dagronf / DSFSparkline

A lightweight sparkline component for macOS, iOS and tvOS
MIT License
138 stars 11 forks source link

feature: insert at in addition to push #7

Closed PierreBrisorgueil closed 3 years ago

PierreBrisorgueil commented 3 years ago

hey, is it possible to update an index of the datasource in the dot graph in addition to the push? this would generate other types of filling animations ?

dagronf commented 3 years ago

Hey mate, there's currently no direct way to update a value in a datasource, the library only allows you to push or set.

However, you could simulate it yourself using a set if you wanted to, like this...

let source = DSFSparkline.DataSource(values: [0,1,2,3,4,5,6,7])
// source contains [0,1,2,3,4,5,6,7]

// Do something...

// Grab out the current datasource raw data, manipulate it as you need, then set() it back
var currentData = source.data
currentData.replaceSubrange(3...3, with: [33])
source.set(values: currentData)
// source now contains [0,1,2,33,4,5,6,7]

Not the most elegant for sure, but it would do what you needed.

PierreBrisorgueil commented 3 years ago

Hum, okok, Nice ! 👌

Thx for your time and reactivity !