首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

Charts JavaScript Tutorials. Part 2. Loading External data

2014-02-21 
Charts JavaScript Tutorials. Part 2. Loading External data.There is one more path which should be f

Charts JavaScript Tutorials. Part 2. Loading External data.

There is one more path which should be fixed:

Data of this chart is generated html file, so it’s not good for us – we want to load external data.

Lets create a simple text file, called data.txt and add some data to it – first column contains dates and the second one has some numbers. Note, our data is irregular – it has gaps at weekends:

2011-02-23,133034
2011-02-24,122290
2011-02-25,383603
2011-02-28,125285
2011-03-01,118042
2011-03-02,102500
2011-03-03,434047
2011-03-04,422374
2011-03-07,396473
2011-03-08,453142

First column has date and two other columns – some numbers. Save this file to the same folder as lineWithDateBasedData.html file and then go back to the editor with lineWithDateBasedData.html file opened. Delete generateChartData method and also the line where it is called.

Loading data

Add a method which loads external data to the script:

And here is a?working example?of all what we’ve done here.

热点排行