Key: Use the setjsondata (data) or setxmldata (data) method of fusioncharts.
Some front-end aspx code:
<Div id = "div7"> comparison curve </div> <SCRIPT type = "text/JavaScript"> <! -- $ (Document ). ready (function () {$. ajax ({type: "Post", contenttype: "application/JSON; charset = UTF-8", URL: "fusioncharts. asmx/getjsondata ", data:" {} ", datatype: 'json', success: function (JSON) {var DATA = eval ('+ JSON. d + '); var MyChart = new fusioncharts ("column3d.swf", "mychartid7", "330", "220", "0", "1"); MyChart. setjsondata (data); MyChart. render ("div7") ;}, error: function (xhr) {// if no above capture error occurs, the callback function alert ('page error \ n \ R' + xhr. responsetext) ;}}) ;}); // --> </SCRIPT> </div>
Fusioncharts. asmx code:
[Webmethod] Public String getjsondata () {// convert the data retrieved from various data sources to JSON format and manually write the data. Other APIs can be converted. For details, detailed analysis string B = "{\" chart \ ": {\" caption \ ": \" weekly sales summary \ ", \" xaxisname \ ": \" week \", "+" \ "yaxisname \": \ "sales \", \ "numberprefix \": \ "$ \"}, "+" \ "data \": ["+" {\ "label \": \ "week 1 \", \ "value \": \ "100 \"}, "+" {\ "label \": \ "Week 2 \", \ "value \": \ "191600 \"}, "+" {\ "label \": \ "week 3 \", \ "value \": \ "14000 \"}, "+" {\ "label \": \ "Week 4 \", \ "value \": \ "55700 \"}]} "; return B ;}