Skip to content

Commit

Permalink
Fix #712: linetype=0 make line invisible by setting `stroke-dasharray…
Browse files Browse the repository at this point in the history
…="0 1"`.
  • Loading branch information
OLarionova-HORIS committed Jun 18, 2024
1 parent 7c31f27 commit 9e2f8bc
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
3 changes: 2 additions & 1 deletion future_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
- [**breaking change**] guide_legend()/guide_colorbar() require keyword arguments for 'nrow'/'barwidth' other parameters except 'title'.

### Fixed
- geom_density2d: support weight aesthetic [[#791](https://github.com/JetBrains/lets-plot/issues/791)].
- geom_density2d: support weight aesthetic [[#791](https://github.com/JetBrains/lets-plot/issues/791)].
- `linetype` = 0 ('blank') should make lines invisible [[#712](https://github.com/JetBrains/lets-plot/issues/712)].
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ package org.jetbrains.letsPlot.core.plot.base.render.linetype
interface LineType {
val isSolid: Boolean

val isBlank: Boolean

val dashArray: List<Double>
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ package org.jetbrains.letsPlot.core.plot.base.render.linetype
enum class NamedLineType(val code: Int, private val myDashArray: List<Double>?) :
LineType {
// 0 = blank, 1 = solid, 2 = dashed, 3 = dotted, 4 = dotdash, 5 = longdash, 6 = twodash
BLANK(0, null) {
override val isBlank: Boolean
get() = true
},
BLANK(0, listOf(0.0, 1.0)),
SOLID(1, null) {
override val isSolid: Boolean
get() = true
Expand All @@ -28,12 +25,9 @@ enum class NamedLineType(val code: Int, private val myDashArray: List<Double>?)
override val isSolid: Boolean
get() = false

override val isBlank: Boolean
get() = false

override val dashArray: List<Double>
get() {
if (!(isSolid || isBlank)) {
if (!isSolid) {
return myDashArray!!
}
throw IllegalStateException("No dash array in " + name.lowercase() + " linetype")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object StrokeDashArraySupport {
}

private fun toStrokeDashArray(strokeWidth: Double, lineType: LineType): String? {
if (lineType.isBlank || lineType.isSolid) {
if (lineType.isSolid) {
return null
}
val sb = StringBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal class DataPointLiveMapAesthetics {
get() {
val lineType = myP.lineType()

if (lineType.isSolid || lineType.isBlank) {
if (lineType.isSolid) {
return emptyList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ class PathConverterTest {
}

@Test
fun blankLineShouldNotHaveDashPattern() {
fun blankLineHasDashPattern() {
aesData!!.builder().lineType(constant(NamedLineType.BLANK))

matcher!!.lineDash(vectorEq(emptyList()))
matcher!!
.strokeWidth(eq(1.1))
.lineDash(vectorEq(listOf(0.0, 1.1)))

assertMapObject()
}
Expand Down

0 comments on commit 9e2f8bc

Please sign in to comment.