Dukis
Posts: 6
Joined: Tue May 31, 2022 8:16 am

Create a multi line chart from csv file

Hello Im really new to highcharts and imtrying to create a multi line chart with 4 lines for a django application with the input coming from the csv. I've tried to look into it with the demos from :
https://jsfiddle.net/gh/get/library/pur ... line-basic

https://jsfiddle.net/gh/get/library/pur ... mo/compare
but since my date format is kinda weird im getting messed up outputs. Any idea on how to display them correctly?
Data from csv looks like this :

Code: Select all

datetime,        humidity , temperature, co2,    ch4
2020-12-31 12:02:25	62	16	866	0.88
2020-12-31 12:17:41	62	17	847	0.73
2020-12-31 12:32:55	62	17	834	0.73
2020-12-31 12:48:11	61	18	825	0.64
2020-12-31 13:03:26	61	17	816	0.73
2020-12-31 13:18:40	61	17	809	0.64
2020-12-31 13:33:55	62	16	798	0.73
2020-12-31 13:49:10	61	17	786	0.64
2020-12-31 14:04:26	61	18	770	0.64
2020-12-31 14:19:41	61	18	759	0.82
2020-12-31 14:34:56	61	18	760	0.7
Any way to just have a

Code: Select all

rangeDescription: 'Range: 2022 '
and print out only the months dates
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Create a multi line chart from csv file

Hello,

Welcome to our forum and thanks for contacting us with your question!

Here's an example of how to use CSV data. Series should be separated by commas.

Demo: https://jsfiddle.net/BlackLabel/ms8563dv/
API: https://api.highcharts.com/highcharts/data.csv
Any way to just have a

Code: Select all

rangeDescription: 'Range: 2022 '
and print out only the months dates
Could you be more precise about what you mean?

Let me know if you have any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
Dukis
Posts: 6
Joined: Tue May 31, 2022 8:16 am

Re: Create a multi line chart from csv file

Thing is i have a data.csv file which is in the same folder as the html im doing the highchart for. So i want to use this to get the data which are in the same format as i 've shown you before .
Another way i tried was in django i saved the csv into a model and used the

Code: Select all

{% for last in last_ten  %}
{{last.datetim}},
{{last.air_humidity}},
{{last.air_temperature}},
{{last.carbon_dioxide_co2}},
{{last.methane_ch4}}
{% endfor %}
for,but the this messes up the output like so :
ssss.png
ssss.png (34.7 KiB) Viewed 748 times
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Create a multi line chart from csv file

Hi,

With pure JS you are unable to read data from a file located in the same folder. You can do it with e.g. Node or Django, but I have no knowledge of Django, so I can't help you directly with that. Certainly the CSV (Comma-separated values) data must be correctly formatted for the parser to process it. The data you submitted does not meet it.

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Stock”