Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Using JSONStringDataHandler with Pie Chart
PostPosted: Wed Jun 29, 2024 1:12 pm 
Offline

Joined: Wed Jun 29, 2024 1:04 pm
Posts: 1
I am trying to get pie charts working with JSON. I have created a simple test using your examples as follows:
Code:
var chart1 = new EJSC.Chart('pie_chart', {
      show_legend: false,
      title: 'Pie Chart'
  });

chart1.addSeries(new EJSC.PieSeries(new EJSC.JSONStringDataHandler(
'[{"x":3,"y":"Widgets"},{"x":7,"y":"Doodads"},{"x":4,"y":"Thingamagigs"},{"x":10,"y":"Whatchamacallits"},{"x":2,"y":"Gizmos"},{"x":5,"y":"Thingies"}]'
    ),
    {
      treeLegend: true ,
      defaultColors: [
          'rgb(255,140,0)',  //DarkOrange
          'rgb(178,34,34)',  //FireBrick
          'rgb(153,50,204)',  //DarkOrchid
          'rgb(255,255,0)',  //Yellow
          'rgb(112,219,147)',  //AquaMarine
          'rgb(35,107,142)'  //SteelBlue
      ]
    }
  ));


This renders the chart correctly except that the wedges simply say 7 of 31, 4 of 31 etc. The don't have the labels (Widgets, Doodads, etc.).

Should my JSON be in a different format or is there some other way to make it use the labels?

Thanks,

James


Top
 Profile  
 
 Post subject: Re: Using JSONStringDataHandler with Pie Chart
PostPosted: Wed Jul 06, 2024 10:56 am 
Offline

Joined: Tue May 10, 2024 10:57 am
Posts: 6
The PieSeries expects data in the form {x,label}, not {x,y}. If you replace all of the "y": with "label": in your JSON string, you will see the labels in the hints.

_________________
Joshua Dees
Emprise Corporation
Web Application Developer


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

Home | RSS Feed © 2006-2011 Emprise Corporation