私のコードでは、Y2 は年のリストで、a2 は値を含む String の arrayList です。年に対応する値を棒グラフで表示する必要があります。どこが間違っているのかわかりません。助けてください、これが私のコードです
if(yearSpinner.equals("All")){
titles = new String[] { "Amount","sasa"};
values = new ArrayList<double[]>();
Double[] doubleLat = new Double[a2.size()];
for(int i = 0; i < a2.size(); i++)
{
doubleLat[i] = a2.get(i);
System.out.println("doubleee=="+doubleLat[i]);
values.add(new double[] { doubleLat[i]});
System.out.println("val=="+values);
}
int[] colors = new int[] { Color.parseColor("#77c4d3")};
renderer = buildBarRenderer(colors);
renderer.setOrientation(Orientation.HORIZONTAL);
setChartSettings(renderer, "Yearly Details", "Year", "Earnings", 0.5,
12.5, 0, yaxis, Color.BLACK, Color.BLACK);
renderer.setXLabels(1);
renderer.setYLabels(10);
for(int i =0;i<y2.size();i++){
renderer.addXTextLabel(i+1, y2.get(i));
}
//renderer.addXTextLabel(1, "yearly");
int length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
SimpleSeriesRenderer seriesRenderer = renderer.getSeriesRendererAt(i);
seriesRenderer.setDisplayChartValues(true);
}
}
final GraphicalView grfv = ChartFactory.getBarChartView(getActivity(), buildBarDataset(titles, values), renderer,Type.DEFAULT);
return grfv;
}
protected XYMultipleSeriesRenderer buildBarRenderer(int[] colors) {
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(16);
renderer.setChartTitleTextSize(20);
renderer.setLabelsTextSize(15);
renderer.setLegendTextSize(15);
renderer.setBarWidth(30);
renderer.setPanEnabled(false, false);
renderer.setMarginsColor(Color.parseColor("#EEEDED"));
renderer.setXLabelsColor(Color.BLACK);
renderer.setYLabelsColor(0,Color.BLACK);
renderer.setApplyBackgroundColor(true);
renderer.setBackgroundColor(Color.parseColor("#FBFBFC"));
int length = a2.size();
for (int i = 0; i < length; i++) {
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(Color.parseColor("#77c4d3"));
//r.setChartvalueAngle(-90);
r.setChartValuesSpacing(15);
renderer.addSeriesRenderer(r);
}
return renderer;
}
protected XYMultipleSeriesDataset buildBarDataset(String[] titles, List<double[]> values) {
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
int length = values.size();
for (int i = 0; i < length; i++) {
CategorySeries series = new CategorySeries("Amoount");
double[] v = values.get(i);
System.out.println("values = ="+values);
System.out.println("v = ="+v);
int seriesLength = v.length;
for (int k = 0; k < seriesLength; k++) {
series.add(v[k]);
System.out.println("v [k]= ="+v[k]);
}
dataset.addSeries(series.toXYSeries());
}
return dataset;
}
protected void setChartSettings(XYMultipleSeriesRenderer renderer, String title, String xTitle,
String yTitle, double xMin, double xMax, double yMin, double yMax, int axesColor,
int labelsColor) {
renderer.setChartTitle(title);
renderer.setYLabelsAlign(Align.RIGHT);
renderer.setXTitle(xTitle);
renderer.setYTitle(yTitle);
renderer.setXAxisMin(xMin);
renderer.setXAxisMax(xMax);
renderer.setYAxisMin(yMin);
renderer.setYAxisMax(yMax);
renderer.setMargins(new int[] { 10, 65, 10, 15 });
renderer.setAxesColor(axesColor);
renderer.setLabelsColor(labelsColor);
}
助けてくれてありがとう