本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet.setValueFormatter方法的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet.setValueFormatter方法的具体用法?Java BarDataSet.setValueFormatter怎么用?Java BarDataSet.setValueFormatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarDataSet
的用法示例。
在下文中一共展示了BarDataSet.setValueFormatter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TestCaseRunner
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
TestCaseRunner(int iterations, BarChart chart, String title, int color, IValueFormatter valueFormatter) {
mIterations = iterations;
mChart = chart;
mEntries = new LinkedList<>();
mDataSet = new BarDataSet(mEntries, title);
mDataSet.setValueFormatter(valueFormatter);
mDataSet.setColor(color);
}
示例2: getBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData getBarData(List<String> xVals, List<BarEntry> barEntries) {
final BarDataSet dataSet = new BarDataSet(barEntries, getContext().getString(R.string.servings));
dataSet.setColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
dataSet.setValueTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
dataSet.setValueTextSize(14);
// We just want the value as an integer
dataSet.setValueFormatter(new BarChartValueFormatter());
return new BarData(xVals, dataSet);
}
示例3: addDataSet
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void addDataSet(GraphData graphData) {
Log.e("yangjun", "----- addDataSet ----");
BarData barData = partBartChart.getData();
if (barData != null) {
Log.e("yangjun", "----- clear values ----");
barData.clearValues();
}
List<Partition> partitions = graphData.getPartitions();
// READ
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < partitions.size(); i++) {
yVals1.add(new BarEntry(partitions.get(i).readLogs.size(), i));
}
// WRITE
ArrayList<BarEntry> yVals2 = new ArrayList<BarEntry>();
for (int i = 0; i < partitions.size(); i++) {
yVals2.add(new BarEntry(partitions.get(i).writeLogs.size(), i));
}
BarDataSet set1 = new BarDataSet(yVals1, "READ");
set1.setColor(Color.rgb(104, 241, 175));
set1.setValueFormatter(new LargeValueFormatter());
BarDataSet set2 = new BarDataSet(yVals2, "WRITE");
set2.setColor(Color.rgb(164, 228, 251));
set2.setValueFormatter(new LargeValueFormatter());
barData.addDataSet(set1);
barData.addDataSet(set2);
partBartChart.notifyDataSetChanged();
partBartChart.invalidate();
}
示例4: onCreate
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_age_distribution);
setTitle("Age Distribution Austria");
mChart = (HorizontalBarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setDescription("");
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getAxisLeft().setEnabled(false);
mChart.getAxisRight().setAxisMaxValue(25f);
mChart.getAxisRight().setAxisMinValue(-25f);
mChart.getAxisRight().setDrawGridLines(false);
mChart.getAxisRight().setDrawZeroLine(true);
mChart.getAxisRight().setLabelCount(7, false);
mChart.getAxisRight().setValueFormatter(new CustomFormatter());
mChart.getAxisRight().setTextSize(9f);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTH_SIDED);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setTextSize(9f);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
l.setFormSize(8f);
l.setFormToTextSpace(4f);
l.setXEntrySpace(6f);
// IMPORTANT: When using negative values in stacked bars, always make sure the negative values are in the array first
ArrayList<BarEntry> yValues = new ArrayList<BarEntry>();
yValues.add(new BarEntry(new float[]{ -10, 10 }, 0));
yValues.add(new BarEntry(new float[]{ -12, 13 }, 1));
yValues.add(new BarEntry(new float[]{ -15, 15 }, 2));
yValues.add(new BarEntry(new float[]{ -17, 17 }, 3));
yValues.add(new BarEntry(new float[]{ -19, 20 }, 4));
yValues.add(new BarEntry(new float[]{ -19, 19 }, 5));
yValues.add(new BarEntry(new float[]{ -16, 16 }, 6));
yValues.add(new BarEntry(new float[]{ -13, 14 }, 7));
yValues.add(new BarEntry(new float[]{ -10, 11 }, 8));
yValues.add(new BarEntry(new float[]{ -5, 6 }, 9));
yValues.add(new BarEntry(new float[]{ -1, 2 }, 10));
BarDataSet set = new BarDataSet(yValues, "Age Distribution");
set.setValueFormatter(new CustomFormatter());
set.setValueTextSize(7f);
set.setAxisDependency(YAxis.AxisDependency.RIGHT);
set.setBarSpacePercent(40f);
set.setColors(new int[] {Color.rgb(67,67,72), Color.rgb(124,181,236)});
set.setStackLabels(new String[]{
"Men", "Women"
});
String []xVals = new String[]{"0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90", "90-100", "100+"};
BarData data = new BarData(xVals, set);
mChart.setData(data);
mChart.invalidate();
}