BoxChart rejects valid List.of data with NullPointerException
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- data-visualization
Research direction
Start by reading the validation paths used by BoxChart.addSeries, series.replaceData, and chart.updateBoxSeries; the issue identifies all three entry points. Add or update tests for two- and three-element List.of inputs, replacement/update, and lists containing null. Done means null-free immutable lists are accepted and lists with null elements remain rejected.
Written by the indexing model from the issue text.
Description
Describe the bug
BoxChart rejects valid, null-free lists created with List.of(...). Both adding a series and replacing its data throw NullPointerException because the validation calls contains(null), which these lists do not support.
To Reproduce
import java.util.List;
import org.knowm.xchart.BoxChart;
import org.knowm.xchart.BoxChartBuilder;
import org.knowm.xchart.SwingWrapper;
public class ImmutableBoxData {
public static void main(String[] args) {
new SwingWrapper<>(getChart()).displayChart();
}
public static BoxChart getChart() {
BoxChart chart = new BoxChartBuilder().width(640).height(480).build();
chart.addSeries("sample", List.of(1, 2, 3)); // NullPointerException
return chart;
}
}
The same exception occurs when calling series.replaceData(List.of(4, 5)) or chart.updateBoxSeries(...) on an existing series.
Expected behavior
Accept the null-free lists while continuing to reject lists that actually contain null elements.
Reproduced on 4.0.5-SNAPSHOT, Java 11. The exception happens before rendering, so no screenshot is needed. Tests cover two- and three-element immutable lists, replacement/update, and rejection of actual null elements.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 398
- PR merge metrics
- No merged PRs in 30d
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
-
X-Axis Line not visiblePossibly taken @timmolter claimed this 58 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
OHLC: first and last candles are clipped at the plot edgesPossibly taken @timmolter claimed this 45 days ago. OpenAesthetics
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
`CategoryChart.addSeries` could support additional call signature for interoperability with ScalaOpen
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
AnnotationsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
helidon-io/helidon#12721 ·
Maintainers usually reply within 1 day
-
status: team-only type: dependency-upgrade
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
spring-projects/spring-boot#51966 ·
Maintainers usually reply within 1 day
-
Missing repro Platform: Android
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
software-mansion/react-native-reanimated#10816 · 2 comments ·
Maintainers usually reply within 1 day
-
area/docs backport/26.6 backport/26.8 kind/bug status/triage
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
[destination-snowflake] Custom domains rejected unlike source connectionsPossibly taken @kuza55 claimed this today. Openautoteam community connectors/destination/snowflake team/use
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day