Fork me on GitHub

Graph API

Each graph instance exposes a number of public functions that we describe in this chapter.

Removes all traces of the DOM and removes any event listeners that were bound to the document.
Programmatically sets the focus onto the graph. Useful for keystroke events. Clicking on the graph triggers the focus.
isPluginAllowed( e, plugin )
Analyzes if the plugin takes priority over the others based on an event or on the fact that it has been programmatically prioritized.
forcePlugin( plugin )
Used to force a plugin to be prioritized. No other plugins will trigger until unforcePlugin() will be called
Removes the plugin prioritization.
elementMoving( element )
Utility that allows the mousemove event to be delegated to element. This is useful to enable dragging elements in SVG. Use false to disable the feature after your element has been moved (typically on mouse up).
getXAxis( num, createOpts ), getYAxis( num, createOpts )
Returns ( or create using createOpts ) the default x or respectively y axis of index num. The default axis position is bottom and left, respectively. If no axis exist, a bottom (left) axis will be created and returned.
get(Top|Bottom|Left|Right)Axis( num, createOpts )
Returns the axis #num on the selected side of the graph (top for getTopAxis, bottom for getBottomAxis, ...). If tha axis doesn't exist, it is created using createOpts as options.
setXAxis( axis, num )
Synonym to setBottomAxis
setYAxis( axis, num )
Synonym to setLeftAxis
set(Top|Bottom|Right|Left)Axis( axis, num )
Sets the nums top axis
setRightAxis( axis, num )
Sets the nums right axis
getPadding(Top|Bottom|Left|Right)( axis, num )
Returns the padding on the selected side of the graph (top for getPaddingTop, bottom for getPaddingBottom, ... )
setTitle( newTitle )
Changes the title of the graph and directly updates the DOM
hideTitle( )
Hides the title. Does not affect margins or paddings
showTitle( )
Shows the title ( default ). Does not affect margins or paddings
drawSerie( )
After a serie has changed or has been created, call drawSerie to update the drawing zone with the data you have entered. It does not trigger an autoAxis method.
autoscaleAxes( )
Except for the initial graph.redraw() call, no autoscaling is applied when you create a new serie or edit the data of a current serie. Call autoAxis to fit the axes minimas and maximas to the minimas and maximas of the series assigned to it. This method will automatically call a redraw() so you don't have to do it.
newSerie( name, options, type, callback )
Creates a new serie. The parameter name is required and will provide a unique identification to the serie (it however not vital internally). options will be used to personalize the serie. type (default: line) defines what serie library to use. Refer to drawing series for further details. callback is employed for development purposes. If the serie file had to be loaded asynchronously, use callback to ensure that the serie has well been created.
resetSeries( )
Removes all series from the graph.
getSeries( )
Returns all series previously created in an array.
getSeries( name|index )
Return serie at index index or which name is name
getSeries( name|index )
Return serie at index index or which name is name
drawSerie( serie )
Redraws a serie.
drawSeries( )
Redraws all series.
selectSerie( )
Selects a serie. Puts its stroke in bold
unselectSerie( )
Unselects a serie.
getSelectedSerie( )
Returns the selected serie
makeShape( shapeData, events, mute )
Creates a new shape using shapeData. events allow you to bind event handlers to this shape. mute is a development features. When true, shape creation events will not be triggered.
redrawShapes( )
Redraws all shapes, which includes repositioning and styling. Caution. using redrawShapes with a high number of shapes is not efficient.
removeShapes( )
Removes all shapes. To remove one shape only, use shape.kill().
selectShape( shape )
Selects a shape. If not locked, the user will be allowed to move and resize the shape.
unselectShape( )
Unselects any selected shape.
makeLegend( )
Creates a new legend and returns its instance.
updateLegend( )
Legend udpating is not automatic (if a serie has been removed or if its style has been modified). You need to call this method to update the current legend.
lockShapes( )
Locks all shapes.
unlockShapes( )
Undoes lockShape(). If a shape was previously locked, this method does not unlocks it.