在AChartEngine的辅助Y轴上绘制多个图形

时间:2014-02-21 09:41:52

标签: android graph achartengine

我正在使用AChartEngine绘制多个Y轴图形图,事情是我在主Y轴上绘制了五条图线,但是当在二级y轴上绘制五条图形线时,它只显示一条,这是最后一条在这里绘制的是我的代码,任何帮助都会感激不尽

关于辅助Y轴的代码

XYMultipleSeriesDataset dataset = buildDataset(titles, x, values);
    values.clear();
    values.add(new double[]  { mWeightFirstList.get(0),
            mWeightFirstList.get(1), mWeightFirstList.get(2),
            mWeightFirstList.get(3), mWeightFirstList.get(4),
            mWeightFirstList.get(5), mWeightFirstList.get(6),
            mWeightFirstList.get(7), mWeightFirstList.get(8),
            mWeightFirstList.get(9), mWeightFirstList.get(10),
            mWeightFirstList.get(11), mWeightFirstList.get(12) });
    addXYSeries(dataset, new String[] { "97%" }, x, values, 1);
    values.add(new double[]  { mWeightSecondList.get(0),
            mWeightSecondList.get(1), mWeightSecondList.get(2),
            mWeightSecondList.get(3), mWeightSecondList.get(4),
            mWeightSecondList.get(5), mWeightSecondList.get(6),
            mWeightSecondList.get(7), mWeightSecondList.get(8),
            mWeightSecondList.get(9), mWeightSecondList.get(10),
            mWeightSecondList.get(11), mWeightSecondList.get(12) });
    addXYSeries(dataset, new String[] { "75%" }, x, values, 2);
    values.add(new double[]  { mWeightThirdList.get(0),
            mWeightThirdList.get(1), mWeightThirdList.get(2),
            mWeightThirdList.get(3), mWeightThirdList.get(4),
            mWeightThirdList.get(5), mWeightThirdList.get(6),
            mWeightThirdList.get(7), mWeightThirdList.get(8),
            mWeightThirdList.get(9), mWeightThirdList.get(10),
            mWeightThirdList.get(11), mWeightThirdList.get(12) });
    addXYSeries(dataset, new String[] { "50%" }, x, values, 3);
    values.add(new double[]  { mWeightFourthList.get(0),
            mWeightFourthList.get(1), mWeightFourthList.get(2),
            mWeightFourthList.get(3), mWeightFourthList.get(4),
            mWeightFourthList.get(5), mWeightFourthList.get(6),
            mWeightFourthList.get(7), mWeightFourthList.get(8),
            mWeightFourthList.get(9), mWeightFourthList.get(10),
            mWeightFourthList.get(11), mWeightFourthList.get(12) });
    addXYSeries(dataset, new String[] { "25%" }, x, values, 4);
    values.add(new double[]  { mWeightFifthList.get(0),
            mWeightFifthList.get(1), mWeightFifthList.get(2),
            mWeightFifthList.get(3), mWeightFifthList.get(4),
            mWeightFifthList.get(5), mWeightFifthList.get(6),
            mWeightFifthList.get(7), mWeightFifthList.get(8),
            mWeightFifthList.get(9), mWeightFifthList.get(10),
            mWeightFifthList.get(11), mWeightFifthList.get(12) });
    addXYSeries(dataset, new String[] { "35%" }, x, values, 5);
    GraphicalView mView = ChartFactory.getCubeLineChartView(context,
            dataset, renderer, 0.3f);
    return mView;

1 个答案:

答案 0 :(得分:1)

尝试使用以下代码

XYMultipleSeriesDataset dataset = buildDataset(titles, x, values);
    values.clear();
    List<double[]> values1 = new ArrayList<double[]>();
    List<double[]> values2 = new ArrayList<double[]>();
    List<double[]> values3 = new ArrayList<double[]>();
    List<double[]> values4 = new ArrayList<double[]>();
    List<double[]> values5 = new ArrayList<double[]>();
    values1.add(new double[]  { mWeightFirstList.get(0),
            mWeightFirstList.get(1), mWeightFirstList.get(2),
            mWeightFirstList.get(3), mWeightFirstList.get(4),
            mWeightFirstList.get(5), mWeightFirstList.get(6),
            mWeightFirstList.get(7), mWeightFirstList.get(8),
            mWeightFirstList.get(9), mWeightFirstList.get(10),
            mWeightFirstList.get(11), mWeightFirstList.get(12) });
    addXYSeries(dataset, new String[] { "97%" }, x, values1, 1);
    values2.add(new double[]  { mWeightSecondList.get(0),
            mWeightSecondList.get(1), mWeightSecondList.get(2),
            mWeightSecondList.get(3), mWeightSecondList.get(4),
            mWeightSecondList.get(5), mWeightSecondList.get(6),
            mWeightSecondList.get(7), mWeightSecondList.get(8),
            mWeightSecondList.get(9), mWeightSecondList.get(10),
            mWeightSecondList.get(11), mWeightSecondList.get(12) });
    addXYSeries(dataset, new String[] { "75%" }, x, values2, 1);
    values3.add(new double[]  { mWeightThirdList.get(0),
            mWeightThirdList.get(1), mWeightThirdList.get(2),
            mWeightThirdList.get(3), mWeightThirdList.get(4),
            mWeightThirdList.get(5), mWeightThirdList.get(6),
            mWeightThirdList.get(7), mWeightThirdList.get(8),
            mWeightThirdList.get(9), mWeightThirdList.get(10),
            mWeightThirdList.get(11), mWeightThirdList.get(12) });
    addXYSeries(dataset, new String[] { "50%" }, x, values3, 1);
    values4.add(new double[]  { mWeightFourthList.get(0),
            mWeightFourthList.get(1), mWeightFourthList.get(2),
            mWeightFourthList.get(3), mWeightFourthList.get(4),
            mWeightFourthList.get(5), mWeightFourthList.get(6),
            mWeightFourthList.get(7), mWeightFourthList.get(8),
            mWeightFourthList.get(9), mWeightFourthList.get(10),
            mWeightFourthList.get(11), mWeightFourthList.get(12) });
    addXYSeries(dataset, new String[] { "25%" }, x, values4, 1);
    values5.add(new double[]  { mWeightFifthList.get(0),
            mWeightFifthList.get(1), mWeightFifthList.get(2),
            mWeightFifthList.get(3), mWeightFifthList.get(4),
            mWeightFifthList.get(5), mWeightFifthList.get(6),
            mWeightFifthList.get(7), mWeightFifthList.get(8),
            mWeightFifthList.get(9), mWeightFifthList.get(10),
            mWeightFifthList.get(11), mWeightFifthList.get(12) });
    addXYSeries(dataset, new String[] { "3% (Weight)" }, x, values5, 1);
    GraphicalView mView = ChartFactory.getCubeLineChartView(context,
            dataset, renderer, 0.3f);
    return mView;