shinsengumi Posted November 28, 2013 Report Share Posted November 28, 2013 hello, here's my js function loadChart(){ $.ajax({ url: ('some/json/data/'), type: "POST", contentType: "application/json; charset=utf-8", dataType : "json", success: function (result) { chart1 = new cfx.Chart(); chart1.getData().setSeries(2); chart1.getAxisY().setMin(500); chart1.getAxisY().setMax(2000); var series1 = chart1.getSeries().getItem(0); var series2 = chart1.getSeries().getItem(1); series1.setGallery(cfx.Gallery.Lines); series2.setGallery(cfx.Gallery.Bar); chart1.setDataSource(result.d); var divHolder = document.getElementById('ChartDiv'); chart1.create(divHolder); }, error: function (xhr, txt, err) { alert("error connecting to data: " + txt); } }); } $(document).ready(function($){loadChart()}); My json's ajax resonse seems legit [{"Bulan":"Januari","Motor":1500,"Onderdil":1234},{"Bulan":"Februari","Motor":1500,"Onderdil":1234},{"Bulan":"Maret","Motor":1500,"Onderdil":1234},{"Bulan":"April","Motor":1500,"Onderdil":1234},{"Bulan":"Mei","Motor":1500,"Onderdil":1234},{"Bulan":"Juni","Motor":1500,"Onderdil":1234},{"Bulan":"Juli","Motor":1500,"Onderdil":1234},{"Bulan":"Agustus","Motor":1500,"Onderdil":1234},{"Bulan":"September","Motor":1500,"Onderdil":1234},{"Bulan":"Oktober","Motor":1500,"Onderdil":1234},{"Bulan":"November","Motor":1500,"Onderdil":1234},{"Bulan":"Desember","Motor":1500,"Onderdil":1234}] The title well said, the chart is showing random data instead my ajax data. pls help, thanks in advance Quote Link to comment Share on other sites More sharing options...
0 JuanC Posted December 2, 2013 Report Share Posted December 2, 2013 Please make sure the object you are passing to setDataSource is an array of javascript objects. If you are getting a string in your ajax callback you might need to use eval. JuanC Quote Link to comment Share on other sites More sharing options...
Question
shinsengumi
hello,
here's my js
My json's ajax resonse seems legit
The title well said, the chart is showing random data instead my ajax data.
pls help, thanks in advance
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.