How to plot series in separate graphs within same dygraph object.

4,973 views
Skip to first unread message

David VP

unread,
Apr 28, 2012, 12:39:06 AM4/28/12
to dygraph...@googlegroups.com
I have a CSV file with 4 series, which get plotted together in the same graph, crossing each other.

We want that each series to be plotted in an independent graph, but within the same dygraph object. This means that each series has to be plotted with its own X-axis and Y-axis labels and numbers.

I have looked here:

But haven't found such an option. Is there any way to do this?

Robert Konigsberg

unread,
Apr 28, 2012, 5:33:58 AM4/28/12
to ing....@gmail.com, dygraph...@googlegroups.com

What do you want out of a consolidated single dygraph that you can't get from four individual graphs?

David VP

unread,
Apr 28, 2012, 10:31:39 AM4/28/12
to dygraph...@googlegroups.com
It's more like a preference from the research team that I work for.

I also think that the consolidated graph is OK.

El sábado, 28 de abril de 2012 04:33:58 UTC-5, konigsberg escribió:

What do you want out of a consolidated single dygraph that you can't get from four individual graphs?

Robert Konigsberg

unread,
Apr 28, 2012, 11:43:30 AM4/28/12
to ing....@gmail.com, dygraph...@googlegroups.com
I think you can just make four graphs with 1/4 the height and get the same effect.
--
Robert Konigsberg | Google NY | http://go/monarch


David VP

unread,
Apr 28, 2012, 11:50:59 AM4/28/12
to dygraph...@googlegroups.com
Yep, but that will require our CSV files to have one column each, which -by now- is really convenient.

The thing is, that they would find it useful to be able to graphically appreciate each series alone.

Robert Konigsberg

unread,
Apr 28, 2012, 11:52:07 AM4/28/12
to ing....@gmail.com, dygraph...@googlegroups.com
Although slightly wasteful, you set only one series' visibility on each graph, and pass all four series. Does that make sense?

David VP

unread,
Apr 28, 2012, 11:57:00 AM4/28/12
to dygraph...@googlegroups.com
Excuse me, in " but that will require our CSV files to have one column each, which -by now- is really convenient"

I tried to say that having the 4 series in a single file is really convenient. Changing it to single series per file would require to have 4 separate files.

About your idea, yes, it can be an option but... as our CSV files are about 5MB each, loading 20 MB per graph would be significatively slow for an Internet client.

We'll weight the options, and decide the best way to solve it.

Thanks for your replies !

Robert Konigsberg

unread,
Apr 28, 2012, 11:59:41 AM4/28/12
to ing....@gmail.com, dygraph...@googlegroups.com
No, I'm saying that you have one CSV with four columns, apply that same data to each graph, and then set the visibility on each.

http://dygraphs.com/options.html#visibility

Dan Vanderkam

unread,
Apr 28, 2012, 12:42:02 PM4/28/12
to konig...@google.com, ing....@gmail.com, dygraph...@googlegroups.com
I think Robert's idea is a good one. Since the CSV file will be the
same for all four charts, it should get cached in the client. Hence
the only overhead is in memory and CPU on the client end. You should
profile before deciding if this is truly a bottleneck.

You may find this demo helpful for synchronizing multiple charts:
http://dygraphs.com/tests/synchronize.html

If the visibility trick proves too slow, parsing the CSV data on your
own and feeding only one column into each dygraph really isn't too
bad. You can read about the native format here:
http://dygraphs.com/data.html

- Dan

Robert Konigsberg

unread,
Apr 30, 2012, 7:06:49 PM4/30/12
to Dan Vanderkam, ing....@gmail.com, dygraph...@googlegroups.com
I still think the visibility option is the right choice, but if you want to parse the data locally, I just published a blog post that will help you: http://blog.dygraphs.com/2012/04/how-to-download-and-parse-data-for.html

David VP

unread,
Apr 30, 2012, 7:14:24 PM4/30/12
to dygraph...@googlegroups.com, Dan Vanderkam, ing....@gmail.com
Yep, visibility works as planned and there is just some processing overhead, but my clients (the research team) can afford  it, because they know we're plotting 84k points on each chart.

Thanks for the advice !!!
Reply all
Reply to author
Forward
0 new messages