Java Code Examples for com.github.mikephil.charting.data.PieData#setValueTypeface()
The following examples show how to use
com.github.mikephil.charting.data.PieData#setValueTypeface() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleFragment.java From StockChart-MPAndroidChart with MIT License | 6 votes |
/** * generates less data (1 DataSet, 4 values) * @return PieData */ protected PieData generatePieData() { int count = 4; ArrayList<PieEntry> entries1 = new ArrayList<>(); for(int i = 0; i < count; i++) { entries1.add(new PieEntry((float) ((Math.random() * 60) + 40), "Quarter " + (i+1))); } PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2015"); ds1.setColors(ColorTemplate.VORDIPLOM_COLORS); ds1.setSliceSpace(2f); ds1.setValueTextColor(Color.WHITE); ds1.setValueTextSize(12f); PieData d = new PieData(ds1); d.setValueTypeface(tf); return d; }
Example 2
Source File: HalfPieChartActivity.java From StockChart-MPAndroidChart with MIT License | 6 votes |
private void setData(int count, float range) { ArrayList<PieEntry> values = new ArrayList<>(); for (int i = 0; i < count; i++) { values.add(new PieEntry((float) ((Math.random() * range) + range / 5), parties[i % parties.length])); } PieDataSet dataSet = new PieDataSet(values, "Election Results"); dataSet.setSliceSpace(3f); dataSet.setSelectionShift(5f); dataSet.setColors(ColorTemplate.MATERIAL_COLORS); //dataSet.setSelectionShift(0f); PieData data = new PieData(dataSet); data.setValueFormatter(new PercentFormatter()); data.setValueTextSize(11f); data.setValueTextColor(Color.WHITE); data.setValueTypeface(tfLight); chart.setData(data); chart.invalidate(); }
Example 3
Source File: SimpleFragment.java From Stayfit with Apache License 2.0 | 5 votes |
/** * generates less data (1 DataSet, 4 values) * @return */ protected PieData generatePieData() { int count = 4; ArrayList<Entry> entries1 = new ArrayList<Entry>(); ArrayList<String> xVals = new ArrayList<String>(); xVals.add("Quarter 1"); xVals.add("Quarter 2"); xVals.add("Quarter 3"); xVals.add("Quarter 4"); for(int i = 0; i < count; i++) { xVals.add("entry" + (i+1)); entries1.add(new Entry((float) (Math.random() * 60) + 40, i)); } PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2015"); ds1.setColors(ColorTemplate.VORDIPLOM_COLORS); ds1.setSliceSpace(2f); ds1.setValueTextColor(Color.WHITE); ds1.setValueTextSize(12f); PieData d = new PieData(xVals, ds1); d.setValueTypeface(tf); return d; }
Example 4
Source File: PieChartActivity.java From iMoney with Apache License 2.0 | 4 votes |
@Override protected void initData() { ivBack.setVisibility(View.VISIBLE); ivSetting.setVisibility(View.GONE); tvTitle.setText("饼状图"); // 初始化字体库 mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); pieChart.setDescription("目前android市场的占比情况"); // 设置内部圆的半径 pieChart.setHoleRadius(52f); // 设置包裹内部圆的半径 pieChart.setTransparentCircleRadius(67f); pieChart.setCenterText("Android\n市场占比"); // 设置中间显示的文本的字体 pieChart.setCenterTextTypeface(mTf); // 设置中间显示的文本的字体大小 pieChart.setCenterTextSize(18f); // 显示的各个部分的占比和是否为100% pieChart.setUsePercentValues(true); // 产生饼状图的数据 PieData mChartData = generateDataPie(); // 设置显示数据的格式 mChartData.setValueFormatter(new PercentFormatter()); mChartData.setValueTypeface(mTf); // 设置显示各个部分的文字的字体大小 mChartData.setValueTextSize(11f); // 设置显示各个部分的文字的字体颜色 mChartData.setValueTextColor(Color.RED); // set data pieChart.setData(mChartData); //获取图示的说明结构 Legend l = pieChart.getLegend(); //设置显示的位置 l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART); //设置几项说明在Y轴方向的间距 l.setYEntrySpace(10f); //设置第一项距离y轴顶部的间距 l.setYOffset(30f); // do not forget to refresh the chart // pieChart.invalidate(); pieChart.animateXY(900, 900); }