Starting FusionWidgets XT, charts/gauges can be rendered using JSON (JavaScript Object Notation) data. JSON is a light-weight and simple data format that is easy to read and understand. Though derived from JavaScript, the data structure is language-independent, with encoders and parsers available for virtually every programming language.
- JSON data is text based data consisting of key and value pairs in format key : value . The values have data associated with them
- You can make up your own key-value pairs like name : "John Doe"
to store data
- Every JSON data is enveloped by curly brace and key:value pairs are comma separated, like { firstName : "John" , lastName: "Doe" }. In JavaScript, this format is called an Object
- A key can be a value within single or double-quotes e.g. { "name" : "John Doe" }
- You can use Objects as values too. For example, { "employee" : { "name" : "John Doe" , "department" : "Project Manager" , "age" : 35 } }
- In JSON, the basic data types are:
- Number (integer or real)
- String (double-quoted Unicode with backslash escaping)
- Boolean (1 or 0 in FusionCharts JSON)
- null
- Array (an ordered sequence of values of Number, String, Boolean, null, Object or Array type, comma-separated and enclosed in square brackets) e.g. [ "employees" : [ "Employees" , { "name" : "John Doe" } , 35 ]
- Object (a collection of key:value pairs, comma-separated and enclosed in curly braces. Value can be of Number, String, Boolean, null, Object or Array type) e.g. { "employee" : { "name" : "John Doe" , "department" : "Project Manager" , "age" : 35 } }
A FusionWidgets XT chart is controlled by a single JSON data source i.e., the same source contains data to plot, functional settings and cosmetic properties. There are many properties that you can define for each chart
type. However, it is not necessary to define all the properties for a given
chart. For example, if you do not want to change the default setting of
the canvas (color, alpha etc.), you don't have to define any property
for the canvas - the default values will be assumed. Thus, each chart
can be generated using minimal properties.
|
{ "chart": { "palette": "2", "caption": "Cisco", "setadaptiveymin": "1" }, "dataset": [ { "data": [ { "value": "27.26" }, { "value": "37.88" }, { "value": "38.88" }, { "value": "22.9" }, { "value": "39.02" }, { "value": "23.31" }, { "value": "30.85" }, { "value": "27.01" }, { "value": "33.2" }, { "value": "21.93" }, { "value": "34.51" }, { "value": "24.84" }, { "value": "39.32" }, { "value": "37.04" }, { "value": "27.81" }, { "value": "22.95" }, { "value": "24.73" }, { "value": "37.63" }, { "value": "29.75" }, { "value": "22.35" }, { "value": "34.35" }, { "value": "27.6" }, { "value": "27.97" }, { "value": "32.36" }, { "value": "22.56" }, { "value": "24.15" }, { "value": "24.93" }, { "value": "35.82" }, { "value": "23.45" }, { "value": "37.64" }, { "value": "26.99" }, { "value": "29.48" }, { "value": "36.63" }, { "value": "35.58" }, { "value": "32.19" }, { "value": "27.59" }, { "value": "26.94" }, { "value": "32.35" }, { "value": "22.63" }, { "value": "25.97" }, { "value": "25.28" }, { "value": "26.73" }, { "value": "23.47" }, { "value": "20.55" }, { "value": "34.58" }, { "value": "29.16" }, { "value": "34.97" }, { "value": "24.57" }, { "value": "20.7" }, { "value": "32.61" } ] } ] }
|
The chart
Object defines all the settings that help to manipulate the chart.
You can find the list of all the attributes for this Object in the XML Sheet of each chart.
In the most general form, chart attributes represent the following JSON format:
"attributeName" : "Value"
e.g., "caption" : "Cisco"
The attributes can be arranged in any order, with values either in single or in double quotes,
like caption:'Cisco'. However,
you need to make sure that a particular attribute occurs only once for
a given element.
Please note that the XML attributes declared in the XML Sheet for Spark charts are same as the JSON keys in FusionWidgets XT JSON data format.
The dataset Object contains the data for the chart. Each Spark chart can have only one element in the dataset Array. This Object contains a data Array. The data Array is a set of Objects, each passing a single value through the value property as shown below:
"dataset": [ { "data": [ { "value": "27.26" }, { "value": "37.88" },
...
]
}
]
|