Open Flash Chart Version 2 – JSON File Definition

X Axis Attributes Object

NOTE: Items in bold red represent patches that may or may not be added to OFC-2.



Defines the attributes for the X Axis of the chart. This includes the X Axis itself, the vertical grid lines, tick marks and the labels.

"x_axis":{"min":0, "max":5, "stroke":2, "tick-height":3,

“colour”:”#784016”, “offset”:true, “grid-colour”:”#F5E1AA”,

"3d":0, "steps":1,

"labels":{"rotate":”vertical”, ”size”:10, “align”:”center”,

”steps”:1, “visible-steps”:3,

"labels":[“Jan”, {text:“Feb”, “size”:12, “colour”:”#FF0000”},

“Mar”, “Apr”, “May” ] },

},

This is an example for a scatter chart using a unix timestamp for the X values.



"x_axis":{"min":1220245200, "max":1220590800, "stroke":2, "tick-height":3,

“colour”:”#784016”, “offset”:true, “grid-colour”:”#F5E1AA”,

// Always specify the labels if using unix timestamps

// It can take a long to create that many auto labels :-)

"labels":{"rotate":"vertical",

"text":"#date#", // default date format

"labels":[{"x":1220245200}, // unix timestamp for 01 Sep 2008

{"x":1220331600},

{"x":1220418000},

{"x":1220504400, "text":"Sep 04"}, // override text

{"x":1220590800},

{"x":1220677200}] },

},



OBJECT

ATTRIBUTE

VALID VALUES

DEFAULT

NOTES

x_axis”






min”

Any value

0

The X value at the point where the X Axis meets the Y axis in the lower left corner


max”

Any value

undefined

If “max” is not specified then it will be automatically determined by the data being plotted.


stroke”

0 to n

2

Width in pixels of the axis line. Zero (0) is a hairline.


tick-height”

0 to n

3

Specifies the length of the tick marks in pixels. Zero (0) means do not draw the tick mark. If set to zero allows the grid line to be drawn without the tick mark.


colour”

#RRGGBB” hex string

#784016

Colour for the axis line. Default is a brownish.


grid-colour”

#RRGGBB” hex string

#F5E1AA

Colour for the background of the chart area. Default is a beige (?).


3d”

0 to n

0

Specifies the height of the axis rectangle for a 3D rendering. 0 indicates that it is not in 3D.


steps”

1 to n

1

Specifies how many steps between grid lines. One (1) means a grid line at every value. Two (2) means a grid line at every other value. Etc.


offset”

true or false

true

Specifies whether or not there should be a small gap between the Y-Axis and the minimum X point.


labels”

Object describing the text labels

{...}

Specifies the attributes for the labels associated with the grid lines.

* See labels definition table below.




Definition of the the “labels” object within the “x_axis” object.

OBJECT

ATTRIBUTE

VALID VALUES

DEFAULT

NOTES

labels”






colour”

#RRGGBB” hex string

#000000”

Defines the color of the label text. Default is black.


text

user defined text

undefined

Specifies the default label text for the X axis labels and should include magic values otherwise all labels will be the same.*

* The magic value #val# will be replaced with the Y value.

* Four magic values are available for use with unix timestamps: #date#, #date:___#, #gmdate# and #gmdate:___#.**

** See the date formatting section below


size”

6 to n

10

Defines the font size of the label


steps”

1 to n

1

Defines number of steps between the labels to be created.

* If you need the labels for use in tooltips with the #x_label# magic value then always use a value of 1. To only display some of them use the “visible-steps” variable.

* This value could be specified before the patch but I believe it was always overridden by the “steps” defined at the “x_axis” level.


visible-steps”

1 to n

1

Defines number of steps between the labels to be displayed.

* 1 = display every label

2 = display every other label

etc.


rotate”

diagonal”

vertical”

-180 to 180

0

Specifies if the label should be rotated.

diagonal” - labels are displayed at an angle. Forces the “rotate” value to -45 degrees.

vertical” - labels are displayed vertically. Forces the “rotate” value to 270 (same as -90) degrees.

A number – the number of degrees to rotate the label

0 – labels are displayed horizontally. This can be overridden by specifying a “rotate” value.


align

auto”

center”

auto”

auto” - rotated labels are moved so that the high point label is pointing to the tick mark.

center” - rotated labels are moved so that the label is centered under the tick mark.


justify

left”

center”

right”

left”

Specifies how to justify multi-line labels.

Defaults to “left” to conform with OFC-2


visible

true or false

true

Whether or not the labels should be visible


labels

Array of text string and/or objects defining each label

[...]

If no labels are defined then labels will be generated automatically based on the “steps” value with the text being the X value at each point.

* Each label object can override any of the above attributes




Definition of the array of “labels” objects within the “labels” object in the “x_axis” object. The label objects with in the “labels” array can be either just a text string or another object with attributes specified for an individual label. Below is the definition of the attributes that are valid for one of these label objects.

OBJECT

ATTRIBUTE

VALID VALUES

DEFAULT

NOTES

label objects




Label objects that can be in the “labels” array


colour”

#RRGGBB” hex string

#000000”

Defines the color of the label text. Default is black.


size”

6 to n

10

Defines the font size of the label


rotate”

diagonal”

veritcal”

-180 to 180

0

Specifies if the label should be rotated.

diagonal” - labels are displayed at an angle. Forces the “rotate” value to -45 degrees.

vertical” - labels are displayed vertically. Forces the “rotate” value to 270 (same as -90) degrees.

A number – the number of degrees to rotate the label

0 – labels are displayed horizontally. This can be overridden by specifying a “rotate” value.


align

auto”

center”

auto”

auto” - rotated labels are moved so that the high point label is pointing to the tick mark.

center” - rotated labels are moved so that the label is centered under the tick mark.


justify

left”

center”

right”

left”

Specifies how to justify multi-line labels.

Defaults to “left” to conform with OFC-2


x

Numeric value

undefined

* This attribute is meant for use with scatter and scatter_line charts. It generates a tick mark and label at the specified “x” value.

** This can probably be used with line charts if you are careful to match the “x” value with the position of the point it coincides with. (the first label is “x”:0)


text

User defined text

undefined

Specifies the text for the X Axis label.

* The magic value #val# will be replaced with the Y value.

* Four magic values are available for use with unix timestamps: #date#, #date:___#, #gmdate# and #gmdate:___#.**

** See the date formatting section below


visible

true or false

true

Whether or not the label should be visible



Magic Values

Replacement variables can be used in the definition of tool tips and labels so that each one does not have to be individually defined. When the text is actually displayed, the variables below will be replaced with its appropriate value (assuming the variable is valid in the context it is used).



Magic Value

Description

#date#

Formats the X Value as a date string using the local time with format Y-m-d such as: 2008-10-23

#date:_____#

Formats the X Value as a date/time string using the local time with user defined formatting.

* See Date Formatting below

#gmdate#

Formats the X Value as a date string using GMT/UTC time with format Y-m-d such as: 2008-10-23

#gmdate:_____#

Formats the X Value as a date/time string using GMT/UTC time with user defined formatting. This is useful for formatting elapsed time in hours, minutes and seconds.

* See Date Formatting below

#val#

Inserts the X Value into the label text at the indicated location(s).



Date Formatting


The user defined date format is implemented to match the formatting performed by the PHP date function. The following table lists the valid format characters and their descriptions.


Format

Character

Description

Example returned

Values

Day



d

Day of the month, 2 digits with leading zeros

01 to 31

D

A textual representation of the day, three letters

Mon through Sun

j

Day of the month without leading zeros

1 to 31

l (lower case L)

A full textual representation of the day of the week

Sunday through Saturday

N

ISO-8601 numeric representation of the day of the week

1 (for Monday) through 7 (for Sunday)

S

English ordinal suffix for the day of the month, 2 characters

st, nd, rd or th. Works well with j

w

Numeric representation of the day of the week

0 (for Sunday) through 6 (for Saturday)

* Not Implemented

z

The day of the year (starting from 0)

0 through 365

* Not Implemented

Week



W

ISO-8601 week number of year, weeks starting on Monday

Example: 42 (the 42nd week in the year)

* Not Implemented

Month



F

A full textual representation of a month

January through December

m

Numeric representation of a month, with leading zeros

01 through 12

M

A short textual representation of a month, three letters

Jan through Dec

n

Numeric representation of a month, without leading zeros

1 through 12

t

Number of days in the given month

28 through 31

* Not Implemented

Year



L

Whether its a leap year

1 if it is a leap year, 0 otherwise

* Not Implemented

o

ISO-1806 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.

* Not Implemented

Y

A full numeric representation of a year, 4 digits

Examples: 1999 or 2003

y

A two digit representation of a year

Examples: 99 or 03

Time



a

Lower case Ante meridiem and Post meridiem

am or pm

A

Upper case Ante meridiem and Post meridiem

AM or PM

B

Swatch Internet time

000 through 999

* Not Implemented

g

12-hour format of an hour without leading zeros

1 though 12

G

24-hour format of an hour without leading zeros

0 through 23

h

12-hour format of an hour with leading zeros

01 through 12

H

24-hour format of an hour with leading zeros

00 through 23

i

Minutes with leading zeros

00 through 59

s

Seconds with leading zeros

00 through 59

u

Microseconds

Example: 54321

* Not Implemented

Timezone



e

Timezone identifier

Examples: UTC, GMT

* Not Implemented

I

Whether or not the date in in daylight saving time

1 if Daylight Saving Time, 0 otherwise

* Not Implemented

O

Difference to Greenwich time (GMT) in hours

Example: +0200

P

Difference to Greenwich time (GMT) in hours with colon between hours and minutes

Example: +02:00

* Not Implemented

T

Timezone abbreviation

Examples: EST, MDT

* Not Implemented

Z

Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east is always positive.

-43200 through 50400

Full

Date.Time



c

ISO 8601 date

Example:

2004-02-12T15:19:21+00:00

* Not Implemented

r

RFC 2822 formatted date

Example:

Thu, 21 Dec 2000 16:0107 +0200

U

Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

Example: 1185080400

is July 22 2007 00:00:00


Any character that is not one of the above format characters is printed as-is.

* Escaping a format character with a backslash so that is passes through and prints is Not Implemented


Examples:

#date:Y-m-d at H:i# would format as 2008-09-18 at 09:46

#date:g:i:s a# would format as 2:14:52 pm

#gmdate:H:i# would format as 02:14