Spline curves using achartengine with cubic line chart doesnt pass through all points

1.3k views Asked by At

I am using achartengine with cubic line chart, but it doesnt seem to work. The cubic line chart doesnt pass through all the points in the series. In this example, the graph is far away from the points. What am I doing wrong, or is this an actual issue with achartengine?

cubiclinechart

Code:

    XYMultipleSeriesDataset series = new XYMultipleSeriesDataset();

    XYValueSeries newTicketSeries = new XYValueSeries("New Tickets");
    newTicketSeries.add(1, 14);
    newTicketSeries.add( 2, 12);
    newTicketSeries.add(3, 18);
    newTicketSeries.add( 4, 5);
    newTicketSeries.add( 5, 10);
    series.addSeries(newTicketSeries);
    XYValueSeries fixedTicketSeries = new XYValueSeries("Fixed Tickets");
    fixedTicketSeries.add( 1, 15);
    fixedTicketSeries.add( 2, 5);
    fixedTicketSeries.add( 3, 15);
    fixedTicketSeries.add(4, 5);
    fixedTicketSeries.add(5, 15);
    series.addSeries(fixedTicketSeries);

    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();

    renderer.setAxisTitleTextSize(56);
    renderer.setChartTitleTextSize(50);
    renderer.setLabelsTextSize(55);
    renderer.setZoomEnabled(true, false);
    renderer.setPanEnabled(false, false);

    renderer.setRange(new double[]{0, 10, 0, 20});

    //renderer.setMargins(new int[] { 20, 30, 15, 0 });
    XYSeriesRenderer newTicketRenderer = new XYSeriesRenderer();
    newTicketRenderer.setColor(Color.argb(250, 0, 210, 250));
    renderer.addSeriesRenderer(newTicketRenderer);
    XYSeriesRenderer fixedTicketRenderer = new XYSeriesRenderer();
    fixedTicketRenderer.setColor(Color.RED);
    fixedTicketRenderer.setLineWidth(10);

    fixedTicketRenderer.setPointStyle(PointStyle.CIRCLE);

    fixedTicketRenderer.setFillPoints(true);
    renderer.addSeriesRenderer(fixedTicketRenderer);

    renderer.setPointSize(40);
    renderer.setXLabels(0);
    renderer.setYLabels(0);
    newTicketRenderer.setDisplayChartValues(true);
    newTicketRenderer.setChartValuesTextSize(30);
    renderer.setShowGrid(false);
    renderer.setShowLegend(true);
    renderer.setShowLabels(false);
    renderer.setBarSpacing(0.5);
    renderer.setBackgroundColor(Color.TRANSPARENT);
    renderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01)); 

    //renderer.setZoomEnabled(false, false);

    GraphicalView chartView;



    String[] types = new String[] { BarChart.TYPE, CubicLineChart.TYPE};

    chartView = ChartFactory.getCombinedXYChartView(getActivity(), series, renderer, types);
1

There are 1 answers

3
Dan D. On BEST ANSWER

This was a bug, indeed. I checked in a fix in the SVN. You can download a version including this fix here.