本文整理汇总了Java中com.github.mikephil.charting.components.Legend.setYOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Legend.setYOffset方法的具体用法?Java Legend.setYOffset怎么用?Java Legend.setYOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.Legend
的用法示例。
在下文中一共展示了Legend.setYOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
mChart = (ScatterChart) v.findViewById(R.id.scatterChart1);
mChart.getDescription().setEnabled(false);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv);
mChart.setDrawGridBackground(false);
mChart.setData(generateScatterData(6, 10000, 200));
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(tf);
rightAxis.setDrawGridLines(false);
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setTypeface(tf);
l.setFormSize(14f);
l.setTextSize(9f);
// increase the space between legend & bottom and legend & content
l.setYOffset(13f);
mChart.setExtraBottomOffset(16f);
return v;
}
示例2: onCreate
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(4);
mSeekBarY.setProgress(10);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.getDescription().setEnabled(false);
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setCenterTextTypeface(mTfLight);
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(4, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
// entry label styling
mChart.setEntryLabelColor(Color.WHITE);
mChart.setEntryLabelTypeface(mTfRegular);
mChart.setEntryLabelTextSize(12f);
}
示例3: configChart
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
private void configChart(Station station, PieChart mChart) {
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setCenterText(getString(R.string.base_state));
mChart.setDrawHoleEnabled(true);
mChart.setHoleColorTransparent(true);
mChart.setUsePercentValues(false);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setTouchEnabled(false);
mChart.setRotationEnabled(false);
mChart.setRotationAngle(0);
setData(mChart, station);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setEnabled(false);
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
}
示例4: bindTo
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
public void bindTo(Station value) {
nameTextView.setText(value.getNumberStation() + " " + value.getNombre());
streetTextView.setText(value.getAddress());
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setCenterText(context.getString(R.string.base_state));
mChart.setDrawHoleEnabled(true);
mChart.setHoleColorTransparent(true);
mChart.setUsePercentValues(false);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setTouchEnabled(false);
mChart.setRotationEnabled(false);
mChart.setRotationAngle(0);
setData(value);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
}
示例5: init
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyle) {
setUsePercentValues(true);
getDescription().setEnabled(false);
setExtraOffsets(5, 10, 5, 5);
setDragDecelerationFrictionCoef(0.95f);
setDrawHoleEnabled(true);
setHoleColor(Color.WHITE);
setTransparentCircleColor(Color.WHITE);
setTransparentCircleAlpha(110);
setHoleRadius(58f);
setTransparentCircleRadius(61f);
setDrawCenterText(true);
setRotationAngle(0);
setRotationEnabled(true);
setHighlightPerTapEnabled(true);
Legend l = getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setTextColor(Color.GRAY);
l.setDrawInside(false);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
setEntryLabelColor(Color.GRAY);
setEntryLabelTextSize(12f);
}
示例6: setDefaultPieChartProperties
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
private void setDefaultPieChartProperties(AndiCarPieChart pieChart) {
pieChart.setUsePercentValues(false);
pieChart.getDescription().setEnabled(false);
pieChart.setDrawEntryLabels(false);
pieChart.setDragDecelerationFrictionCoef(0.95f);
pieChart.setDrawHoleEnabled(false);
pieChart.setRotationAngle(0);
//disable rotation of the chart by touch
pieChart.setRotationEnabled(false);
pieChart.setHighlightPerTapEnabled(false);
pieChart.animateY(700, Easing.EasingOption.EaseInOutQuad);
// entry label styling
pieChart.setEntryLabelColor(Color.WHITE);
pieChart.setTouchEnabled(true);
Legend l = pieChart.getLegend();
if (mChartsLine.getTag() != null && mChartsLine.getTag().equals(getResources().getString(R.string.chart_key_legendAtRight))) {
l.setVerticalAlignment(Legend.LegendVerticalAlignment.CENTER);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
}
else {
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
}
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(10f);
}
示例7: onCreateView
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
mChart = (ScatterChart) v.findViewById(R.id.scatterChart1);
mChart.setDescription("");
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mChart.setMarkerView(mv);
mChart.setDrawGridBackground(false);
mChart.setData(generateScatterData(6, 10000, 200));
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setTypeface(tf);
rightAxis.setDrawGridLines(false);
Legend l = mChart.getLegend();
l.setWordWrapEnabled(true);
l.setTypeface(tf);
l.setFormSize(14f);
l.setTextSize(9f);
// increase the space between legend & bottom and legend & content
l.setYOffset(13f);
mChart.setExtraBottomOffset(16f);
return v;
}
示例8: onCreate
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvX.setTextSize(10);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.getDescription().setEnabled(false);
// mChart.setDrawBorders(true);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv); // Set the marker to the chart
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(100);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(true);
l.setTypeface(mTfLight);
l.setYOffset(0f);
l.setXOffset(10f);
l.setYEntrySpace(0f);
l.setTextSize(8f);
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTfLight);
xAxis.setGranularity(1f);
xAxis.setCenterAxisLabels(true);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return String.valueOf((int) value);
}
});
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setValueFormatter(new LargeValueFormatter());
leftAxis.setDrawGridLines(false);
leftAxis.setSpaceTop(35f);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
}
示例9: onCreate
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart_half);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
moveOffScreen();
mChart.setUsePercentValues(true);
mChart.getDescription().setEnabled(false);
mChart.setCenterTextTypeface(mTfLight);
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationEnabled(false);
mChart.setHighlightPerTapEnabled(true);
mChart.setMaxAngle(180f); // HALF CHART
mChart.setRotationAngle(180f);
mChart.setCenterTextOffset(0, -20);
setData(4, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
// entry label styling
mChart.setEntryLabelColor(Color.WHITE);
mChart.setEntryLabelTypeface(mTfRegular);
mChart.setEntryLabelTextSize(12f);
}
示例10: getView
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(
R.layout.list_item_piechart, null);
holder.chart = (PieChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
holder.chart.getDescription().setEnabled(false);
holder.chart.setHoleRadius(52f);
holder.chart.setTransparentCircleRadius(57f);
holder.chart.setCenterText(mCenterText);
holder.chart.setCenterTextTypeface(mTf);
holder.chart.setCenterTextSize(9f);
holder.chart.setUsePercentValues(true);
holder.chart.setExtraOffsets(5, 10, 50, 10);
mChartData.setValueFormatter(new PercentFormatter());
mChartData.setValueTypeface(mTf);
mChartData.setValueTextSize(11f);
mChartData.setValueTextColor(Color.WHITE);
// set data
holder.chart.setData((PieData) mChartData);
Legend l = holder.chart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setYEntrySpace(0f);
l.setYOffset(0f);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(900);
return convertView;
}
示例11: setGroupBarChart
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
/**
* Set the pie pattern
* @param barChart chart
* @param chartData pie chart data
* @param context context
* @param typeface Typeface font
*/
public static void setGroupBarChart(Context context, BarChart barChart, ChartData<?> chartData,
Typeface typeface) {
barChart.getDescription().setEnabled(false);
// scaling can now only be done on x- and y-axis separately
barChart.setPinchZoom(false);
barChart.setDrawBarShadow(false);
barChart.setDrawGridBackground(false);
// create a custom MarkerView (extend MarkerView) and specify the layout to use for it
SalaryMarker mv = new SalaryMarker(context, R.layout.marker_salary_detail);
mv.setChartView(barChart); // For bounds control
barChart.setMarker(mv); // Set the marker to the chart
barChart.setDrawMarkers(false);
Legend l = barChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(true);
l.setTypeface(typeface);
l.setYOffset(0f);
l.setXOffset(10f);
l.setYEntrySpace(0f);
l.setTextSize(8f);
XAxis xAxis = barChart.getXAxis();
xAxis.setTypeface(typeface);
xAxis.setGranularity(1f);
xAxis.setTextSize(8f);
xAxis.setCenterAxisLabels(true);
xAxis.setValueFormatter(new GroupBarValueFormatter());
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setValueFormatter(new LargeValueFormatter());
leftAxis.setDrawGridLines(false);
leftAxis.setSpaceTop(35f);
leftAxis.setAxisMinimum(0f);
barChart.getAxisRight().setEnabled(false);
barChart.setData((BarData) chartData);
}
示例12: onCreate
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDescription("");
// mChart.setDrawBorders(true);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
// define an offset to change the original position of the marker
// (optional)
// mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
// set the marker to the chart
mChart.setMarkerView(mv);
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(100);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART_INSIDE);
l.setTypeface(tf);
l.setYOffset(0f);
l.setYEntrySpace(0f);
l.setTextSize(8f);
XAxis xl = mChart.getXAxis();
xl.setTypeface(tf);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
leftAxis.setValueFormatter(new LargeValueFormatter());
leftAxis.setDrawGridLines(false);
leftAxis.setSpaceTop(30f);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
}
示例13: getView
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(
R.layout.list_item_piechart, null);
holder.chart = (PieChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
holder.chart.setDescription("");
holder.chart.setHoleRadius(52f);
holder.chart.setTransparentCircleRadius(57f);
holder.chart.setCenterText(mCenterText);
holder.chart.setCenterTextTypeface(mTf);
holder.chart.setCenterTextSize(9f);
holder.chart.setUsePercentValues(true);
holder.chart.setExtraOffsets(5, 10, 50, 10);
mChartData.setValueFormatter(new PercentFormatter());
mChartData.setValueTypeface(mTf);
mChartData.setValueTextSize(11f);
mChartData.setValueTextColor(Color.WHITE);
// set data
holder.chart.setData((PieData) mChartData);
Legend l = holder.chart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
l.setYEntrySpace(0f);
l.setYOffset(0f);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(900);
return convertView;
}
示例14: onCreate
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setProgress(10);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(3, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
}
示例15: onCreate
import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_chart_pie);
try {
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setProgress(10);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// 设置圆盘中间区域的字体
mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(3, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
} catch (Exception e) {
e.printStackTrace();
}
}