JavaScript Object Notation is a standard way of converting an object to a text string. An object described in JSON is consists of a set of curly braces {} enclosing a set of attribute-value pairs. Since the JSON format for OFC is describing an object which determines how OFC is to present data to the user the first character in the file should be an open curly brace { and the last character should be a closing curly brace }.
The attributes contained within the OFC JSON object can be a combination of strings, numbers, booleans, arrays and even other objects. Any amount of white space (spaces, tabs, new lines) can be used to make the JSON file more readable by us mere humans.
The data for the entire JSON file is enclosed in a set of curly braces {}. The simplest JSON File Format for OFC is in fact an object with no attributes which would be: {}.
The attribute-value pairs must be in the format of the attribute name enclosed in double quotes (“) followed by a colon (:) followed by the value of the attribute in the format specific to its data type. Attribute names are case sensitive so care must be taken when defining them.
A comma (,) is used to separate each attribute-value pair. The last item in a list must not have a comma after it.
Object Attributes
The OFC JSON File Format consists of several objects (or you might think of them as sections) which define a specific portion of the chart. For instance there is a tooltip object which defines what a tool tip is supposed to look like. So within the JSON File there would be a tooltip attribute defining an object without an attributes (what I call an an empty object) would like this:
{ “tooltip” : { } }
A JSON file with three empty objects would look like this:
{ “title” : {},
“tooltip” : {},
“x_axis” : {}
}
A JSON file with an object containing an empty object would look like this:
{ “x_axis” : { “labels” : {} } }
String Attributes
All string values are enclosed in double quotes “”
Examples:
“text”: “My Chart Title”,
“mouse” : “follow”,
Number Attributes
Numbers can be defined in the normal fashion you would write a number or in exponential notation. Do not use a leading plus sign (+).
Examples:
“min” : -10.5,
“x” : 1.25e8, (not currently valid in OFC2)
“x” : null, (specifies a null value – do not use quotes)
Array Attributes
All array values are enclosed in a set of square brackets ( [ ] ). OFC uses arrays of objects to define the set of plots to display and within each plot definition a set of values objects to be plotted.
Examples:
“elements” : [ { “type” : “scatter”, “text” : “plot line 1”, ... }, { “type” : “scatter”, “text” : “plot line 2”, ... }],
“values” : [ {“x”:1, “y”: 1}, {“x”:2, “y”:4} ],
Boolean Attributes
The boolean attributes can only have one of two values: either true or false. The words true and false must not be enclosed in quotes and must be in all lower case in the JSON file.
Examples:
“visible” : false,
“hollow” : true,
Colour Attributes
Colour type attributes can be represented as a number or as a text string consisting of a pound sign (#) followed by 6 hex digits. The hex digits are 3 sets of 2 hex digits each representing the saturation of the red, green and blue components in that order.
Examples:
“colour” : 0, // 0 is black
“colour” : “#FF0000”, // Red
“colour” : “#00FF00”, // Green
“colour” : “#0000FF”, // Blue
“background_colour” : “#FFFFFF”, // White