DannyR

Json Object Discrepency In 3.2 Style

Recommended Posts

First, thanks for FusionCharts. I'm glad I was able to convince my company to make the investment.

 

I'm not sure if you would consider this a bug (I would from a developer's usability standpoint), but this may help some other people who are struggling with the "style" object in the Json data format.

 

Using FusionCharts("id").getJSONData() we can see that the typical style object is structured like this:

 

"styles":[
 {
   "definition":[
     {
       "style":[
         {
           "type":"font",
           "color":"666666",
           "name":"CaptionFont",
           "size":"15"
         },
         {
           "type":"font",
           "name":"SubCaptionFont",
           "bold":"0"
         }
       ]
     }
   ],
   "application":[
     {
       "apply":[
         {
           "toobject":"caption",
           "styles":"CaptionFont"
         },
         {
           "toobject":"SubCaption",
           "styles":"SubCaptionFont"
         }
       ]
     }
   ]
 }
]

 

However, if you feed this object to the chart using setJSONData() what will happen is the chart will interpret this object as follows [substituting (..) for brevity]:

 

"styles":[
 {
   "definition":[
     {
       "style":[
         {
           "style":[
             (..)
           ]
         }
       ]
     }
   ],
   "application":[
     {
       "apply":[
         {
           "apply":[
             (..)
         }
       ]
     }
   ]
 }
]

 

Note the extra "style" and "apply"! Having observed this, I changed my input object to the following structure:

 

"styles":[
 {
   "definition":[
     (..)
   ],
   "application":[
     (..)
   ]
 }
]

 

... thus eliminating the "style" and "apply" properties altogether and moving the "definition" and "application" arrays up a level. This seems to work just fine. If this is the intended behavior, maybe this could be documented somewhere?

Share this post


Link to post
Share on other sites

My pleasure. Keep up the great work guys!

 

Thank you for posting this! The JSON documentation for this whole product is atrocious, and your post here just put an end to about 2 hours of absolute frustration. The JSON data format as listed in the examples seemed a bit too deep, composed of too many layers of arrays.

 

The documentation absolutely needs to be changed to be correct. I was about 5 minutes from abandoning FusionCharts altogether, and I'm looking at recommending the expensive SaaS license to my client. That's a big sale to miss out on.

 

Other problems include no standardization on what needs to be capitalized. Is it "toobject" or "toObject?" When defining a font and choosing a font face, is it "font" or "face?" I've found examples of both. If I'm applying something to the caption, is it "caption," "Caption," or "CAPTION?

Share this post


Link to post
Share on other sites

It seems like some sort of auto XML -> JSON script was used to generate the JSON documentation. The JSON structure as written very closely resembles the XML structure, even though there is this huge difference.

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