Chart

Chart class, used to define and create charts. Constructor takes container element as the first, and only, parameter.

Syntax

new Chart(el);

Parameters

Static Methods

NameDescription
None.

Static Fields

NameTypeDescripton
None.

Methods

NameDescription
add

Syntax

object.add(label, color, values [, flags])

Arguments

NameTypeDescripton
labelStringLabel of series, shown in legend.
colorStringColor the series area, line or bar will be drawn using.
valuesNumber[]Array of values making up the series.
flagsNumberOptional. Series type, overrides the default type if specified.

Return Type

void

Adds series to chart.
draw

Syntax

object.draw()

Arguments

NameTypeDescripton

Return Type

void

Draws the chart, all series should be added and all settings made before calling this.
setBarDistance

Syntax

object.setBarDistance(distance)

Arguments

NameTypeDescripton
distanceNumberDistance between bars, in pixels.

Return Type

void

Sets distance between bars for bar charts.
setBarWidth

Syntax

object.setBarWidth(width)

Arguments

NameTypeDescripton
widthNumberWidth of bars, in pixels.

Return Type

void

Sets with of bars for bar charts.
setDefaultType

Syntax

object.setDefaultType(flags)

Arguments

NameTypeDescripton
flagsNumberBitmap determining default series type

Return Type

void

Sets default series type. Flags can be one of CHART_LINE, CHART_AREA or CHART_BAR and optionally CHART_STACKED. For instance to set the default type to a line chart, CHART_LINE is specified, for a stacked area chart CHART_AREA | CHART_STACKED is used.
setGridDensity

Syntax

object.setGridDensity(x, y)

Arguments

NameTypeDescripton
xNumberNumber of grid lines and labels on the x-axis.
yNumberNumber of grid lines and labels on the y-axis.

Return Type

void

Sets grid density, the number of grid lines shown and the number of axis labels.
setHorizontalLabels

Syntax

object.setHorizontalLabels(labels)

Arguments

NameTypeDescripton
labelsString[]Array of labels.

Return Type

void

Sets the labels for the horizontal axis, number of labels specified should match the x-axis density specified with setGridDensity.
setLabelPrecision

Syntax

object.setLabelPrecision(precision)

Arguments

NameTypeDescripton
precisionNumberDesired precision in number of decimals.

Return Type

void

Sets the precision for labels on the vertical axis.
setPainterFactory

Syntax

object.setPainterFactory(fFactory)

Arguments

NameTypeDescripton
fFactoryFunctionFactory function to use, such as CanvasChartPainterFactory or SVGChartPainterFactory.

Return Type

void

Sets factory function used to create the chart painter. If not set CanvasChartPainterFactory is used.
setShowLegend

Syntax

object.setShowLegend(b)

Arguments

NameTypeDescripton
bBooleanIf true legend is shown, if false it's not.

Return Type

void

Controls whatever or not the legend should be shown. Defaults to true if not set.
setVerticalRange

Syntax

object.setVerticalRange(min, max)

Arguments

NameTypeDescripton
minNumberMinimum value.
maxNumberMaximum value.

Return Type

void

Sets the range of the vertical axis, if not set the minimum and maximum value of all series will be used.

Fields

NameTypeDescripton
None.

Events

NameDescripton
None.

Remarks

None.

Introduction
Implementation
Usage
API
Demo
SVG Demo (mozilla/opera only)
JsGraphics Demo
Download

Author: Emil A Eklund