本文整理汇总了Java中com.github.mikephil.charting.formatter.YAxisValueFormatter类的典型用法代码示例。如果您正苦于以下问题:Java YAxisValueFormatter类的具体用法?Java YAxisValueFormatter怎么用?Java YAxisValueFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
YAxisValueFormatter类属于com.github.mikephil.charting.formatter包,在下文中一共展示了YAxisValueFormatter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setData
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = "reception rate per second";
if (!format.equals("%"))
legend = "packet count per second";
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例2: setValueFormatter
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
/**
* Sets the formatter to be used for formatting the axis labels. If no formatter is set, the chart will
* automatically determine a reasonable formatting (concerning decimals) for all the values that are drawn inside
* the chart. Use chart.getDefaultValueFormatter() to use the formatter calculated by the chart.
*
* @param f
*/
public void setValueFormatter(YAxisValueFormatter f) {
if (f == null)
mYAxisValueFormatter = new DefaultYAxisValueFormatter(mDecimals);
else
mYAxisValueFormatter = f;
}
示例3: setValueFormatter
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
/**
* Sets the formatter to be used for formatting the axis labels. If no formatter is set, the chart will
* automatically determine a reasonable formatting (concerning decimals) for all the values that are drawn inside
* the chart. Use chart.getDefaultValueFormatter() to use the formatter calculated by the chart.
*
* @param f
*/
public void setValueFormatter(YAxisValueFormatter f) {
if (f == null)
mYAxisValueFormatter = new DefaultYAxisValueFormatter(mDecimals);
else
mYAxisValueFormatter = f;
}
示例4: setData
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
if (valueList != null) {
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!format.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例5: initChart
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
/**
* initiliaze chart
*/
private void initChart() {
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDescriptionColor(Color.parseColor("#000000"));
XAxis xAxis = mChart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setSpaceBetweenLabels(0);
YAxisValueFormatter custom = new DataAxisFormatter("%");
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setValueFormatter(custom);
rightAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setDrawGridLines(true);
rightAxis.setDrawGridLines(false);
mChart.animateY(1000);
mChart.getLegend().setEnabled(true);
mChart.setVisibility(View.GONE);
}
示例6: setData
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
/**
* update data for visualization chart
*
* @param valueList list of values for the chart
* @param unit data unit
*/
private void setData(List<Integer> valueList, String unit) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!unit.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(unit);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例7: setupChart
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
private void setupChart() {
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
mChart.setMaxVisibleValueCount(60);
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(2);
YAxisValueFormatter custom = new PercentFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinValue(0f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinValue(0f);
Legend legend = mChart.getLegend();
legend.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
legend.setForm(Legend.LegendForm.CIRCLE);
legend.setFormSize(9f);
legend.setTextSize(11f);
legend.setXEntrySpace(4f);
mChart.animateXY(1000, 1000);
}
示例8: onCreate
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的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);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(2);
YAxisValueFormatter custom = new MyYAxisValueFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
// l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
// l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
// "def", "ghj", "ikl", "mno" });
setData(12, 50);
// setting data
mSeekBarY.setProgress(50);
mSeekBarX.setProgress(12);
mSeekBarY.setOnSeekBarChangeListener(this);
mSeekBarX.setOnSeekBarChangeListener(this);
// mChart.setDrawLegend(false);
}
示例9: setValueFormatter
import com.github.mikephil.charting.formatter.YAxisValueFormatter; //导入依赖的package包/类
/**
* Sets the formatter to be used for formatting the axis labels. If no formatter is set, the
* chart will
* automatically determine a reasonable formatting (concerning decimals) for all the values
* that are drawn inside
* the chart. Use chart.getDefaultValueFormatter() to use the formatter calculated by the chart.
*
* @param f
*/
public void setValueFormatter(YAxisValueFormatter f) {
if (f == null)
mYAxisValueFormatter = new DefaultYAxisValueFormatter(mDecimals);
else
mYAxisValueFormatter = f;
}