score:4
$.getjson
is an asynchronous request. once you receive the data, then you can pass it to highcharts, thus you have to call that code from within the callback function of $.getjson()
.
try this, use a helper function to process your data and draw the chart, see drawchart()
below:
var options1 = {
chart: {
renderto: 'container1'
},
series: []
};
var drawchart = function(data, name) {
// 'series' is an array of objects with keys:
// - 'name' (string)
// - 'data' (array)
var newseriesdata = {
name: name,
data: data
};
// add the new data to the series array
options1.series.push(newseriesdata);
// if you want to remove old series data, you can do that here too
// render the chart
var chart = new highcharts.chart(options1);
};
$.getjson('tokyo.jsn', function(data){
drawchart(data, 'tokyo');
});
$.getjson('sydney.jsn', function(data){
drawchart(data, 'sydney');
});
see fiddle: http://jsfiddle.net/amyamy86/pum7s/
score:4
you can use solution used by highcharts in that example: http://www.highcharts.com/stock/demo/compare
or first create empty chart, without any series, and then use addseries()
function in each callback, see: http://api.highcharts.com/highcharts#chart.addseries()
Source: stackoverflow.com
Related Query
- How to get multiple data series into Highcharts
- How to have multiple highcharts with different series data in vuejs without repeating code
- How to get multiple series data in tooltip highcharts (Without loosing tooltip pointer arrow)
- How to get multiple series data in tooltip highcharts?
- Highcharts - how to create multiple y axis and group the data series
- HighCharts Drill Down multiple series , how to get drill down on second item on drill down?
- How to make multiple Y-axis with incoming series of data from database using Highcharts
- How to get total of highcharts multiple series
- How to set columnrange width to expand the length of the x-axis in multiple data series in Highcharts
- Get Highcharts Series Data after Load
- Hiding _groups_ of series in Highcharts and jQuery: how to get acceptable performance?
- Highcharts how to use JavaScript variable as series data source?
- Highcharts with JSON data and multiple series
- How to pass custom data into Highcharts graph click event
- How get data name in Highcharts pie chart legend instead of "Slice" using array of values?
- How to hide one series data info in tooltip using highcharts
- Highcharts not displaying series data for graph with multiple Y-axes
- Multiple series data on HighCharts column
- Highcharts show the same yAxis start and end value with multiple data series
- Highcharts get series data zoom indices
- Getting a django view python dict into highcharts series data
- How to input plot data into highcharts with rails
- Highcharts - How to make a scatter plot with multiple series from HTML table
- How to construct HighCharts data series to match returned Json via ajax call
- How to get Series Name Based on Selection in Highcharts
- How To Get Data From Database To Highcharts Plugin in cakephp
- How to add multiple series in highcharts synchronously
- Highcharts - how to show/hide multiple data labels on mouseOver and mouseOut
- Multiple series data Highcharts line
- Get json data into Highcharts scatter plot
More Query from same tag
- Highcharts: Stop the circle marker from shrinking in size on mouseover
- HighCharts and Javascript to pass data as array
- Highcharts series.data not working for me
- Dynamic number of highcharter plots
- Using HighchartsExport Library for .Net I am getting Blank Page
- Blank boxes in high chart when data is null
- How to format xAxis label as date for each value in Highcharts?
- Highcharts: Add point without connecting series
- Highcharts: allowDecimals on y-axis when it's logarithmic is ignored
- Can I lay two Highcharts series side-by-side?
- highcharts: A chart with 1 or 0 in Y axis
- Inhibit caching JavaScript/CSS
- Activity Gauze Highchart DataLabel
- Highcharts: How to toggle between different xaxis having individual plotbands, onclick rangeselector buttons
- How to update Highcharts data dynamically over a period of time
- how to show data for single day in graph using php mysql
- Highchart ctor doesn't return a Chart
- Highcharts, arithmetic operation between two graph's series points
- Render Highchart with dynamic ID in jQuery tooltip
- Highcharts: how to get the data points in the zoomed window?
- Highcharts / Highmaps with Angular - Cannot run demo
- Getting data from mysql and drawing a chart
- How can I optimize Highcharts.js zones?
- Toggle connectNulls with button
- highcharts export server not working out of the box (Java)
- How to extend or highlight a horizontal line in Highcharts?
- Generate javascript and html blocks on the fly
- How to add space between series in stacked columns in HighChart?
- How to scrape data from Highcharts charts using selenium and python?
- Highcharts Area Range Plot in rCharts