function b(data){
document.write(data);
$('#graphContainer').highcharts(data);
}
I need to pass JSON to .highcharts() API.
Using document.write() i have printed that the value of data is:
{"chart" : { "type" : "line"} , "title" : { "text" : "First Time Fix Rate"} , "xAxis" : { "title" : { "text" : "Time"} , "categories" : [ 2009.0 , 2010.0 , 2011.0 , 2012.0 , 2013.0]} , "yAxis" : { "title" : { "text" : "FTFR"}} , "plotOptions" : { "series" : { "cursor" : "pointer" , "point" : { "events" : { "click" :function () {alert (this.category+':' + this.y);}}}}} , "tooltip" : { "pointFormat" : "{series.name} produced {point.y:,.0f}
warheads in {point.x}"} , "series" : [ { "data" : [ 100.0 , 222.0 , 555.0 , 367.0 , 100.0]}]}
If I manually place this in
$('#graphContainer').highcharts(data);
removing the white spaces, graph is getting generated. but if want chart to be generated dynamically, its failing without any javascript error.
I tried json2.js, JSON.parse and Stringify, but that didn't solve the issue. Am i missing something?
If i set the data in session from my client code and access it using scriplet ie $('#graphContainer').highcharts(<%=session1.getAttribute("data")%>); it works fine. I wonder whats wrong with variables?
I cant use session here.
data = data.replace(/ /g, '');before the document.write?