pka
pka

Reputation: 183

add/delete series dynamically/programmatically in dygraph

lets say dygraph is already showing a chart with few series. Is it possible to add/insert a new series, or delete one existing series dynamically(via javascript)?

I could not find anything like it in examples/documentation.

Upvotes: 3

Views: 4988

Answers (3)

Sandeep Gunda
Sandeep Gunda

Reputation: 319

You can't add those later on, however you can plot multiple series with the dygraph. If you have 2 time series t1 and t2, you can combine them and pass the date to dygraph

combined <- cbind(t1, t2)
dygraph(combined)

Upvotes: 0

Jabran Saeed
Jabran Saeed

Reputation: 6168

Keep your data and label arrays somewhere. When you want to add a new series, pull them up, update with new data and then

g.updateOptions({'file':data,'labels':labels});

"data" is the updated data array For this example I am using native data format. For CSV you would edit the original data csv file and update it similarly.

Upvotes: 3

danvk
danvk

Reputation: 16945

dygraphs doesn't take responsibility for managing your data. That's up to you.

That being said, you can show/hide series using the visibility option.

Upvotes: 3

Related Questions