JonathansCorner.com

What's Wrong With My Json?

Recommended Posts

I am trying to migrate from working XML to JSON. The XML is:

 

<chart caption="Volume 2010 vs. 2011" xAxisName="Month" yAxisName="USD" showValues="0" numberPrefix="{:content:}quot;>
<categories>
	<category label="Current" />
	<category label="February" />
	<category label="January" />
	<category label="December" />
	<category label="November" />
	<category label="October" />
</categories>

<dataset seriesName="2010" color="4060af">
	<set value="1" />
	<set value="2" />
	<set value="1" />
	<set value="2" />
	<set value="1" />
	<set value="2" />
</dataset>

<dataset seriesName="2011" color="622567">
	<set value="3" />
	<set value="4" />
	<set value="3" />
	<set value="4" />
	<set value="3" />
	<set value="4" />
</dataset>
</chart>

 

 

The JSON I have is getting an error, message "No data to display."

 

{
"chart":
 {
  "palette": "5",
  "caption": "Volume 2010 vs. 2011",
  "xaxisname": "Month",
  "yaxisname": "USD",
  "numberprefix": "{:content:}quot;,
  "rotatevalues": "1",
  "placevaluesinside": "1",
  "forceyaxisvaluedecimals": "1",
  "yaxisvaluedecimals": "2",
  "showvalues": "0"
 },
"categories":
 [
  {
   "label": "October"
  },
  {
   "label": "November"
  },
  {
   "label": "December"
  },
  {
   "label": "January"
  },
  {
   "label": "February"
  },
  {
   "label": "Current"
  }
 ],
"dataset":
 [
  {
   "seriesname": "2010",
   "color": "4060af",
   "showvalues": "0",
   "data":
	[
     {
  	"value": "1"
     },
     {
  	"value": "2"
     },
     {
  	"value": "1"
     },
     {
  	"value": "2"
     },
     {
  	"value": "1"
     },
     {
  	"value": "2"
     }
	]
   },
   {
	"seriesname": "2011",
	"color": "622567",
	"showvalues": "0",
	"data":
     [
  	{
       "value": "3"
  	},
  	{
       "value": "4"
  	},
  	{
       "value": "3"
  	},
  	{
       "value": "4"
  	},
  	{
       "value": "3"
  	},
  	{
       "value": "4"
  	}
     ]
	}
   ]
  }

 

 

The code that calls it, and works for XML, is:

 

            var volChart = new FusionCharts("FusionCharts/MSColumn3D.swf",
             "volChartId", "100%", "300", "0", "1");
           // volChart.setXMLUrl("Vol.xml");
           volChart.setJSONUrl("Vol.json");
           volChart.render("volChartContainer");

 

 

What is wrong with my code?

 

Thanks,

Edited by JonathansCorner.com

Share this post


Link to post
Share on other sites

I needed to change the categories to:

 

 "categories":
 [
  {"category":
   [
	{
     "label": "October"
	},
	{
     "label": "November"
	},
	{
     "label": "December"
	},
	{
     "label": "January"
	},
	{
     "label": "February"
	},
	{
     "label": "Current"
	}
   ]
  }
 ],

 

 

However, it's still not working...

Edited by JonathansCorner.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now