Jump to content
JChartFX Community
  • 0

My ajax chart is not showing


shinsengumi

Question

Hi, here's my JS code

 

 function loadChart(){
               $.ajax({
                    url: (some/json/data/generator),
                    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 result seems fine


[{"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}]

 

And yet not showing, pls help. Thanks in advance

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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...
×
×
  • Create New...