本文整理汇总了Java中com.github.mikephil.charting.data.BarData.setValueFormatter方法的典型用法代码示例。如果您正苦于以下问题:Java BarData.setValueFormatter方法的具体用法?Java BarData.setValueFormatter怎么用?Java BarData.setValueFormatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarData
的用法示例。
在下文中一共展示了BarData.setValueFormatter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDownloadRateSuccessful
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public void onDownloadRateSuccessful() {
ArrayList<BarDataSet> dataSets;
ArrayList<BarEntry> valueSet1 = new ArrayList<>();
BarEntry v1e1 = new BarEntry(ratee.fivestar, 0); // Jan
valueSet1.add(v1e1);
BarEntry v1e2 = new BarEntry(ratee.fourstar, 1); // Feb
valueSet1.add(v1e2);
BarEntry v1e3 = new BarEntry(ratee.threestar, 2); // Mar
valueSet1.add(v1e3);
BarEntry v1e4 = new BarEntry(ratee.twostar, 3); // Apr
valueSet1.add(v1e4);
BarEntry v1e5 = new BarEntry(ratee.onestar, 4); // May
valueSet1.add(v1e5);
BarDataSet barDataSet1 = new BarDataSet(valueSet1, "");
barDataSet1.setColors(ColorTemplate.COLORFUL_COLORS);
dataSets = new ArrayList<>();
dataSets.add(barDataSet1);
BarData data = new BarData(getXAxisValues(), dataSets);
// barDataSet1.setValueTextSize(2);
data.setValueFormatter(new MyValueFormatter());
chart.setData(data);
chart.getXAxis().setEnabled(false); // hides horizontal grid lines inside chart
YAxis leftAxis = chart.getAxisLeft();
chart.getAxisRight().setEnabled(false); // hides horizontal grid lines with below line
leftAxis.setEnabled(false); // hides vertical grid lines inside chart
/*chart.animateXY(2000, 2000);*/ // for animating reviews display
chart.invalidate();
chart.setDescription(""); // Hide the description
chart.setPinchZoom(true);
leftAxis.setDrawLabels(true);
}
示例2: createBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
mDashboardHelper = new DashboardHelper(getActivity());
HashMap<String, ArrayList> holder = mDashboardHelper.generateTimesPerDayMap();
ArrayList<String> xVals = holder.get("dayOfThisMonth");
ArrayList<BarEntry> yVals1 = holder.get("episodesPerDay");
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(0xFF2196f3);
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例3: onProgressChanged
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
tvX.setText("" + (mSeekBarX.getProgress() + 1));
tvY.setText("" + (mSeekBarY.getProgress()));
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
xVals.add(mMonths[i % mMonths.length]);
}
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
float mult = (mSeekBarY.getProgress() + 1);
float val1 = (float) (Math.random() * mult) + mult / 3;
float val2 = (float) (Math.random() * mult) + mult / 3;
float val3 = (float) (Math.random() * mult) + mult / 3;
yVals1.add(new BarEntry(new float[] { val1, val2, val3 }, i));
}
BarDataSet set1 = new BarDataSet(yVals1, "Statistics Vienna 2014");
set1.setColors(getColors());
set1.setStackLabels(new String[] { "Births", "Divorces", "Marriages" });
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueFormatter(new MyValueFormatter());
mChart.setData(data);
mChart.invalidate();
}
示例4: setData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
private void setData(List<Data> dataList) {
ArrayList<BarEntry> values = new ArrayList<BarEntry>();
String[] dates = new String[dataList.size()];
List<Integer> colors = new ArrayList<Integer>();
int green = Color.rgb(110, 190, 102);
int red = Color.rgb(211, 74, 88);
for (int i = 0; i < dataList.size(); i++) {
Data d = dataList.get(i);
BarEntry entry = new BarEntry(d.yValue, d.xIndex);
values.add(entry);
dates[i] = dataList.get(i).xAxisValue;
// specific colors
if (d.yValue >= 0)
colors.add(red);
else
colors.add(green);
}
BarDataSet set = new BarDataSet(values, "Values");
set.setBarSpacePercent(40f);
set.setColors(colors);
set.setValueTextColors(colors);
BarData data = new BarData(dates, set);
data.setValueTextSize(13f);
data.setValueTypeface(mTf);
data.setValueFormatter(new ValueFormatter());
mChart.setData(data);
mChart.invalidate();
}
示例5: generateBarData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
private BarData generateBarData(float index, float dis) {
ArrayList<BarEntry> entries = new ArrayList<>();
for (int i = 0; i < count; i++) {
float a = new Random().nextInt(40) / 100f + 0.1f;
float b = new Random().nextInt(40) / 100f + 0.1f;
entries.add(new BarEntry(index, new float[]{a, b, 1 - a - b}));
index += dis;
}
BarDataSet set = new BarDataSet(entries, "hello");
set.setStackLabels(new String[]{"1", "2"});
set.setColors(new int[]{Color.rgb(154, 209, 253), Color.rgb(254, 206, 121), Color.rgb(253, 136, 95)});
set.setValueTextColor(Color.rgb(61, 165, 255));
set.setValueTextSize(10f);
set.setAxisDependency(YAxis.AxisDependency.LEFT);
ArrayList<IBarDataSet> threebardata = new ArrayList<>();
BarData d = new BarData(threebardata);
d.setBarWidth(0.4f);
d.setDrawValues(true);
d.addDataSet(set);
d.setValueFormatter(new IValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return toPercentDecimalStr(value);
}
});
return d;
}
示例6: createBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
ArrayList<String> xVals = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
xVals.add(i + "");
}
ArrayList<BarEntry> yVals1 = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
float mult = (5 + 1);
int val = (int) (Math.random() * mult);
yVals1.add(new BarEntry((val == 0 ? 1 : val), i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(0xFF2196f3);
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例7: createStackedBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createStackedBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
ArrayList<String> xVals = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
xVals.add(i + "");
}
ArrayList<BarEntry> yVals1 = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
float mult = (5 + 1);
int val = (int) (Math.random() * mult);
yVals1.add(new BarEntry(new float[] {(val == 0 ? 1 : val - 1), 1}, i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColors(new int[] {0xFF2196f3, 0xFF3f51b5});
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例8: onDownloadRateSuccessful
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public void onDownloadRateSuccessful() {
ArrayList<BarDataSet> dataSets;
ArrayList<BarEntry> valueSet1 = new ArrayList<>();
BarEntry v1e1 = new BarEntry(ratee.fivestar, 0); // Jan
valueSet1.add(v1e1);
BarEntry v1e2 = new BarEntry(ratee.fourstar, 1); // Feb
valueSet1.add(v1e2);
BarEntry v1e3 = new BarEntry(ratee.threestar, 2); // Mar
valueSet1.add(v1e3);
BarEntry v1e4 = new BarEntry(ratee.twostar, 3); // Apr
valueSet1.add(v1e4);
BarEntry v1e5 = new BarEntry(ratee.onestar, 4); // May
valueSet1.add(v1e5);
BarDataSet barDataSet1 = new BarDataSet(valueSet1, "");
barDataSet1.setColors(ColorTemplate.COLORFUL_COLORS);
dataSets = new ArrayList<>();
dataSets.add(barDataSet1);
BarData data = new BarData(getXAxisValues(), dataSets);
// barDataSet1.setValueTextSize(2);
data.setValueFormatter(new MyValueFormatter());
chart.setData(data);
chart.getXAxis().setEnabled(false); // hides horizontal grid lines inside chart
YAxis leftAxis = chart.getAxisLeft();
chart.getAxisRight().setEnabled(false); // hides horizontal grid lines with below line
leftAxis.setEnabled(false); // hides vertical grid lines inside chart
/*chart.animateXY(2000, 2000);*/ // for animating reviews display
chart.invalidate();
chart.setDescription(""); // Hide the description
chart.setPinchZoom(true);
leftAxis.setDrawLabels(true);
DecimalFormat numberFormat = new DecimalFormat("#.0");
txtrate.setText(Float.parseFloat(rate1) + "");
ratingDetail.setRating(Float.parseFloat(rate1));
txtratecount.setText(point1);
txtcountfavorites.setText(countfavorites + " " + getResources().getString(R.string.favorites));
}