square / cubism

Cubism.js: A JavaScript library for time series visualization.

Home Page:https://square.github.com/cubism/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metric Plugin API?

dustin opened this issue · comments

I've written a time series database that I'm using with cubism, but I find adding support for it just a bit awkward. Currently, I've replaced the calls to cubism.context() with mydatabase.context(), which calls cubism.context() and injects a new metric into the context so it can access the context properly and work as expected.

Has any thought been put into an API for registering new metrics? It looks like it'd be really easy to add a cubism.registerMetric() function to provide the proper context and let my plugin become it.

To expand a bit: I just discovered that my strategy was horribly flawed as there's some kind of context cache that was causing my graphs to render incorrectly, further necessitating a correct way to do this.

Typically you start by defining a new source by extending cubism.context.prototype; however, this is not required.

Then you can define new metrics using context.metric.

You can also extend cubism.metric.prototype, but this is rarely needed.