Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141780

Draw multiple series in Highchart from single JSON data container

$
0
0

I an trying to draw 2 lines in Highchart from JSON file I have been reading threads with similar problems but to no avail so now i posting my problem. My JSON file looks like this

[[ 1578258092000, 109, 32 ], [ 1578258812000, 120, 34 ], [ 1578260104000, 123, 35 ],

and i trying to use code below to instruct Highchart

Highcharts.getJSON('temps.json',
    function (data) {

        Highcharts.chart('container', {
            chart: {zoomType: 'x'},
            title: {text: 'Values over time'},
            subtitle: {text: document.ontouchstart === undefined ? 'Pinch the chart to zoom in' : 'Pinch the chart to zoom in'},
            xAxis: {type: 'datetime'},
            yAxis: {title: {text: 'Value'}},
            legend: {enabled: false},
            plotOptions: {
                area: {
                    fillColor: {
                        linearGradient: {
                            x1: 0,
                            y1: 0,
                            x2: 0,
                            y2: 0
                        },
                        stops: [
                            [0, Highcharts.getOptions().colors[0]],
                            [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                        ]
                    },
                    marker: {
                        radius: 2
                    },
                    lineWidth: 1,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    },
                    threshold: null
                }
            },

            series: [{
                name: 'Value1',
                data: data.arr1
				},{
                name: 'Value2',
                data: data.arr2	
				}]
        });
    }
);

I dont know how to split the data from JSON file into 2 series. Can someone give me an example?


Viewing all articles
Browse latest Browse all 141780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>