Jump to content
JChartFX Community
  • 0

My Chart is not showing - shows data not available= json


dsasu1
 Share

Question

this is what im doing

function get_dash()

{

       

        $('.tab-content').html('<div id="ChartDiv" class="ChartDiv1" style="width:600px;height:400px;display:inline-block"></div>'); 

            

        

          $.ajax({

         

         type:"POST",

         url:baseurl + "ajaxgetoffice/dashreport",

         cache:false,

         dataType:"json",

         data: "userid=" + userid,  

         }).done(function(response){

              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);
           
var data =
            chart1
.setDataSource(data);
           
var divHolder = document.getElementById('ChartDiv');

        chart1.create(divHolder);           

        });   

 

my json response is below

[{"name":"Event","namecount":"1"},{"name":"Job","namecount":"1"}]

 

graph shows, data not available. what am i doing wrong?  Thanks for your help, i am new to this

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

We do not show the data because the namecount field contains strings not numbers. You have 2 choices

1) Modify the json response as shown, note the values for namecount do not contain quotes which makes them numbers and not strings

[{"name":"Event","namecount":1},{"name":"Job","namecount":1}] 

 

2) If you cannot modify the json used to populate the chart, specify how to use the data fields

    var field1 = new cfx.FieldMap();

    field1.setName("name");

    field1.setUsage(cfx.FieldUsage.Label);


    var field2 = new cfx.FieldMap();

    field2.setName("namecount");

    field2.setUsage(cfx.FieldUsage.Value);

 

    chart1.getDataSourceSettings().getFields().add(field1);

    chart1.getDataSourceSettings().getFields().add(field2);

 

Regards,

JuanC 

Link to comment
Share on other sites

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...