use of com.github.mikephil.charting.formatter.PercentFormatter in project MPAndroidChart by PhilJay.
the class RealmBaseActivity method styleData.
protected void styleData(ChartData data) {
data.setValueTypeface(mTf);
data.setValueTextSize(8f);
data.setValueTextColor(Color.DKGRAY);
data.setValueFormatter(new PercentFormatter());
}
use of com.github.mikephil.charting.formatter.PercentFormatter in project MPAndroidChart by PhilJay.
the class RealmBaseActivity method setup.
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.getDescription().setEnabled(false);
// enable touch gestures
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
YAxis leftAxis = mChart.getAxisLeft();
// reset all limit lines to avoid overlapping lines
leftAxis.removeAllLimitLines();
leftAxis.setTypeface(mTf);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.DKGRAY);
leftAxis.setValueFormatter(new PercentFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTf);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.DKGRAY);
mChart.getAxisRight().setEnabled(false);
}
}
use of com.github.mikephil.charting.formatter.PercentFormatter in project MPAndroidChart by PhilJay.
the class PiePolylineChartActivity method setData.
private void setData(int count, float range) {
float mult = range;
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
// the chart.
for (int i = 0; i < count; i++) {
entries.add(new PieEntry((float) (Math.random() * mult) + mult / 5, mParties[i % mParties.length]));
}
PieDataSet dataSet = new PieDataSet(entries, "Election Results");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int c : ColorTemplate.VORDIPLOM_COLORS) colors.add(c);
for (int c : ColorTemplate.JOYFUL_COLORS) colors.add(c);
for (int c : ColorTemplate.COLORFUL_COLORS) colors.add(c);
for (int c : ColorTemplate.LIBERTY_COLORS) colors.add(c);
for (int c : ColorTemplate.PASTEL_COLORS) colors.add(c);
colors.add(ColorTemplate.getHoloBlue());
dataSet.setColors(colors);
//dataSet.setSelectionShift(0f);
dataSet.setValueLinePart1OffsetPercentage(80.f);
dataSet.setValueLinePart1Length(0.2f);
dataSet.setValueLinePart2Length(0.4f);
//dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.BLACK);
data.setValueTypeface(tf);
mChart.setData(data);
// undo all highlights
mChart.highlightValues(null);
mChart.invalidate();
}
use of com.github.mikephil.charting.formatter.PercentFormatter in project MPAndroidChart by PhilJay.
the class HalfPieChartActivity method setData.
private void setData(int count, float range) {
ArrayList<PieEntry> values = new ArrayList<PieEntry>();
for (int i = 0; i < count; i++) {
values.add(new PieEntry((float) ((Math.random() * range) + range / 5), mParties[i % mParties.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(mTfLight);
mChart.setData(data);
mChart.invalidate();
}
use of com.github.mikephil.charting.formatter.PercentFormatter in project MPAndroidChart by PhilJay.
the class PieChartActivity method setData.
private void setData(int count, float range) {
float mult = range;
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
// the chart.
for (int i = 0; i < count; i++) {
entries.add(new PieEntry((float) ((Math.random() * mult) + mult / 5), mParties[i % mParties.length], getResources().getDrawable(R.drawable.star)));
}
PieDataSet dataSet = new PieDataSet(entries, "Election Results");
dataSet.setDrawIcons(false);
dataSet.setSliceSpace(3f);
dataSet.setIconsOffset(new MPPointF(0, 40));
dataSet.setSelectionShift(5f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int c : ColorTemplate.VORDIPLOM_COLORS) colors.add(c);
for (int c : ColorTemplate.JOYFUL_COLORS) colors.add(c);
for (int c : ColorTemplate.COLORFUL_COLORS) colors.add(c);
for (int c : ColorTemplate.LIBERTY_COLORS) colors.add(c);
for (int c : ColorTemplate.PASTEL_COLORS) colors.add(c);
colors.add(ColorTemplate.getHoloBlue());
dataSet.setColors(colors);
//dataSet.setSelectionShift(0f);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(mTfLight);
mChart.setData(data);
// undo all highlights
mChart.highlightValues(null);
mChart.invalidate();
}
Aggregations