Joe Boudreau
10/27/2024, 7:48 PMvLine
in a Kandy plot if the x axis isn't a number? I'm trying to plot something with Dates on the x axis and I want to place a vertical line on a specific date value. The plot always fails with exception java.lang.IllegalArgumentException: Figure spec kind is not defined.
Here is a example to illustrate the problem:
dataFrameOf(
"foo" to listOf("a", "b", "c"),
"bar" to listOf(1, 2, 3)
)
.plot {
line {
x("foo")
y("bar")
}
vLine {
xIntercept.constant("b")
}
}
This doesn't work. But this does:
dataFrameOf(
"foo" to listOf("a", "b", "c"),
"bar" to listOf(1, 2, 3)
)
.plot {
line {
x("bar")
y("foo")
}
vLine {
xIntercept.constant(2)
}
}
Is this just a limitation with the Kandy library right now? Is there any ways around it?Joe Boudreau
10/27/2024, 7:50 PMString
isn't Comparable
so I converted the dates into LocalDate
instances, but the same error gets thrown still. It seems like xIntercept.constant
only accepts numbers as input 🤔Andrei Kislitsyn
10/28/2024, 8:36 AMNumber
- it’s a Lets-Plot limitation. In your case it will be enough to make mapping to a list of one element instead of constant setting:
dataFrameOf(
"foo" to listOf("a", "b", "c"),
"bar" to listOf(1, 2, 3)
)
.plot {
line {
x("foo")
y("bar")
}
vLine {
xIntercept(listOf("b"))
}
}
Joe Boudreau
10/28/2024, 1:17 PMJoe Boudreau
11/01/2024, 4:09 PMallChanges.groupBy("Symbol")
.plot {
line {
x("Date")
y("Change (%)")
color("Symbol")
}
vLine {
xIntercept(listOf("10/19/2023"))
type = LineType.DASHED
}
}