XChart
XChart copied to clipboard
CategoryChart exception when series are of different length
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.