Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart zoomin is not working correctly for Y axis if ticks are set manually. #563

Open
rabbi7 opened this issue Jan 17, 2019 · 0 comments
Open

Comments

@rabbi7
Copy link

rabbi7 commented Jan 17, 2019

Chart zooming doesn't work correct for Y axis if the ticks are set with setTickPositions function.
There is a small example with two charts. The first one the ticks are set with setTickInterval and setMin, setMaxFunction and everything is working correctly. On the second one the ticks are set via setTickPositions function. And zooming on y axis doesn't work correct.

public MainView() {
        Chart chart1 = new Chart();
        Configuration configuration1 = chart1.getConfiguration();
        configuration1.getChart().setType(ChartType.LINE);
        configuration1.getTitle()
                .setText("Ticks on Axes are set with setTickInterval");
        configuration1.getChart().setZoomType(Dimension.XY);

        configuration1.getxAxis().setTickInterval(1);
        configuration1.getxAxis().setMin(0);
        configuration1.getxAxis().setMax(5);
        configuration1.getyAxis().setTickInterval(1);
        configuration1.getyAxis().setMin(0);
        configuration1.getyAxis().setMax(5);

        DataSeries ds1 = new DataSeries();
        ds1.add(new DataSeriesItem(1, 1));
        ds1.add(new DataSeriesItem(2, 2));
        ds1.add(new DataSeriesItem(3, 2));
        ds1.add(new DataSeriesItem(4, 1));
        configuration1.addSeries(ds1);

        Chart chart2 = new Chart();
        Configuration configuration2 = chart2.getConfiguration();
        configuration2.getChart().setType(ChartType.LINE);
        configuration2.getTitle()
                .setText("Ticks on Axes are set with setTickPosition");
        configuration2.getChart().setZoomType(Dimension.XY);

        configuration2.getxAxis().setTickPositions(new Double [] {0.0, 1.00, 2.0, 3.0, 4.0, 5.0});
        configuration2.getxAxis().setMin(0);
        configuration2.getxAxis().setMax(5);


        configuration2.getyAxis().setTitle(new AxisTitle("Y"));
        configuration2.getyAxis().setTickPositions(new Double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0});

        DataSeries ds2 = new DataSeries();
        ds2.add(new DataSeriesItem(1, 1));
        ds2.add(new DataSeriesItem(2, 2));
        ds2.add(new DataSeriesItem(3, 2));
        ds2.add(new DataSeriesItem(4, 1));
        configuration2.addSeries(ds2);

        VerticalLayout charts = new VerticalLayout();
        charts.add(chart1);
        charts.add(chart2);
        add(charts);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant