can't update data to DyGraph after created by csv file

2,116 views
Skip to first unread message

Anhtv

unread,
Apr 18, 2012, 12:40:08 PM4/18/12
to dygraphs-users
I have a question the same as :
http://groups.google.com/group/dygraphs-users/browse_thread/thread/1c949ca36bd9fff7/26a8a11bbcd1f49b?q=#26a8a11bbcd1f49b
And atfer create Dygraph by csv file ,then I want continue update data
to Dygraph .
Every 100 miliseconds, I call the function in .js below:

$(function (updateData) {
data = [];
if (myDyGraph== null) {
data = [];

myDyGraph= new
Dygraph(document.getElementById("graphId"), "myData.csv",
{

});
}
else {
var t = new Date();
var x =formatDate(t,'yyyy/MM/dd HH:mm:ss');

data.push([x, updateData]); // updateData is decimal
type
myDyGraph.updateOptions({ 'file': data] });

}
});

and myData.csv like this :
Date,Price
2012/04/19 00:01:02 , 123
2012/04/19 01:02:03 , 345
2012/04/19 04:05:06 , 678

I drawed dygraph with myData.csv at the first time call function
above . But I can't update data by use updateOptions at the next
call . My DyGraph is always display empty when call updateOptions .
How can I update data to my graph ?

Robert Konigsberg

unread,
Apr 18, 2012, 12:42:25 PM4/18/12
to taviet...@gmail.com, dygraphs-users
Your code has clear syntax errors on it (e.g. "data]" instead of "data".) Can you please clarify what you're doing?
--
Robert Konigsberg | Google NY | http://go/monarch


Anhtv

unread,
Apr 18, 2012, 12:56:41 PM4/18/12
to dygraphs-users
sorry I typed code incorect . I want to continue update data after I
created DyGraph by csv file .My graph is DYNAMIC  graph. Example : my
graph is show the change of  foreign currency every second. Every
users start the website , they can see the data  before showed on
graph ( that i created by csv)  and live data change every second .
Sorry for my English is terrible . Thank you

On Apr 18, 11:42 pm, Robert Konigsberg <konigsb...@google.com> wrote:
> Your code has clear syntax errors on it (e.g. "data]" instead of "data".)
> Can you please clarify what you're doing?
>
>
>
>
>
>
>
>
>
> On Wed, Apr 18, 2012 at 12:40 PM, Anhtv <tavietanhs...@gmail.com> wrote:
> > I have a question the same as :
>
> >http://groups.google.com/group/dygraphs-users/browse_thread/thread/1c...

Robert Konigsberg

unread,
Apr 18, 2012, 1:03:59 PM4/18/12
to taviet...@gmail.com, dygraphs-users
Can you give us an example of your code that compiles?

Anhtv

unread,
Apr 18, 2012, 2:07:54 PM4/18/12
to dygraphs-users
Message has been deleted

Dan Vanderkam

unread,
Apr 18, 2012, 3:11:37 PM4/18/12
to taviet...@gmail.com, dygraphs-users
If you're pulling in data from a CSV file, you may need to do
something to ensure that your browser isn't caching the data.

If you're plugging in raw data, it should work just fine. This page
does this, for instance: http://dygraphs.com/tests/dynamic-update.html

- dan

On Wed, Apr 18, 2012 at 2:52 PM, Anhtv <taviet...@gmail.com> wrote:
> I used ASP MVC 4 pattern and pass data from server by SignalR for my
> project .
>  I'd better to write my example code at jsfiddle.net but i don't know
> how to add jsscripts , sorry for this

Anhtv

unread,
Apr 18, 2012, 3:19:08 PM4/18/12
to dygraphs-users
I already read this demo dynamic update you suggest and I have done
with it . But my problem is : I can't update continue data after
created dygraph by csv file .
You said : my browser wasn't caching the data . How I can do ?

Anhtv

