cubism icon indicating copy to clipboard operation
cubism copied to clipboard

Smooth interpolation between values?

Open victorhooi opened this issue 12 years ago • 7 comments

Hi,

Is it possible to add an argument to Cubism.js that will allow it to do smooth interpolation between values, or over missing values?

Somebody asked about it on SO here:

http://stackoverflow.com/questions/13732309/interpolation-on-cubism-graphs

and the answer mentioned using custom interpolators in D3:

http://bl.ocks.org/mbostock/3310323

Is something like that possible to add into Cubism.js?

Cheers, Victor

victorhooi avatar Apr 04 '13 06:04 victorhooi

I would look at modifying graphite.js to apply interpolation before passing to cubism for rendering. Essentially what you're asking is for cubism to make up data for you when it doesn't know a value. Better to do that yourself I think, and keep cubism's rendering code as "just the facts" :)

RandomEtc avatar Apr 04 '13 14:04 RandomEtc

Also, the horizon rendering code draws one rectangle per pixel. In other words you need the same number of data points as you have pixels in your graph. Hope that makes sense!

RandomEtc avatar Apr 04 '13 14:04 RandomEtc

I see value in doing this on the Cubism side, although it might also be nice to have Graphite do it; smoothing is a pretty useful feature to mitigate noise in metrics.

If you were to do this on the Cubism side, I expect you could compose a smoothing algorithm with another metric implementation, similar to how time-shifting and metric arithmetic are implemented. A simple method of smoothing is interpolating the previous value with the new value. So, if the underlying metric reports a new value of v1, the smoothed metric blends this with the previous value v0 and reports v0 + (v1 - v0) * α, where α is a parameter in the range [0, 1] depending on how much smoothing you want.

mbostock avatar Apr 04 '13 17:04 mbostock

Hi,

In our case, we're looking at using it with a Cube backend - not Graphite.

It would be nice to be able to just switch this on in Cubism, regardless of the backend - Cube, Graphite, CSVs, your own custom one etc.

Just so I understand what @mbostock is saying - we add another another OperatorPrototype to metric-operator.js so that when given a metric, it doesn't report the real metric, but rather something in-between the last known value and the real metric?

Cheers, Victor

victorhooi avatar Apr 04 '13 20:04 victorhooi

The metric operators derive a new metric, which in this case would compose the original metric with a smoothing function. So metric.subtract(50) doesn’t modify the metric, it returns a new metric whose values are the original values minus 50.

mbostock avatar Apr 04 '13 20:04 mbostock

Hi,

@RandomEtc How hard do you reckon this would be to implement? Is this something that's on the horizon? (See what I did there...lol).

Cheers, Victor

victorhooi avatar Apr 08 '13 02:04 victorhooi

@victorhooi I have no idea, sorry. I'm not planning to work on this myself.

RandomEtc avatar Apr 08 '13 17:04 RandomEtc