我对这个问题非常陌生,之前从未在Achart Engine上工作,我正在尝试使用achart Engine绘制条形图。
这是我的代码快照
productive =new int[] { 2000, 2500, 2700, 3000 };
neutral = new int[]{ 2200, 2700, 2900,2222 };
destructing = new int[]{ 2200, 2700, 2900,2222 };
XYSeries ProductiveSeries = new XYSeries("Productive");
// Creating an XYSeries for Income
XYSeries NuetralSeries = new XYSeries("Nuetral");
XYSeries DescatringSeries = new XYSeries("Nuetral");
// Adding data to Income and Expense Series
for (int i = 0; i < CategoryNum; i++) {
ProductiveSeries.add(i, productive[i]);
NuetralSeries.add(i, neutral[i]);
DescatringSeries.add(i, destructing[i]);
}
// Creating a dataset to hold each series
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
// Adding Income Series to the dataset
dataset.addSeries(ProductiveSeries);
dataset.addSeries(NuetralSeries);
// Adding Expense Series to dataset
dataset.addSeries(DescatringSeries);
// Creating XYSeriesRenderer to customize incomeSeries
XYSeriesRenderer incomeRenderer = new XYSeriesRenderer();
incomeRenderer.setColor(Color.rgb(130, 130, 230));
incomeRenderer.setFillPoints(true);
incomeRenderer.setLineWidth(2);
incomeRenderer.setDisplayChartValues(true);
// Creating XYSeriesRenderer to customize expenseSeries
XYSeriesRenderer expenseRenderer = new XYSeriesRenderer();
expenseRenderer.setColor(Color.rgb(220, 80, 80));
expenseRenderer.setFillPoints(true);
expenseRenderer.setLineWidth(2);
expenseRenderer.setDisplayChartValues(true);
Calendar cal = Calendar.getInstance();
cal.clear(Calendar.HOUR);
// Creating XYSeriesRenderer to customize expenseSeries
XYSeriesRenderer expenseRenderer1 = new XYSeriesRenderer();
expenseRenderer1.setColor(Color.rgb(240, 166, 0));
expenseRenderer1.setFillPoints(true);
expenseRenderer1.setLineWidth(2);
expenseRenderer1.setDisplayChartValues(true);
Calendar cal1 = Calendar.getInstance();
cal1.clear(Calendar.HOUR);
// Creating a XYMultipleSeriesRenderer to customize the whole chart
XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();
multiRenderer.setXLabels(0);
multiRenderer.setChartTitle("Income vs Expense Chart");
multiRenderer.setXTitle("Year 2012");
multiRenderer.setYTitle("Amount in Dollars");
multiRenderer.setZoomButtonsVisible(true);
for (int i = 0; i < CategoryNum; i++) {
multiRenderer.addXTextLabel(i, mMonth[i]);
}
multiRenderer.addSeriesRenderer(incomeRenderer);
multiRenderer.addSeriesRenderer(expenseRenderer);
multiRenderer.addSeriesRenderer(expenseRenderer1);
// Creating an intent to plot bar chart using dataset and
// multipleRenderer
Intent intent = ChartFactory.getBarChartIntent(getBaseContext(),
dataset, multiRenderer, Type.DEFAULT);
// Start Activity
startActivity(intent);
通过使用上面的代码我得到的图形如下图所示
现在我想要的是,正如你可以看到一个黑色圆圈在那里,正好在250的值之下,仅在那个特定的部分上,我只想改变那个特定列的颜色,任何人都可以告诉我如何做到了吗?
由于