Search code examples
achartengine

AchartEngine when zooming in linechart lines disappear


I am using AchartEngine to draw graph with multiple lines (linechart). When zooming in, lines between points disappear and only points stay visible. Did anyone had such problem ?

enter image description here

enter image description here

Code is nothing special.

XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset(); XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();

    XYSeries IVseries=new XYValueSeries("IV");
    XYSeries IV_stc_series=new XYValueSeries("IVstc");


    for(double i=0;i<6;i=i+0.1){
        IVseries.add(sin(i),cos(i));
        IV_stc_series.add(2*sin(i),cos(i));
    }

    mDataset.addSeries(IVseries);
    mDataset.addSeries(IV_stc_series);

    XYSeriesRenderer IVrenderer = new XYSeriesRenderer ();
    IVrenderer.setFillPoints(true);
    IVrenderer.setPointStyle(PointStyle.TRIANGLE);
    IVrenderer.setLineWidth(5);
    IVrenderer.setColor(Color.GREEN);
    mRenderer.addSeriesRenderer(IVrenderer);

    XYSeriesRenderer IV_stc_renderer = new XYSeriesRenderer ();
    IV_stc_renderer.setFillPoints(true);
    IV_stc_renderer.setPointStyle(PointStyle.X);
    IV_stc_renderer.setLineWidth(5);
    IV_stc_renderer.setColor(Color.RED);
    mRenderer.addSeriesRenderer(IV_stc_renderer);

    mRenderer.setPanEnabled(true,true);
    mRenderer.setZoomEnabled(true, true);
    mRenderer.setZoomButtonsVisible(true);
    mRenderer.setXLabels(20);
    mRenderer.setYLabels(20);
    mRenderer.setShowGrid(true);
    mRenderer.setGridColor(Color.BLACK);
    mRenderer.setApplyBackgroundColor(true);
    mRenderer.setBackgroundColor(Color.WHITE);

    mChartView = ChartFactory.getLineChartView(context, mDataset, mRenderer);
    layout.addView(mChartView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

Solution

  • Eventually i resolved this by disabling hardware acceleration in AndroidManifest.xml

    android:hardwareAccelerated="false"

    This way lines are always rendered no mater how much i zoom in.