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

CategoryChart exception when series are of different length #635

Open
atorstling-mojang opened this issue Oct 27, 2021 · 0 comments
Open

Comments

@atorstling-mojang
Copy link

Hello! Consider the following code:

public static void main(final String[] args) {
    final CategoryChart categoryChart = new CategoryChartBuilder().width(400).height(400).build();
    categoryChart.addSeries("one", new double[]{0.0}, new double[]{0.0});
    categoryChart.addSeries("two", new double[]{0.0, 1.0}, new double[]{0.0, 1.0});

    final JFrame frame = new JFrame();
    frame.add(new XChartPanel<>(categoryChart));
    frame.pack();
    frame.setVisible(true);
}

This produces the following stacktrace:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at org.knowm.xchart.internal.chartpart.PlotContent_Category_Bar.doPaint(PlotContent_Category_Bar.java:267)
	at org.knowm.xchart.internal.chartpart.PlotContent_.paint(PlotContent_.java:55)
	at org.knowm.xchart.internal.chartpart.Plot_.paint(Plot_.java:37)
	at org.knowm.xchart.internal.chartpart.Plot_AxesChart.paint(Plot_AxesChart.java:35)
	at org.knowm.xchart.internal.chartpart.Plot_Category.paint(Plot_Category.java:37)
	at org.knowm.xchart.CategoryChart.paint(CategoryChart.java:309)
	at org.knowm.xchart.XChartPanel.paintComponent(XChartPanel.java:132)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1074)

Is this expected? I'm surprised that the plotter seems to assume that the series have an equal amount of samples.

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