我正在使用MPAndroidChart。如何在组合图表中创建多部分条形图系列,我将条形图和折线图组合在一起
这是我的代码,请看看
private BarData generateBarData(List arrayList){
ArrayList<BarEntry> barEntries = new ArrayList<BarEntry>();
BarData barData = new BarData();
for(int counter=0;counter<arrayList.size();counter++)
{
barEntries.add(new BarEntry(20.0f,counter));
}
BarDataSet barDataSet = new BarDataSet(barEntries,"Bar Dataset");
barDataSet.setColor(Color.rgb(60, 220, 78));
barDataSet.setValueTextColor(Color.rgb(60,220,78));
barDataSet.setValueTextSize(10f);
barData.addDataSet(barDataSet);
barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
return barData;
}
private LineData generateLineData(ArrayList arrayList){
ArrayList<Entry> lineEntries = new ArrayList<Entry>();
LineData lineData = new LineData();
for(int counter=0;counter<arrayList.size();counter++)
{
lineEntries.add(new Entry(20.4f,counter));
}
LineDataSet lineDataSet = new LineDataSet(lineEntries,"Line Dataset");
lineDataSet.setColor(Color.rgb(240,238,70));
lineDataSet.setLineWidth(2.5f);
lineDataSet.setCircleColor(Color.rgb(240, 238, 70));
lineDataSet.setCircleSize(5f);
lineDataSet.setFillColor(Color.rgb(240, 238, 70));
lineDataSet.setDrawCubic(true);
lineDataSet.setDrawValues(true);
lineDataSet.setValueTextSize(10f);
lineDataSet.setValueTextColor(Color.rgb(240, 238, 70));
lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
lineData.addDataSet(lineDataSet);
return lineData;
}
答案 0 :(得分:0)
在CombinedChart
中, v3.0.0 之前的版本不支持多个BarDataSets
。
自release v3.0.0起,CombinedChart
支持多个小节。