Anychart linechart dynamic mulitple lines

0
Hi everyone,   I am trying to plot an Anychart where I provide the dynamic data using JSON structure and export mapping. Plotting a single line chart where X-Axis shows “Time” and Y-Axis shows “Temperature” was not difficult but when I tried to plot another series on the same chart duplicating the values for X-Axis and showing “Pressure” values on Y-Axis, then it doesn’t work. Where I am stuck at the moment is when I enter the sample data in JSON snippet. When I do that it says "Array contains multiple json object definitions. Only first will be used". A screenshot of the problem is posted down below and the sample data (just an example) I used is:   [   {     "type": "scatter",     "mode": "lines+markers",     "name": "dekkingsgraad",     "hoverinfo": "y+x",     "line": {       "color": "black",       "dash": "line"     },     "x": [       "2021-11-01",       "2021-10-01",       "2021-09-01",       "2021-08-01",       "2021-07-01",       "2021-06-01",       "2021-05-01",       "2021-04-01",       "2021-03-01",       "2021-02-01",       "2021-01-01",       "2020-12-01",       "2020-11-01",       "2020-10-01",       "2020-09-01",       "2020-08-01",       "2020-07-01",       "2020-06-01",       "2020-05-01",       "2020-04-01",       "2020-03-01",       "2020-02-01",       "2020-01-01"     ],     "y": [       101,       103,       104,       105,       102,       99,       101,       102,       103,       102,       104,       102,       99,       101,       102,       103,       103,       99,       101,       100,       99,       101,       100     ]   },   {     "type": "scatter",     "mode": "lines",     "name": "Waarschuwing(>103)",     "hoverinfo": "y+x",     "line": {       "color": "#008000",       "dash": "dot"     },     "x": [       "2021-11-01",       "2021-10-01",       "2021-09-01",       "2021-08-01",       "2021-07-01",       "2021-06-01",       "2021-05-01",       "2021-04-01",       "2021-03-01",       "2021-02-01",       "2021-01-01",       "2020-12-01",       "2020-11-01",       "2020-10-01",       "2020-09-01",       "2020-08-01",       "2020-07-01",       "2020-06-01",       "2020-05-01",       "2020-04-01",       "2020-03-01",       "2020-02-01",       "2020-01-01"     ],     "y": [       103,       103,       103,       103,       103,       103,       103,       103,       103,       103,       103.5,       103.5,       103.5,       103.5,       103.5,       103.5,       103.5,       103.5,       103.5,       103.5,       103.5,       103.5,       102.5     ]   },   {     "type": "scatter",     "mode": "lines",     "name": "Overschrijding(<=98)",     "hoverinfo": "y+x",     "line": {       "color": "#ff0000",       "dash": "dot"     },     "x": [       "2021-11-01",       "2021-10-01",       "2021-09-01",       "2021-08-01",       "2021-07-01",       "2021-06-01",       "2021-05-01",       "2021-04-01",       "2021-03-01",       "2021-02-01",       "2021-01-01",       "2020-12-01",       "2020-11-01",       "2020-10-01",       "2020-09-01",       "2020-08-01",       "2020-07-01",       "2020-06-01",       "2020-05-01",       "2020-04-01",       "2020-03-01",       "2020-02-01",       "2020-01-01"     ],     "y": [       98,       98,       98,       98,       98,       98,       98,       98,       98,       98,       99,       99,       99,       99,       99,       99,       99,       99,       99,       99,       99,       99,       100     ]   } ]  
asked
3 answers
1

Hi Manish,

 

For each line I create a JSON object, Line Object, X object and Y object see below (not for the chart you provided but same setup)

 

And then in a loop I fill the x and y values for each line

Unfortunately not possible to add the MPK file. 

 

answered
0

Hi Manish, 

The message you are seeing indicates that the json snippet that you have used contains multiple objects with values like type, mode, name etc. It means that it will use the top object to create the mapping. But, since you use the same attributes on this object, this should not be a problem. 

You need to repeat the creation of objects in the MF for each series in your plot. Each JsonObject object will represent 1 series. Associate every JsonObject with the root object and then export to json. Goodluck! 

answered
1

Hi Manish,

Good to see that people use my example data ;-)

I assume you have created the JSON structure. There is no issue with the multiple objects..

Have you created the export mapping like below?

After you have created the export mapping you can start with filling the export tables with data via a microflow.

 

regards,

 

Andre

answered