A charting library.
Entry point to all things pythia. Creates and returns a pythia canvas.
pythia(domElement, options);
If domElement is undefined the body element is used.
-
size
- An array of two numbers [width, height]
-
renderer
- Either 'raphael' or 'canvas'
The canvas, charts, and primitives like paths, and rectangles are all Elements. Elements can be styled, transformed, and can listen for events.
Starting with the canvas, Elements are created within each other. Every element has methods to create element primitives that become children of the element.
Get or set the size of the element. Size is an array of two numbers
Hide element from view.
Display an element that was hidden.
Scale element by scale relative to some point. Relative can be a position or one of the following strings: 'bottom', 'top', 'center'.
Rotate element by angle r
Translate element horizontally by t[0] and vertically by t[1]
Delete all of the element's children
Add class to element. These are not HTML classes.
Remove class from element.
Select elements among children
Set up an event listener. When the call back is invoked the this keyword will refer to the element that triggered the event.
mouseover
mouseout
click
Charts are elements composed of primitive elements representing data.
- dimensions: 2
- getDimensions: { 0: function (data) { return data;}, 1: function (data, key) { return data[key]; } }
- getValue: { 0: function (data, key) { return key;}, 1: function (data, key) { return data[key]; } }
Add or update data displayed on the chart. This method invokes one of the following methods for each item in the data set.
add
remove
change
If any of these methods returns a function, the function will be invoked after all the data has been iterated over once.
- multiline: false
- stacked: false
- percent: false
- fill: false
- radius: 50
- x: 50
- y: 50
- multiline: false
- multiline: false
- stacked: false
The animate function takes a callback and a duration in milliseconds.
element.animate(callback, duration);
The callback receives a single number between 0 and 1 reflecting how much time has passed. At 0 the animation has just started. At 1 the animation should be put in its completed state.
animation_callback(time_scale);
Position and dimensions values are always an array of two numbers.
Draw an arbitrary path
Jump to position path.move(position);
Draw a line to position. path.line(position);
Complete path and fill it in. path.close();
Draw an arc around a position
path.arc(position, radius, startAngle, angle);
I'm not too happy with this implementation. The way styles work is likely to change.