Skip to content

Wrong bars placement when ticks are hidden #111

@paolieri

Description

@paolieri

When some ticks are hidden (e.g., only 2, 4, 6, 8, 12 x-ticks are shown), bars are not placed at the correct x-position.

For example, this code:

public class XChartBug {
    public static void main(String[] args) {
        int[] x = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
        int[] y = new int[] {1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0};

        Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(640).height(480).build();
        chart.addSeries("test", x, y);
        chart.getStyleManager().setLegendVisible(false);
        new SwingWrapper(chart).displayChart();
    }
}

produces the plot:

image

By dropping the last bar, all x-ticks are shown, and the placement of bars is correct:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions