score:0
Check the response(JSON DATA) coming through ajax having datatype as object or not. Because highcharts will work it the response is of datatype as object.
If it is returning as string then, convert it into object using eval('(' + response + ')')
score:1
In an example from a project I'm working on right now, I evaluate the series data from an array like this. Maybe that is cheating, but I at least got it to work :)
var xAxisCat = new Array();
var hSeries = new Array();
for (var datevote in contestantObject.contestants[cObj].votes)
{
xAxisCat.push(datevote);
hSeries.push(contestantObject.contestants[cObj].votes[datevote]);
}
var setSeries = "["+hSeries+"]";
And then, at the series creation I evaluate the created array instead:
series: [{
name: contestantObject.contestants[cObj].name,
data: eval(setSeries)
}]
score:16
I figured this out. Here's how I did it in case anyone else has the same question:
In my script that generates the JSON data, I did the following:
header('Content-type: text/json');
//Placeholder - random data for now
$x1 = "2011-8-1";
$y1 = rand(0, 100);
$x2 = "2011-8-2";
$y2 = rand(0, 100);
//Generate this array from database data
$arr = array($x1 => $y1, $x2 => $y2);
echo json_encode($arr);
Then, in the ajax script that adds the series to the chart, I did the following:
function requestData() {
$.ajax({
url: 'chartData.php',
success: function(json) {
var series = {
id: 'series',
name: 'JSON Data',
data: []
}
$.each(json, function(date,value) {
xval = date.split("-");
x = Date.UTC(xval[0], xval[1] - 1, xval[2]);
series.data.push([
x,
value
]);
});
chart.addSeries(series);
},
cache: false
});
}
Source: stackoverflow.com
Related Query
- adding series to highcharts from JSON
- Highcharts displays series names but missing data points from json source
- adding series from existing highcharts chart
- Highcharts multiple series json from php
- passing json values to highcharts from .net code behind
- Charts using Highcharts with multiple series from JSON
- Highcharts + Angularjs : Graph doesn't redraw when adding series from an external event
- Highcharts with multiple series from JSON Dynamically
- Highcharts with multiple series from JSON
- Extract data series from a JSON array for a Highcharts chart with 2 y-axis
- Highcharts not displaying series pushed from JSON
- Add Categories and Series dynamically from JSON in HighCharts
- Plotting multiple series from JSON php import to Highcharts
- Plotting multiple series in single Highcharts plot from JSON
- Highcharts adding additional blank series from csv
- Highcharts display date as series label from JSON data?
- Highcharts multiple series from json
- Adding multiple dynamic series and axes via JSON into Highcharts
- highcharts with dynamically adding multiple series from JavaScript array name value pair
- How to render highcharts from external json for multiple series
- How can I assign multiple series from my json data? Highcharts
- Highcharts multiple series from JSON with different style depending on serie name
- HighCharts Hide Series Name from the Legend
- Proper way to remove all series data from a highcharts chart?
- How can I hide series from a HighCharts legend?
- How can I hide a series from initially being displayed in Highcharts
- Highlighting Highcharts series from a remote element
- Send JSON data to highcharts pie from asp.net MVC controller in C#
- Adding a series dynamically with HighCharts Stock Charts
- Highcharts with JSON data and multiple series
More Query from same tag
- Highcharts 12hr time format of x-axis labels
- how to render chart based on different id?
- shift y-axis from dumbell chart within the line
- how to display charts/graphs based on user specific data
- highcharts destroy selected group annotation with button
- Javascript window.print() gives me a different output
- TickWidth 0 for Categories (not in grouped category)
- Highcharts GANTT chart - need to allow category with no data
- Unable to add tooltip for titles in highcharts
- Highlight a slice of pie chart in highcharts on click of a div
- Highcharts: How to make curve start outside of the visible view horizontally?
- Cannot find Component identifier in JSF
- Highcharts solidgauge with green/yellow/red gradient
- how to add custom button on highstock/highcharts on subplot/addAxis
- Labels string from Asp.net does not distributed in the highchart
- Get a reference to a Highcharts chart
- creating a chart using a count query on repository in symfony
- Stacked bar chart colors in case of Drilldown (open on click of Line chart)
- Highchart can't be displayed
- Highchart is not working when I am fetching the axis values from database
- Highchart network graph with tooltip when hover on every node
- javascript highcharts jQuery issue
- Highcharts align multiple piecharts
- Change marker width and height in scatter chart
- Returning correctly formatted json response for use in highcharts with Laravel
- JSON data size limit
- How to disble invisible legend padding in highcharts?
- what means ${demo.css} in example files of highcharts ? That piece of code seems to be literal
- highcharts fixed point width is not working when a series is hidden
- Is there any way to include heatmap in treemap