我正在使用 AChartEngine 库处理饼图。在这里,我想禁用图表值以显示在图表上,但仅限于内容值为 0 的那些。如果有人知道这一点,请分享给我。
编码:
pchart=ChartFactory.getPieChartView(this,buildCategoryDataset("Daily Basis", values),renderer);
re.addView(pchart);
}
}
BuildCategory 渲染器:
protected DefaultRenderer buildCategoryRenderer(int[] colors) {
DefaultRenderer renderer = new DefaultRenderer();
renderer.setLabelsTextSize(10);
renderer.setLegendTextSize(15);
renderer.setShowLegend(true);
renderer.setExternalZoomEnabled(true);
renderer.setZoomEnabled(true);
renderer.setZoomButtonsVisible(true);
renderer.setShowAxes(true);
// renderer.setMargins(new int[] { 20, 30, 15, 0 });
for (int color : colors) {
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(color);
renderer.addSeriesRenderer(r);
}
return renderer;
}
数据集在这里:
protected CategorySeries buildCategoryDataset(String title, double[] values) {
CategorySeries series = new CategorySeries(title);
int k = 0,year;
String str_year;
str_year=String.valueOf(Math.round(values[0]));
Log.i("Invent","Year"+str_year);
year=Integer.parseInt(str_year);
Log.i("Invent","YearInt"+year);
if(flag_val==1)
{
for(k=0;k<tot_yearno-1;k++)
{
if(values[k]==0)
{
series.add(0.0); /// Here some settings for display null value.But **here i Want to display nothing Only.**
}
else
series.add("" + year_first++, values[k]);
}
}
if(flag_val==0)
{
for (double value : values) {
if(value==0)
{
series.add("" + ++k, 0.0);
}
else
series.add("Day " + ++k, value);
}
}
return series;
}
}