SpeedView icon indicating copy to clipboard operation
SpeedView copied to clipboard

Set dynamic values to section

Open abby1602 opened this issue 5 years ago • 1 comments

I have to set the value dynamically from json to speedview

For example i am getting the value for green orange red as 65 , 95, 100 .

Then how to set the sections accordingly

I am getting the values from json so it will change accordingly.

PLease help me out in this

abby1602 avatar May 12 '21 08:05 abby1602

First you need to clear previous sections:

speedometer.clearSections()

Then add new ones:

val firstSectionEndPoint = .65f // Get from json.
val secondSectionEndPoint = .95f
val thirdSectionEndPoint = 1f
speedometer.addSections(
        Section(0f, firstSectionEndPoint , Color.GREEN),
        Section(firstSectionEndPoint, secondSectionEndPoint, Color.ORANGE),
        Section(secondSectionEndPoint, thirdSectionEndPoint, Color.RED)
)

Don't try to edit your existing sections, it may leads to conflict exception.

anastr avatar May 12 '21 08:05 anastr