Graph

Graph

new Graph(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.range_x function | Object

Callback function returning a Range module for x axis or an object with options for a new Range.

options.range_y function | Object

Callback function returning a Range module for y axis or an object with options for a new Range.

options.dots Array.<Object> | String [

The dots of the path. Can be a ready-to-use SVG-path-string or an array of objects like {x: x, y: y [, x1: x1, y1: y1, x2: x2, y2: y2, type: type]} (depending on the type, see options.type for more information). type is optional and defines a different type as explained under options.type for a specific dot. If omitted, the general options.type is used. It may also be a function, in which case it is called with this graph widget as first and only argument. The return value can be one of the other possible types.

options.type String <optional>
"L"

Type of the graph (needed values in dots object):

  • L: normal (needs x,y)
  • T: smooth quadratic Bézier (needs x, y)
  • H[n]: smooth horizontal, [n] = smoothing factor between 1 (square) and 5 (nearly no smoothing)
  • Q: quadratic Bézier (needs: x1, y1, x, y)
  • C: CurveTo (needs: x1, y1, x2, y2, x, y)
  • S: SmoothCurve (needs: x1, y1, x, y)
options.mode String <optional>
"line"

Drawing mode of the graph, possible values are:

  • line: line only
  • bottom: fill below the line
  • top: fill above the line
  • center: fill from the vertical center of the canvas
  • base: fill from a arbitray position on the canvas (set with base)
  • fill: close the curve using a Z directive and fill on the canvas
options.base Number <optional>
0

If mode is base set the position of the base line to fill from between 0 (bottom) and 1 (top).

options.color String <optional>
""

Set the color of the path. Better use stroke and fill via CSS.

options.key String | Boolean <optional>
false

Show a description for this graph in the charts key, false to turn it off.

Graph is a single SVG path element. It provides some functions to easily draw paths inside Charts and other derivates.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{ }

An object containing initial options.

Extends

Members

element :SVGPath

Source:

The SVG path. Has class .aux-graph

Type:
  • SVGPath

range_x :Range

Source:

The range for the x axis.

Type:

range_y :Range

Source:

The range for the y axis.

Type:

Methods

addChild(child)

Source:
Inherited From:
See:

Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.

Parameters:
Name Type Description
child Widget

The child to add.

Fires:
  • Widget#event:child_added

addChildren(a)

Source:
Inherited From:

Registers an array of widgets as children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

allChildren()

Source:
Inherited From:

Returns an array of all children.

appendChild(child)

Source:
Inherited From:

Appends child.element to the widget element and registers child as a child widget.

Parameters:
Name Type Description
child Widget

The child widget to append.

appendChildren(children)

Source:
Inherited From:

Calls Widget#appendChild for an array of widgets.

Parameters:
Name Type Description
children Array.<Widget>

The child widgets to append.

disableTansitions()

Source:
Inherited From:

Disable CSS transitions.

enableDraw()

Source:
Overrides:

Schedules this widget for drawing.

Fires:

enableDrawChildren()

Source:
Inherited From:

Enables rendering for all children of this widget.

enableTransitions()

Source:
Inherited From:

Enable CSS transitions.

forceHide()

Source:
Inherited From:

Hide the widget immediately by applying the class aux-hide. Does not call disableDraw().

forceShow()

Source:
Inherited From:

Show the widget immediately by applying the class aux-show. Does not call enableDraw().

getStyle()

Source:
Inherited From:

Returns the computed style of this widget's DOM element.

hidden()

Source:
Inherited From:

Returns the current hidden status.

hide()

Source:
Inherited From:

Hide the widget. This will result in the class aux-hide being applied to this widget in the next rendering step.

invalidate(key)

Source:
Inherited From:

Invalidates an option and triggers a redraw() call.

Parameters:
Name Type Description
key string

observeResize(cb)

Source:
Inherited From:

Calls a callback whenever the widget resizes. This method will trigger one resize.

Parameters:
Name Type Description
cb function

removeChild(child)

Source:
Inherited From:

Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.

Parameters:
Name Type Description
child Widget

The child to remove.

Fires:
  • Widget#event:child_removed

removeChildren(a)

Source:
Inherited From:

Removes an array of children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

set(key, value)

Source:
Inherited From:

Sets an option.

Parameters:
Name Type Description
key string

The option name.

value

The option value.

setStyle()

Source:
Inherited From:

Sets a CSS style property in this widget's DOM element.

show()

Source:
Inherited From:

Make the widget visible. This will apply the class aux-show during the next rendering step.

toBack()

Source:

Moves the graph to the back, i.e. add as first element to the containing SVG group element.

toFront()

Source:

Moves the graph to the front, i.e. add as last element to the containing SVG group element.

toggleHidden()

Source:
Inherited From:

Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.

transitionsDisabled()

Source:
Inherited From:

Returns true if transitions are currently disabled on this widget.

visibleChildren()

Source:
Inherited From:

Returns an array of all visible children.

Events

destroy

Source:
Inherited From:

Is fired when a widget is destroyed.

doubleclick

Source:
Inherited From:

Is fired after a double click appeared. Set dblclick to 0 to disable click event handling.

Parameters:
Name Type Description
event string

The browsers MouseEvent.

GenericDOMEvents

Source:
Inherited From:

Generic DOM events. Please refer to W3Schools for further details.

hide

Source:
Inherited From:

The hide event is emitted when a widget is hidden and is not rendered anymore. This happens both with browser visibility changes and also internally when using layout widgets such as Pager.

initialized

Source:
Inherited From:

Is fired when a widget is initialized.

redraw

Source:
Inherited From:

The redraw event is emitted when a widget is redrawn. This can be used to do additional DOM modifications to a Widget.

resize

Source:
Inherited From:

The resize event is emitted whenever a widget is being resized. This event can be used to e.g. measure its new size. Note that some widgets do internal adjustments after the resize event. If that is relevant, the Widget#resized event can be used instead.

resized

Source:
Inherited From:

The resized event is emitted after each rendering frame, which was triggered by a resize event.

set

Source:
Inherited From:

The set event is emitted when an option was set using the Widget#set method. The arguments are the option name and its new value.

Note that this happens both for user interaction and programmatical option changes.

show

Source:
Inherited From:

The show event is emitted when a widget is shown and is being rendered. This is the counterpart to Widget#hide.

visibility

Source:
Inherited From:

Is fired when the visibility state changes. The first argument is the visibility state, which is either true or false.