Achartengine on android - multiple Y axis

It is not easy to get the multiple Y axis to display on the chart using achartengine on android. I tried to copy what was done in the demo version of “Several temperature charts” here: http://code.google.com/p/achartengine/source/browse/trunk/achartengine/demo/org/achartengine/chartdemo/demo /chart/MultipleTemperatureChart.java , but it will not show the Y axis on the right, and it will not show the shortcuts of the shortcuts I want to show.

Any ideas what my code might do wrong:

    mCurrentCostSeries = new XYSeries(costTitle);
    mCurrentEffSeries = new XYSeries(effTitle);

    mDataset.addSeries(mCurrentCostSeries);
    mDataset.addSeries(mCurrentEffSeries);



    int[] colors = new int[] { Color.RED, Color.YELLOW };
    PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.DIAMOND };
    mRenderer = new XYMultipleSeriesRenderer(2);
    setRenderer(mRenderer, colors, styles);
    int length = mRenderer.getSeriesRendererCount();
    for (int i = 0; i < length; i++) {
      XYSeriesRenderer r = (XYSeriesRenderer) mRenderer.getSeriesRendererAt(i);
      r.setLineWidth(3f);
    }

    mRenderer.setApplyBackgroundColor(true);
    mRenderer.setBackgroundColor(Color.argb(100, 50, 50, 50));

    mRenderer.setAxesColor(Color.LTGRAY);
    mRenderer.setZoomButtonsVisible(true);
    mRenderer.setPointSize(10);

    mRenderer.setChartTitle("Fuel Efficiency and Cost");


    mRenderer.setShowGrid(true);
    mRenderer.setXLabelsAlign(Align.RIGHT);
    mRenderer.setYLabelsAlign(Align.RIGHT);


    mRenderer.setYTitle(cunits,0);

    mRenderer.setLabelsColor(Color.WHITE);
    mRenderer.setXLabelsColor(Color.GREEN);
    mRenderer.setYLabelsColor(0, colors[0]);
    mRenderer.setYLabelsColor(1, colors[1]);



    mRenderer.setYTitle(dunits, 1);        // these lines SHOULD set the second Y axis 
    mRenderer.setYAxisAlign(Align.RIGHT, 1);// (series=1) but have no effect.
    mRenderer.setYLabelsAlign(Align.LEFT, 1);

I use the timeseries chart, not the chart that the demo uses, but otherwise everything should be pretty much the same.

+5
source share
1 answer

, . , mCurrentEffSeries , :

mCurrentEffSeries = new XYSeries(effTitle, 1);
+5

All Articles