yunjianwu / achartengine

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

why need to display chart value even it is 0...can provide a api to prevent it. #159

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. construct a barchart with two double values list contains negative and 
positive values..such as {0, 12.5, 5, 16} ,{0,-13,0,-2}
2. using getSeriesRendererAt(0),getSeriesRendererAt(1) to set Display Chart 
Values to true..
3. run the chart,the chart value will show like this 0,0 ;  12.5,-13;  5,0; 
16,-2;

What is the expected output? What do you see instead?
What i expected output is just show nonzero value.. in previous example,it 
should just show 12.5,-13; 5; 16,-2;

Please provide a source code snippet that we can use to replicate the issue.

String[] titles = new String[] { "positive", "negative" };
        List<double[]> values = new ArrayList<double[]>();
        values.add(new double[] { 0, 120, 0, 80, 30, 150, 420, 300, 160, 120,
                100, 35, 145, 650, 0, 0, 260, 0, 0, 200, 0, 332, 0, 139.73, 0,
                200, 600, 0, 288, 580, 600 });
        values.add(new double[] { -230, 0, -100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, -420, 0, 0, -40, 0, 0, 0, 0, -150, -200, 0, 0, 0, -332, 0,
                0, 0 });

        int[] colors = new int[] { Color.BLUE, Color.CYAN };
        XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
        setChartSettings(renderer, "", "", "", 0, 10.5, -500, 700, Color.GRAY, Color.LTGRAY);

        renderer.setBarSpacing(0.3);//set the bar size

        renderer.setXLabels(0);//Sets the approximate number of labels for the X axis.
        renderer.setYLabels(4);//the approximate number of labels for the Y axis.

        renderer.addXTextLabel(1, "");
        renderer.addXTextLabel(2, "2nd");
        renderer.addXTextLabel(3, "");
        renderer.addXTextLabel(4, "4th");
        renderer.addXTextLabel(5, "");
        renderer.addXTextLabel(6, "6th");
        renderer.addXTextLabel(7, "");
        renderer.addXTextLabel(8, "8th");
        renderer.addXTextLabel(9, "");
        renderer.addXTextLabel(10, "10th");
        renderer.addXTextLabel(11, "");
        renderer.addXTextLabel(12, "12th");
        renderer.addXTextLabel(13, "");
        renderer.addXTextLabel(14, "14th");
        renderer.addXTextLabel(15, "");
        renderer.addXTextLabel(16, "16th");
        renderer.addXTextLabel(17, "");
        renderer.addXTextLabel(18, "18th");
        renderer.addXTextLabel(19, "");
        renderer.addXTextLabel(20, "20th");
        renderer.addXTextLabel(21, "");
        renderer.addXTextLabel(22, "22nd");
        renderer.addXTextLabel(23, "");
        renderer.addXTextLabel(24, "24th");
        renderer.addXTextLabel(25, "");
        renderer.addXTextLabel(26, "26th");
        renderer.addXTextLabel(27, "");
        renderer.addXTextLabel(28, "28th");
        renderer.addXTextLabel(29, "");
        renderer.addXTextLabel(30, "30th");
        renderer.addXTextLabel(31, "");

        renderer.addYTextLabel(-1000, "-1000");
        renderer.addYTextLabel(-500, "-500");
        renderer.addYTextLabel(0, "0");
        renderer.addYTextLabel(500, "500");
        renderer.addYTextLabel(1000, "1000");
        renderer.setMargins(new int[] {0, 50, 0, 0});//margins - an array containing the margin size values, in this order: top, left, bottom, right
        renderer.setYLabelsAlign(Align.RIGHT);
        renderer.setPanEnabled(true, false);//just can slide the x axis,the y axis can not slide

        renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
        renderer.getSeriesRendererAt(0).setChartValuesTextSize(12);
        renderer.getSeriesRendererAt(0).setGradientEnabled(true);
        renderer.getSeriesRendererAt(0).setGradientStart(0, Color.CYAN);
        renderer.getSeriesRendererAt(0).setGradientStop(500, Color.BLUE);

        renderer.getSeriesRendererAt(1).setDisplayChartValues(true);
        renderer.getSeriesRendererAt(1).setChartValuesTextSize(12);
        renderer.getSeriesRendererAt(1).setGradientEnabled(true);
        renderer.getSeriesRendererAt(1).setGradientStart(-500, Color.CYAN);
        renderer.getSeriesRendererAt(1).setGradientStop(0, Color.MAGENTA);

        // renderer.setZoomEnabled(false);
        renderer.setZoomRate(1.1f);
        return ChartFactory.getBarChartIntent(context,
                buildBarDataset(titles, values), renderer, Type.STACKED);

What version of the product binary library are you using?
I'm using the AChartEngine 0.7.0 binary build library. 

Original issue reported on code.google.com by luzhen0...@gmail.com on 20 Dec 2011 at 2:53

GoogleCodeExporter commented 9 years ago
jesus christ, can treat 0 as MathHelper.NULL_VALUE...then will not show 0 chart 
value.

Original comment by luzhen0...@gmail.com on 20 Dec 2011 at 5:48

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 4 Jan 2012 at 9:19