Kotlin / Kotlin/kandy

[BUG] Providing domain with negative start value causes NPE

Open
#497 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
744
Forks
27
Avg merge
4d 1h
Merged PRs (30d)
1

Description

## **Describe the bug**
I am plotting geoPoints on a geoMap

When I get min and max for the column used to determine the geoPoint size and provide this range as the domain and the min is negative for the scale I experience the following:

```
java.lang.NullPointerException: null
at org.jetbrains.letsPlot.core.plot.base.aes.AesScaling.strokeWidth(AesScaling.kt:18)
at org.jetbrains.letsPlot.core.plot.base.geom.util.LinesHelper$decorate$1.invoke(LinesHelper.kt:228)
at org.jetbrains.letsPlot.core.plot.base.geom.util.LinesHelper.decorate(LinesHelper.kt:241)
at org.jetbrains.letsPlot.core.plot.base.geom.PolygonGeom.buildIntern(PolygonGeom.kt:33)
```

The plot as follows:
```kotlin
plot {
withData(overviewGeoMap) {
geoMap {
fillColor(countryCode) {
legend.name = "Country Code"
alpha = 0.7
scale = categorical("USA" to Color.BLUE, "CAN" to Color.RED,"MEX" to Color.GREEN)
}
borderLine.color = Color.BLACK
borderLine.width = 0.1
}
}
withData(dataGeoPlot) {
geoPoints {
color(focusAreaColourColumn) {
scale = continuous(Color.GREEN..Color.RED, domain = minColourValue..maxColourValue)
}
legend.name = messageSource.getMessageText(locale, focusAreaColourColumn.name())
size(focusAreaSizeColumn) {
scale = continuous(range = 3.0..12.0, domain = minSizeValue..maxSizeValue)
legend.name = messageSource.getMessageText(locale, focusAreaSizeColumn.name())
}
}
}
withData(level1Names) {
text {
label(level1Name)
alpha = 1.0
x(centerX)
y(centerY)
font.color = Color.BLACK
font.size = 6.0
font.family = FontFamily.SANS
}
}
}
```
When I remove the `domain =` to the `continuous()` scale the NPE doesn't occur.

Contributor guide

Open the contributing guide

Research direction

Start with the stack-trace entry point in plot/base/aes/AesScaling.kt, then trace the call through LinesHelper.kt and PolygonGeom.kt. Reproduce the geoPoints example with a continuous scale whose domain has a negative minimum, and compare it with the case where domain is omitted. Done means the negative-domain plot no longer raises the reported NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.