0
我試過使用achart引擎,但文檔有點不清楚。我也試着看過這些例子。achart引擎設置
有人可以解釋如何增加附加的條形圖中的線的粗細?另外,我想將每個欄分成它自己的系列,但我沒有這樣做(我的代碼在圖片下方)。我一直在研究這個問題很長一段時間!
public XYMultipleSeriesRenderer getBarDemoRenderer() {
Log.d(LOG_TAG, "Entering getBarDemoRenderer");
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(18);
renderer.setChartTitleTextSize(20);
renderer.setLabelsTextSize(18);
renderer.setLegendTextSize(14);
renderer.setMargins(new int[] {20, 30, 15, 0});
int[] color = {Color.RED, Color.CYAN,Color.YELLOW, Color.LTGRAY,Color.MAGENTA, Color.GREEN, Color.WHITE};
for(int i=0; i<7; i++){
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(color[i]);
renderer.addSeriesRenderer(r);
}
int renderCount = renderer.getSeriesRendererCount();
Log.d(LOG_TAG, "Renderer series count = " + renderCount);
return renderer;
}
private XYMultipleSeriesDataset getApplianceDataset() {
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
try{
CategorySeries series = null;
for (Map.Entry<String,Float> entry : list.entrySet()) {
String key = entry.getKey();
series = new CategorySeries (key);
String b=String.valueOf(entry.getValue());
double value=Double.valueOf(b);
series.add(value);
dataset.addSeries(series.toXYSeries());
}
}catch(IllegalArgumentException e){
Log.e(LOG_TAG, "IllegalArgumentException " + e.toString());
Toast.makeText(this, "Unable to show chart", Toast.LENGTH_LONG).show();
}
int dataSeriesCount = dataset.getSeriesCount();
return dataset;
}
private void setChartSettings(XYMultipleSeriesRenderer renderer) {
renderer.setChartTitle("Test Bar Chart");
renderer.setChartTitleTextSize(20);
renderer.setXTitle("Appliance");
renderer.setYTitle("Watt Hours (wh)");
renderer.setXAxisMax(3);
renderer.setXAxisMin(0.0);
renderer.setYAxisMax(1800);
renderer.setYAxisMin(0);
}
謝謝SOOOO了!這工作(除了酒吧間距越小,酒吧越大)。所以,renderer.setBarSpacing(0.5f)的結果比renderer.setBarSpacing(1.0f)大。在您指定方法執行此操作後,我能夠查找setBarSpacing並找到相同的問題:http://code.google.com/p/achartengine/issues/detail?id=145。 Thx再次! – 2012-02-02 06:03:01
不錯。感謝您的鏈接。 – AD14 2012-02-02 06:26:52