How to extract the data from highstock chart

♀尐吖头ヾ 提交于 2020-01-01 18:19:15

问题


Assume that I have a sample highstock chart like this in the website. I was wondering whether it is possible to extract the data from the chart alone (i.e. chart is created by the third person and the data used for the chart is not accessible to others).

<img src="http://www.highcharts.com/stock/demo/basic-line">

回答1:


Yep. Each chart is stored within HighChart's Highcharts.charts array. On the page you've linked that currently contains the one chart:

Highcharts.charts
-> [ z.Chart ]

This is an object containing all the data within that chart. We can view it by picking it from the Highcharts.charts array index (0 in this case):

Highcharts.charts[0]
-> z.Chart { ... }

This contains all the information you'd need. Each chart object contains a series property which is an array containing the data for each of the series the chart renders. A data property exists within each series containing all the data within, and the name property contains the name of the series.

For example:

Highcharts.charts[0].series[0].name
-> "APPL"
Highcharts.charts[0].series[0].data
-> Array[1774]

HighCharts' documentation is laid out in the same format as the JavaScript object it creates. This can be viewed here: http://api.highcharts.com/highcharts.




回答2:


Actually if you download the page with the chart, you can easily extract the data. It will be stocked in the main *.html file.

It's not the actual data, but rather the positions of every point in the chart. But you'll just have to scale it to get what you want.



来源:https://stackoverflow.com/questions/29147250/how-to-extract-the-data-from-highstock-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!