【发布时间】:2014-04-04 11:22:41
【问题描述】:
我正在尝试使用 achartengine 显示条形图,但我得到没有颜色的透明条形图,而且我只是在条形图顶部获得数字(y 坐标)。 我使用了这段代码: 类 SalesStackedBarChart
public class SalesStackedBarChart extends AbstractDemoChart {
/**
* Returns the chart name.
*
* @return the chart name
*/
public String getName() {
return "Sales** stacked bar chart";
}
/**
* Returns the chart description.
*
* @return the chart description
*/
public String getDesc() {
return "The monthly** sales for the last 2 years (stacked bar chart)";
}
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "2008", "2007" };
List<double[]> values = new ArrayList<double[]>();
/* values.add(new double[] { 14230, 12300, 0, 15244, 15900, 19200, 22030, 21200, 19500, 15500,
12600, 14000 });
values.add(new double[] { 5230, 7300, 0, 10540, 7900, 9200, 12030, 11200, 9500, 10500,
11600, 13500 });*/
values.add(new double[] { -65, -71, 0, -80, -90, -20, -10, -95, -89, -75,
-95, -35,-45,-68 });
values.add(new double[] { -71, -65, 0, -80, -90, -10, -20, -95, -89, -75,
-95, -35,-45,-68 });
int[] colors = new int[] { Color.BLUE, Color.CYAN };
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
setChartSettings(renderer, "Monthly sales in the last 2 years", "Month", "Units sold", 0,
12, -100, -30, Color.GRAY, Color.LTGRAY);
renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
renderer.getSeriesRendererAt(1).setDisplayChartValues(true);
renderer.setXLabels(12);
renderer.setYLabels(10);
renderer.setXLabelsAlign(Align.LEFT);
renderer.setYLabelsAlign(Align.LEFT);
renderer.setPanEnabled(true, false);
// renderer.setZoomEnabled(false);
renderer.setZoomRate(1.1f);
renderer.setBarSpacing(0.5f);
return ChartFactory.getBarChartIntent(context, buildBarDataset(titles, values), renderer,
Type.STACKED);
}
}
【问题讨论】:
标签: android bar-chart achartengine