Jump to content
JChartFX Community
  • 0

My chart is showing random data instead my ajax data


shinsengumi
 Share

Question

 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

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...