CSommer
Posts: 56
Joined: Mon Jun 27, 2016 12:27 am

Data via mixed data file

Thu Aug 31, 2023 3:36 am

I currently have the charts working fine using a js file with this format
varXXX = [{x:, y:, ,,,},{},{},{}...]
varYYY = [{x:, y:, ,,,},{},{},{}...]

This is identified in the chart by using

series[{name: 'SomeName', data: 'XXX', id: 'XXX'},{name: 'SomeotherName', data: 'YYY', id: 'YYY'}]


what I am wanting to do is mix this data and somehow identify each data block by an identifier as a single data block eg.
x, y, id, marker
123, 456, XXX, circle
2341, 45184, YYY, square
129, 458, XXX, circle
133, 446, XXX, circle
143, 456, XXX, circle
2342, 45084, YYY, square
2343, 47084, YYY, square

I have tried seriesMapping of a CSV, and putting an Id in the map but this doesn't produce any data.

data: {csvURL: '\\\someAdresss\myFile.csv',
seriesMapping: [{x: 0, y: 1, id: 2, marker:3}]}

I am plotting this as a Spline.


Regards

CSommer

jakub.j
Posts: 866
Joined: Tue Jan 24, 2023 11:14 am

Re: Data via mixed data file

Thu Aug 31, 2023 7:53 am

Thanks for contacting us!

In data.beforeParse you can add a custom logic to spread the data between 2 series and map it based on id or value. In this case I check if the value is positive and if so I add it to one series and if it's negative or 0, I add a point to the second series.

Demo: https://jsfiddle.net/BlackLabel/na21ogkh/

I hope you will find it useful
Best regards
Jakub
Jakub
Highcharts Developer

CSommer
Posts: 56
Joined: Mon Jun 27, 2016 12:27 am

Re: Data via mixed data file

Sat Sep 09, 2023 5:43 am

Hi Jakub,

This is almost my solution.

My data is not in a URL location, but in a network folder.

I have tried using the network location with no luck.

I have put the data in a <pre> as per the API example and it creates errors.

How can I use this solution using csv rather than csvURL.

Regards

CSommer

jedrzej.r
Posts: 526
Joined: Tue Jan 24, 2023 11:21 am

Re: Data via mixed data file

Mon Sep 11, 2023 4:12 pm

Hi!

Unfortunately, accessing the file in your local network is assumed the same as accesing a file from your computer, which isn't possible due to security reasons. What I'd reccomend is setting up a file as accessible URI in your network folder.

As for defining data in HTML structure and the applying changes, I've come with a workaround to the errors. Instead of updating series directly in parsed method, I'm declaring two arrays in which i push data depending on the condition. After that, on chart load, I set data for series with defined arrays.

Demo: https://jsfiddle.net/BlackLabel/9recmf8g/

API:
https://api.highcharts.com/class-refere ... es#setData
https://api.highcharts.com/class-refere ... art#redraw

Let me know if you have any further questions!
Best regards!
Jędrzej Ruta
Highcharts Developer

Return to “Highcharts Stock”