unread,
Apr 18, 2012, 3:31:42 PM4/18/12
to dygraphs-users
My project base on the demo dynamic update you suggest .
And the thing I want is : Dygraph will load old data ( from csv file)
when user open website . Then it will update live data continue
And my cache of browser is biger and biger if I run dynamic dygraph
long time . How can I dispose my browser cache every running the
dygraph ?

Robert Konigsberg

unread,
Apr 18, 2012, 3:31:50 PM4/18/12
to taviet...@gmail.com, dygraphs-users
One possible way to fix it is laid out in Dan's first comment from the groups post you mentioned at the start.

Anhtv

unread,
Apr 18, 2012, 3:48:10 PM4/18/12
to dygraphs-users
I pluged in raw data ( csv file ) . It still not run . It just load
csv file successfully at the first time ,but then dygraph was empty
when updateOption attribute called data to update .

On Apr 19, 2:11 am, Dan Vanderkam <dan...@gmail.com> wrote:

Dan Vanderkam

unread,
Apr 18, 2012, 6:43:44 PM4/18/12
to taviet...@gmail.com, dygraphs-users
Do you have any javascript errors? It's hard for us to debug without a
working link.

- dan

Anhtv

unread,
Apr 18, 2012, 8:35:33 PM4/18/12
to dygraphs-users
I haven't any js error because I used Firebug to debug , it's running
successful .
My working link was posted above :http://www.2shared.com/file/-lUNPRo6/
SignalR_with_DyGraph_Sample.html
I though my problem was format DateTime of live update data , I
formated them like data in .csv file ( yyyy/MM/dd HH:mm:ss) , but it
wasn't update .
Do maybe add more attribute of Dygraph to resolve this
problem ? ....

Robert Konigsberg

unread,
Apr 18, 2012, 9:03:30 PM4/18/12
to taviet...@gmail.com, dygraphs-users
Your first message points to another conversation from this mailing list. Dan suggested fixing this kind of problem by using a random number as a URL parameter. Try it.
Message has been deleted
Message has been deleted

Anhtv

unread,
Apr 18, 2012, 10:42:51 PM4/18/12
to dygraphs-users
In this demo : http://jsfiddle.net/hzkjG/1/
It running exacly all thing I want to talk . I will try to modify this
load data by .csv instead .
Thank you so much ,Dan & Robert !

Anhtv

unread,
Apr 18, 2012, 11:51:15 PM4/18/12
to dygraphs-users
$(function() {
var data = [];
}

var g = new Dygraph(document.getElementById("div_g"), "myData.csv", {
drawPoints: true,
showRoller: true,
valueRange: [0.0, 1.2],
labels: ['Time', 'Random']
});

window.intervalId = setInterval(function() {
var x = new Date(); // current time
var y = Math.random();
data.push([x, y]);
g.updateOptions({
'file': data
});
}, 1000);
});

myData.csv like this:
2012/04/20 12:00:01,1.2
2012/04/20 13:00:00,0.3
2012/04/20 14:00:00,1.5
2012/04/20 15:00:00,0.8
2012/04/20 16:00:00,1.1​


Sorry you but can't resolve my problem :(

Anhtv

unread,
Apr 19, 2012, 5:35:54 AM4/19/12
to dygraphs-users
Solved !
--> DyGraph just only convert x-values string to date , can not
convert date to string , doesn't it ?
Thanks for your supported !

Robert Konigsberg

unread,
Apr 19, 2012, 6:17:38 AM4/19/12
to taviet...@gmail.com, dygraphs-users
Congratulations! I'm sorry for having difficulty understanding you.

Anhtv

unread,
Apr 21, 2012, 3:27:24 AM4/21/12
to dygraphs-users
ye, I will support my comunicate follow Dygraph version , lol

On Apr 19, 5:17 pm, Robert Konigsberg <konigsb...@google.com> wrote:
> Congratulations! I'm sorry for having difficulty understanding you.
>

Sunil Kumar

unread,
Sep 1, 2017, 2:25:39 AM9/1/17
to dygraphs-users, taviet...@gmail.com
Hi,
  Can you gave me real example of .updateOptions.
Reply all
Reply to author
Forward
0 new messages