yunjianwu / achartengine

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

Barchart - Bars does not display at correct positions #312

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. BarChart
2.
3.

What is the expected output? What do you see instead?

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

    xAxisBarDisplayBottomValues = new String[] { "Jan", "Feb", "Mar", "Apr"};
        xAxisTempPositions = new int[]{ 0, 1, 2, 3};
        barValues = new int[]{ 20, 60, 27, 90};

public XYMultipleSeriesRenderer getBarChartRenderer() {

        XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();
        multiRenderer.setBarWidth(30);
        multiRenderer.setXLabels(0);
        multiRenderer.setInScroll(true);
        multiRenderer.setShowAxes(true);
        multiRenderer.setApplyBackgroundColor(true);
        multiRenderer.setBackgroundColor(Color.WHITE);
        multiRenderer.setMarginsColor(Color.WHITE);
        multiRenderer.setChartTitle("Income vs Expense Chart");
        multiRenderer.setYTitle("% to Total Listings");
        multiRenderer.setZoomButtonsVisible(false);
        multiRenderer.setXLabelsColor(Color.BLACK);
        multiRenderer.setYLabelsColor(0, Color.BLACK);
        multiRenderer.setAxesColor(Color.parseColor("#949494"));
        multiRenderer.setLabelsColor(Color.BLACK);
        multiRenderer.setShowGrid(true);
        multiRenderer.setYAxisMin(0);
        multiRenderer.setYAxisMax(100);
        multiRenderer.setXAxisMin(-0.5);
        multiRenderer.setXAxisMax(3.5);
        multiRenderer.setBarSpacing(0.2);
        multiRenderer.setFitLegend(true);
        multiRenderer.setShowLegend(false);
        multiRenderer.setZoomEnabled(true, false);
        multiRenderer.setPanEnabled(true, false);
        multiRenderer.setYLabelsAlign(Align.RIGHT);
        multiRenderer.setMargins(new int[] { 45, 45, 45, 45 });

        XYSeriesRenderer incomeRenderer = new XYSeriesRenderer();
        incomeRenderer.setColor(Color.BLACK);
        // to give the gradient color to the bars.
        incomeRenderer.setFillPoints(true);
        incomeRenderer.setLineWidth(2);
        incomeRenderer.setGradientEnabled(true);
        incomeRenderer.setGradientStart(0, Color.parseColor("#de3709"));
        incomeRenderer.setGradientStop(100, Color.parseColor("#b7d91e"));
        incomeRenderer.setDisplayChartValues(true);
        multiRenderer.addXTextLabel(0, xAxisBarDisplayBottomValues[0]);
        multiRenderer.addSeriesRenderer(incomeRenderer);

        incomeRenderer = new XYSeriesRenderer();
        incomeRenderer.setColor(Color.BLACK);
        // to give the gradient color to the bars.
        incomeRenderer.setFillPoints(true);
        incomeRenderer.setLineWidth(2);
        incomeRenderer.setGradientEnabled(true);
        incomeRenderer.setGradientStart(0, Color.parseColor("#FFFFFF"));
        incomeRenderer.setGradientStop(100, Color.parseColor("#000000"));
        incomeRenderer.setDisplayChartValues(true);
        multiRenderer.addXTextLabel(1, xAxisBarDisplayBottomValues[1]);
        multiRenderer.addSeriesRenderer(incomeRenderer);

        incomeRenderer = new XYSeriesRenderer();
        incomeRenderer.setColor(Color.BLACK);
        // to give the gradient color to the bars.
        incomeRenderer.setFillPoints(true);
        incomeRenderer.setLineWidth(2);
        incomeRenderer.setGradientEnabled(true);
        incomeRenderer.setGradientStart(0, Color.parseColor("#c9c9c9"));
        incomeRenderer.setGradientStop(100, Color.parseColor("#000000"));
        incomeRenderer.setDisplayChartValues(true);
        multiRenderer.addXTextLabel(2, xAxisBarDisplayBottomValues[2]);
        multiRenderer.addSeriesRenderer(incomeRenderer);

        incomeRenderer = new XYSeriesRenderer();
        incomeRenderer.setColor(Color.BLACK);
        // to give the gradient color to the bars.
        incomeRenderer.setFillPoints(true);
        incomeRenderer.setLineWidth(2);
        incomeRenderer.setGradientEnabled(true);
        incomeRenderer.setGradientStart(0, Color.parseColor("#de3709"));
        incomeRenderer.setGradientStop(100, Color.parseColor("#000000"));
        incomeRenderer.setDisplayChartValues(true);
        multiRenderer.addXTextLabel(3, xAxisBarDisplayBottomValues[3]);
        multiRenderer.addSeriesRenderer(incomeRenderer);
        return multiRenderer;
    }

    private XYMultipleSeriesDataset getBarDemoDataset() {
        // Creating a dataset to hold each series
        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

        XYSeries incomeSeries1 = new XYSeries("Income1");
        incomeSeries1.add(xAxisTempPositions[0], barValues[0]);
        dataset.addSeries(incomeSeries1);

        XYSeries incomeSeries2 = new XYSeries("Income2");
        incomeSeries2.add(xAxisTempPositions[1], barValues[1]);
        dataset.addSeries(incomeSeries2);

        XYSeries incomeSeries3 = new XYSeries("Income3");
        incomeSeries3.add(xAxisTempPositions[2], barValues[2]);
        dataset.addSeries(incomeSeries3);

        XYSeries incomeSeries4 = new XYSeries("Income4");
        incomeSeries4.add(xAxisTempPositions[3], barValues[3]);
        dataset.addSeries(incomeSeries4);

        return dataset;
    }

What version of the product binary library are you using?

Please provide any additional information below.

Original issue reported on code.google.com by vedavyas...@gmail.com on 5 Jun 2013 at 8:01

GoogleCodeExporter commented 9 years ago
An explanation, a screenshot?

Original comment by dandrome...@gmail.com on 31 Oct 2013 at 8:01

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 1 Nov 2013 at 8:15