CategoryChart exception when series are of different length
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java
- Domain
- data-visualization, desktop
Research direction
Start with the reproducible CategoryChart example and inspect org.knowm.xchart.internal.chartpart.PlotContent_Category_Bar.java at line 267, where the stack trace identifies the failure. Trace how series lengths are handled during painting and verify the example no longer throws when the series contain different numbers of samples.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 400
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 7
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from knowm/XChart
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 4 days
-
Difficulty 3/5 1-2 days Newbie friendliness 57/100
Maintainers usually reply within 4 days
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
Maintainers usually reply within 4 days
-
Cleanup: generate axis ticks in-range instead of pruning after the fact (follow-up to #634)Possibly taken @Sinkleberg claimed this 20 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 4 days
-
`CategoryChart.addSeries` could support additional call signature for interoperability with ScalaPossibly taken @Sinkleberg claimed this 20 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Maintainers usually reply within 4 days
Similar issues
-
documentation good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
eclipse-sw360/sw360#4849 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
bug key bindings
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Android Bug Core Drape
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
organicmaps/organicmaps#14449 ·
Maintainers usually reply within 1 day