Useful feature? DygraphData object for compiling series data into Dygraph data array

64 views
Skip to first unread message

Jody Florian

unread,
Aug 8, 2016, 8:15:50 AM8/8/16
to dygraphs-users
I want to contribute at some point, and I'm wondering if code I've written already could be useful if integrated into Dygraphs:

There are two somewhat related features:

Firstly: Compiling data with multiple series is a bit of a pain if  X-axis points values are not the same. (I.e. the option "connectSeparatedPoints: true" is required). So having individual objects for each series made sense to me. Then this is compiled into separate data and options objects which are passed to the Dygraph() constructor.

So, I have three objects: PlottableSeries, MyDygraphData, MyDygraphOptions.

Secondly, I've been writing graphs which mix types of series. One might be stepped as per Dygraph examples. Another might have multiple mathematical functions per series, each defined by intervals. This second use-case prompted me to write a specialised series object, and helper objects to make all this smoother.

The objects I've written for this are:

FunctionSeries (extends PlottableSeries)
IntervalObject (Abstract)
IntervalConstant (extends IntervalObject) - probably overkill, but gives a consistent way of adding an interval that is simply a straight horizontal line
IntervalFunction (Abstract, extends IntervalObject)
IntervalFunctionLinear (extends IntervalFunction) - allows a linear function to result in two points over the range of the interval (or 3, if the y value is to remain constant after the interval)
IntervalFunctionNonlinear (extends IntervalFunction) - results in multiple points to be plotted, based on the function provided. Abstracts the number of points required to plot it, so that all series' resolution (distance between points on x axis) is controlled at a higher level.

While it has been very useful to me, I don't know if it's a justifiable chunk of code to add to the library?

I'd be interested to hear opinions; when I'm brave enough to tackle GIT I might submit a pull request.

I've also got some other ideas that I have yet to work on, such as providing a hook so a callback is available when a specific segment of the graph is hovered over, to give information such as total length, or x or y length as an annotation. (E.g. for a step graph series, display the step height or width when that step is hovered over.)

Thanks and congratulations to all who've developed DyGraphs, it's a top-notch piece of work.
Jodes

Dan Vanderkam

unread,
Aug 9, 2016, 11:18:44 AM8/9/16
to dygraphs-users
I'd be interested in seeing your code. Did you write custom plotters or DataHandlers?

The party line has always been that dygraphs is about plotting your data, not managing it. But questions about combining series come up constantly, so some sort of DygraphsData helper could be useful.

  - Dan

--
You received this message because you are subscribed to the Google Groups "dygraphs-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dygraphs-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jody Florian

unread,
Aug 9, 2016, 11:49:41 AM8/9/16
to dygraph...@googlegroups.com

No custom plotters or data handlers, I've only just started using Dygraphs but plan to get to know all its features soon.

My code is rather crude still, it was mainly just a handy abstraction, the innards are pretty embarrassing :) And it only handles a small subset of Dyphraph's use-cases in its current form, but I will pass you what I have when I think it might be helpful.

But one thing that did occur to me, which fits with with what you were saying, is that maybe the existing CSV functionality could be refactored out into the DygraphsData helper, as it seems it's a bit of an oddball feature given the stance on data management?

To unsubscribe from this group and stop receiving emails from it, send an email to dygraphs-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "dygraphs-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dygraphs-users/9cHmvmuhn4w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dygraphs-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages