vico
vico copied to clipboard
Dashed Path support for Line Layer
Description
This pull request enables users to add a android.graphics.PathEffect
of their choice to the LineCartesianLayer
.
Why?
On occasion, the design team may require a dashed pattern for the lines on the Line Layer. There's also an ongoing discussion about adding support for a Dashed Line
- #469
With this update, users can add any PathEffect
they prefer, allowing them more flexibility than just a dashed effect.
How?
First, I added a nullable pathEffect
property to the LineSpec
in /core/cartesian/layer/LineCartesianLayer.kt
class. Utilizing the library's extensive APIs, I assigned this pathEffect
to linePaint
within the drawLine()
function.
Next, I updated the rememberLineSpec()
function in /compose/cartesian/layer/LineCartesianLayer.kt
to include the pathEffect
property.
And finally, I updated the sample application by using the pathEffect
property on Chart9
. This shows how simple it is to add a new line effect.
What does that look like?
Default Behavior | with DashPathEffect |
---|---|
Default Behavior | with DashPathEffect |
---|---|