本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet类的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet类的具体用法?Java BarDataSet怎么用?Java BarDataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BarDataSet类属于com.github.mikephil.charting.data包,在下文中一共展示了BarDataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
protected BarData generateBarData(int dataSets, float range, int count) {
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
for(int i = 0; i < dataSets; i++) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
// entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
for(int j = 0; j < count; j++) {
entries.add(new BarEntry((float) (Math.random() * range) + range / 4, j));
}
BarDataSet ds = new BarDataSet(entries, getLabel(i));
ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
sets.add(ds);
}
BarData d = new BarData(ChartData.generateXVals(0, count), sets);
d.setValueTypeface(tf);
return d;
}
示例2: onCreate
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.timevis_layout);
barchart = (BarChart) findViewById(R.id.barchart);
Intent intent = getIntent();
String ot = intent.getExtras().getString("ot");
String pt = intent.getExtras().getString("pt");
String lt = intent.getExtras().getString("lt");
String pert = intent.getExtras().getString("pert");
Float otf = Float.valueOf(ot);
Float ptf = Float.valueOf(pt);
Float ltf = Float.valueOf(lt);
Float pertf = Float.valueOf(pert);
List<BarEntry> entries = new ArrayList<>();
entries.add(new BarEntry(0f, otf.floatValue()));
entries.add(new BarEntry(1f, ptf.floatValue()));
entries.add(new BarEntry(2f, ltf.floatValue()));
entries.add(new BarEntry(3f, pertf.floatValue()));
BarDataSet set = new BarDataSet(entries, "Time Visualization");
BarData data = new BarData(set);
data.setBarWidth(0.9f); // set custom bar width
barchart.setData(data);
barchart.setFitBars(true); // make the x-axis fit exactly all bars
barchart.invalidate();
}
示例3: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
protected BarData generateBarData(int dataSets, float range, int count) {
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
for(int i = 0; i < dataSets; i++) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
// entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
for(int j = 0; j < count; j++) {
entries.add(new BarEntry(j, (float) (Math.random() * range) + range / 4));
}
BarDataSet ds = new BarDataSet(entries, getLabel(i));
ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
sets.add(ds);
}
BarData d = new BarData(sets);
d.setValueTypeface(tf);
return d;
}
示例4: generateData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateData(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry(i, (float) (Math.random() * 70) + 30));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setBarShadowColor(Color.rgb(203, 203, 203));
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
sets.add(d);
BarData cd = new BarData(sets);
cd.setBarWidth(0.9f);
return cd;
}
示例5: generateDataBar
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateDataBar(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry(i, (int) (Math.random() * 70) + 30));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setHighLightAlpha(255);
BarData cd = new BarData(d);
cd.setBarWidth(0.9f);
return cd;
}
示例6: setData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
private void setData(int count) {
ArrayList<BarEntry> yVals = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * count) + 15;
yVals.add(new BarEntry(i, (int) val));
}
BarDataSet set = new BarDataSet(yVals, "Data Set");
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
set.setDrawValues(false);
BarData data = new BarData(set);
mChart.setData(data);
mChart.invalidate();
mChart.animateY(800);
}
示例7: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
private BarData generateBarData(List<Integer> progressSoFar) {
ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());
DateTime dateTime = new DateTime();
referenceTime = dateTime.minusDays(7).getMillis();
int totalSeconds = 0;
for (int i = 0; i < progressSoFar.size(); i++) {
int progress = progressSoFar.get(i);
barEntries.add(new BarEntry(i, progress));
totalSeconds += progress;
}
activityTotal.setText(context.getString(R.string.total_project_time,
FormatUtils.getFormattedTime(context, totalSeconds)));
BarDataSet barDataSet = new BarDataSet(barEntries, "");
barDataSet.setColors(blue400);
BarData barData = new BarData(barDataSet);
barData.setBarWidth(0.85f);
barData.setDrawValues(false);
return barData;
}
示例8: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
private BarData generateBarData(int dailyGoal, List<Integer> progressSoFar) {
ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());
DateTime dateTime = new DateTime();
referenceTime = dateTime.minusDays(7).getMillis();
for (int i = 0; i < progressSoFar.size(); i++) {
barEntries.add(new BarEntry(i, progressSoFar.get(i)));
}
BarDataSet barDataSet = new BarDataSet(barEntries, "");
int colors[] = new int[progressSoFar.size()];
for (int i = 0; i < progressSoFar.size(); i++) {
colors[i] = (progressSoFar.get(i) >= dailyGoal * 60 * 60) ? green400 : red400;
}
barDataSet.setColors(colors);
BarData barData = new BarData(barDataSet);
barData.setBarWidth(0.85f);
barData.setDrawValues(false);
return barData;
}
示例9: prepareChartData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
public void prepareChartData(Hit hit){
entries = new ArrayList<BarEntry>();
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
entries.add(new BarEntry(0, (float) (hit.getFields().getNfCalories()/2000)*100));
entries.add(new BarEntry(1, (float) (hit.getFields().getNfTotalFat()/65)*100));
entries.add(new BarEntry(2, (float) (hit.getFields().getNfCholesterol()/300)*100));
entries.add(new BarEntry(3, (float)(hit.getFields().getNfSodium()/2400)*100));
entries.add(new BarEntry(4, (float)(hit.getFields().getNfTotalCarbohydrate()/300)*100));
entries.add(new BarEntry(5, (float) hit.getFields().getNfSodium()));
entries.add(new BarEntry(6, (float) (hit.getFields().getNfProtein()/50)*100));
// entries.add(new BarEntry(7, (float) hit.getFields().getNfVitaminADv(), "(mg)"));
// entries.add(new BarEntry(8, (float) hit.getFields().getNfVitaminCDv(), "(mg)"));
// entries.add(new BarEntry(9, (float) hit.getFields().getNfCalciumDv(), "(mg)"));
BarDataSet dataSet = new BarDataSet(entries, String.format("%s Nutrition", food_item).toUpperCase());
setChartData(dataSet);
}
示例10: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
/**
* 柱形图数据
*/
private BarData generateBarData() {
BarData barData = new BarData();
ArrayList<BarEntry> entries1 = new ArrayList<>();
for (int index = 0; index < items.size(); index++) {
entries1.add(new BarEntry(index + 1f, (float) items.get(index).main_data.getData()));
}
BarDataSet barDataSet = new BarDataSet(entries1, "当前数据");
barDataSet.setValues(entries1);
barDataSet.setDrawValues(false);//是否在线上显示值
barDataSet.setColor(Color.rgb(230, 230, 230));
barDataSet.setHighLightColor(Color.parseColor(items.get(dateSelected).state.getColor()));
barDataSet.setValueTextColor(Color.rgb(60, 220, 78));
barDataSet.setValueTextSize(10f);
barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
float barWidth = 0.45f;
barData.addDataSet(barDataSet);
barData.setBarWidth(barWidth);
return barData;
}
示例11: generateData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateData(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setBarSpacePercent(20f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setBarShadowColor(Color.rgb(203, 203, 203));
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
sets.add(d);
BarData cd = new BarData(getMonths(), sets);
return cd;
}
示例12: generateDataBar
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateDataBar(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setBarSpacePercent(20f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setHighLightAlpha(255);
BarData cd = new BarData(getMonths(), d);
return cd;
}
示例13: setData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
private void setData(int count) {
ArrayList<BarEntry> yVals = new ArrayList<BarEntry>();
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * count) + 15;
yVals.add(new BarEntry((int) val, i));
xVals.add((int) val + "");
}
BarDataSet set = new BarDataSet(yVals, "Data Set");
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
set.setDrawValues(false);
BarData data = new BarData(xVals, set);
mChart.setData(data);
mChart.invalidate();
mChart.animateY(800);
}
示例14: setData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
private void setData(int count, float range) {
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add(mMonths[i % 12]);
yVals1.add(new BarEntry((float) (Math.random() * range), i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet 1");
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setValueTypeface(tf);
mChart.setData(data);
}
示例15: generateOrderBarData
import com.github.mikephil.charting.data.BarDataSet; //导入依赖的package包/类
private BarData generateOrderBarData(List<MarketHistory> historyEntries) {
SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());
int size = historyEntries.size();
List<BarEntry> entries = new ArrayList<>(size);
List<String> xAxis = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
MarketHistory history = historyEntries.get(i);
Date recordDate = new Date(history.getRecordDate());
xAxis.add(format.format(recordDate));
entries.add(new BarEntry((float) history.getOrderCount(), i));
}
BarDataSet set = new BarDataSet(entries, "Order Count");
set.setColor(Color.parseColor("#99FF99"));
// set.setValueTextSize(0f);
set.setDrawValues(false);
set.setAxisDependency(YAxis.AxisDependency.RIGHT);
return new BarData(xAxis, set);
}