leewbo / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

Line chart didn't draw transparent marginsColor correctly #404

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
----------
What steps will reproduce the problem?
1. Set activity background to some color other that black (or a picture).
2. Set chart background color to DefaultRenderer.NO_COLOR. (or keep it intact)
3. Set chart marginsColor to DefaultRenderer.NO_COLOR. (or keep it intact)
4. Create the line chart.

----------
What is the expected output? What do you see instead?
The background of the whole chart was expected to be transparent.
Actural result, however, only line curve zone was transparent, the margins zone 
around axes was paint black, instead of transparent.

----------
Please provide a source code snippet that we can use to replicate the
issue.
        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();

        Random rand = new Random();
        XYSeries currentSeries = new XYSeries("Sample Data");
        currentSeries.add(1, rand.nextInt(500));
        currentSeries.add(2, rand.nextInt(500));
        currentSeries.add(3, rand.nextInt(500));
        currentSeries.add(4, rand.nextInt(500));
        currentSeries.add(5, rand.nextInt(500));
        dataset.addSeries(currentSeries);

        XYSeriesRenderer currentRenderer = new XYSeriesRenderer();
        currentRenderer.setColor(0xFFFF0000);
        currentRenderer.setLineWidth(3);
        currentRenderer.setPointStyle(PointStyle.CIRCLE);
        currentRenderer.setPointStrokeWidth(3);
        currentRenderer.setFillPoints(true);
        renderer.addSeriesRenderer(currentRenderer);
        renderer.setPointSize(8);
        renderer.setXAxisMin(0.5);
        renderer.setXAxisMax(5.5);
        renderer.setYAxisMin(0);
        renderer.setYAxisMax(500);
        renderer.setPanEnabled(true, false);
        renderer.setPanLimits(new double[] {0.5, 5.5, 0, 500});
        renderer.setZoomEnabled(true, false);
        renderer.setZoomInLimitX(2.5);
        renderer.setZoomLimits(new double[] {0.5, 5.5, 0, 500});
        renderer.setAntialiasing(true);
        renderer.setApplyBackgroundColor(true);
        renderer.setBackgroundColor(DefaultRenderer.NO_COLOR);
        renderer.setMarginsColor(DefaultRenderer.NO_COLOR);

        GraphicalView view = ChartFactory.getLineChartView(getContext(), dataset, renderer)

----------
What version of the product binary library are you using?
1.1.0 as well as HEAD(564) revision in svn repository.

----------
Please provide any additional information below.
I have create a patch to solve this issue. Check the attachments.
It doesn't makes any sense to case mRenderer into XYMultipleSeriesRenderer in 
GraphicalView, I think the only thing did here is set marginsColor to black if 
it is DefaultRenderer.NO_COLOR, so I remove it. Since this will cause line 
curve to over draw into axes zone, I add a canvas clipRect in XYChart before 
draw chart series.

Although I check the code and pretty sure this shouldn't cause any trouble to 
other types of chart, please be aware that I only test this in line chart.

Original issue reported on code.google.com by iss....@gmail.com on 8 Apr 2014 at 4:51

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch!
I've had the same issue, and it helped.

Original comment by oleg.skr...@gmail.com on 5 Feb 2015 at 5:29