questuk
Posts: 2
Joined: Sun Dec 02, 2018 6:39 pm

How to get local data into Highcharts ?

Hi,

New to Highcharts, I am trying to get a folder called data.json into highcharts, but cannot get it to work ?

I tried in the index.htm .... $.getJSON("ajax/data.json", function (data) { ............ etc

and also tried ..... $.getJSON("data.json", function (data) { ............ etc

neither worked. what am i doing wrong, i have xammp running
and the index,htm and the file data.json are in the same htdocs folder.

This is just a small part of the json file
[
1167609600000,
0.7537
],
[
1167696000000,
0.7537
],
[
1167782400000,
0.7559


any ideas welcome ?


Thanks
bastss
Site Admin
Posts: 1192
Joined: Wed Oct 17, 2018 10:59 am

Re: How to get local data into Highcharts ?

Hello questuk,

There is whole information about using JSON files in Highcharts API: https://www.highcharts.com/docs/working ... processing. Read it carefully and try to figure out what could be wrong in your files. Let know if this help.

Best regards!
Sebastian Wędzel,
Highcharts Developer
questuk
Posts: 2
Joined: Sun Dec 02, 2018 6:39 pm

Re: How to get local data into Highcharts ?

Hi,

I did get it working by using the example that comes with Highcharts-6.2.0
Look in ... examples/line-time-series/index.htm

My files were in a folder called .... C:\xampp\htdocs\V1.1
My JSON file was called .... data.json also in the above folder.

So you need to change the following .... to your folder and file name.
$.getJSON("/V1.1/data.json", function(data) {

Also I had to change these ...
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="../../code/highcharts.js"></script>
<script src="../../code/modules/exporting.js"></script>
<script src="../../code/modules/export-data.js"></script>

to

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="code/highcharts.js"></script>
<script src="code/modules/exporting.js"></script>
<script src="code/modules/export-data.js"></script>

This points to where my modules were in my folder V1.1, yours may be in a different place ?



Hope this helps someone in the future !

Thanks
bastss
Site Admin
Posts: 1192
Joined: Wed Oct 17, 2018 10:59 am

Re: How to get local data into Highcharts ?

I haven't tested it locally, I just sent you info to documentation but I am glad that you figured out it by yourself ;)

Kind regards!
Sebastian Wędzel,
Highcharts Developer

Return to “Highcharts Usage”