TK.Circular

new Circular(options)

TK.Circular is a SVG group element containing two paths for displaying numerical values in a circular manner. TK.Circular is able to draw labels, dots and markers and can show a hand. TK.Circular e.g. is implemented by TK.Clock to draw the hours, minutes and seconds.

Parameters:
Name Type Description
options Object
Properties:
Name Type Attributes Default Description
options.value number <optional>
0

The current value.

options.size number <optional>
100

The diameter of the circle.

options.thickness number <optional>
3

The thickness of the circle.

options.margin number <optional>
0

The margin between base and value circles.

options.show_hand boolean <optional>
true

Draw the hand.

options.hand Object <optional>

Dimensions of the hand.

Name Type Attributes Default Description
width number <optional>
2

Width of the hand.

length number <optional>
30

Length of the hand.

margin number <optional>
10

Margin of the hand.

options.start number <optional>
135

The starting point in degrees.

options.basis number <optional>
270

The maximum degree of the rotation if options.value === options.max.

options.base number | boolean <optional>
false

If a base value is set in degrees, circular starts drawing elements from this position.

options.show_base boolean <optional>
true

Draw the base ring.

options.show_value boolean <optional>
true

Draw the value ring.

options.x number <optional>
0

Horizontal displacement of the circle.

options.y number <optional>
0

Vertical displacement of the circle.

options.dot Object <optional>

This option acts as default values for the individual dots specified in options.dots.

Name Type Attributes Default Description
width number <optional>
2

Width of the dots.

length number <optional>
2

Length of the dots.

margin number <optional>
5

Margin of the dots.

options.dots Array <optional>
[]

An array of objects describing where dots should be placed along the circle. Members are position pos in the value range and optionally color and class and any of the properties of options.dot.

options.marker Object <optional>

This option acts as default values of the individual markers specified in options.markers.

Name Type Attributes Default Description
thickness number <optional>
3

Thickness of the marker.

margin number <optional>
3

Margin of the marker.

options.markers Array <optional>
[]

An array containing objects which describe where markers are to be places. Members are the position as from and to and optionally color, class and any of the properties of options.marker.

options.label Object <optional>

This option acts as default values for the individual labels specified in options.labels.

Name Type Attributes Default Description
margin integer <optional>
8

Distance of the label from the circle of diameter options.size.

align string <optional>
"outer"

This option controls if labels are positioned inside or outside of the circle with radius options.size/2 - margin.

format function <optional>

Optional formatting function for the label. Receives the label value as first argument.

options.labels Array <optional>
[]

An array containing objects which describe where labels are to be places. Members are the position pos in the value range and optionally color, class and any of the properties of options.label.

Mixes In:
Source:

Extends

Members

_base :SVGPath

The base of the ring. Has class toolkit-base

Source:

_dots :SVGGroup

A group containing all dots. Has class toolkit-dots

Source:

_hand :SVGRect

The hand of the knob. Has class toolkit-hand

Source:

_labels :SVGGroup

A group containing all labels. Has class toolkit-labels

Source:

_markers :SVGGroup

A group containing all markers. Has class toolkit-markers

Source:

_value :SVGPath

The ring showing the value. Has class toolkit-value

Source:

element :SVGImage

The main SVG element. Has class toolkit-circular

Source:

Methods

add_label(label)

Adds a label.

Parameters:
Name Type Description
label

The label.

Source:
Returns:

label

remove_label(label)

Removes a label.

Parameters:
Name Type Description
label

The label.

Source:
Returns:

label

Methods inherited from TK.Widget

add_child(child)

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

add_children(a)

Registers an array of widgets as children.

all_children()

Returns an array of all children.

enable_draw()

Schedules this widget for drawing.

force_hide()

This is an alias for hide, which may be overloaded. See TK.Container for an example.

force_show()

This is an alias for hide, which may be overloaded. See TK.Container for an example.

get_style()

Returns the computed style of this widgets DOM element.

hidden()

Returns the current hidden status.

hide()

Make the widget hidden. This does not modify the DOM, instead it will stop rendering this widget. Options changed after calling hide will only be rendered (i.e. applied to the DOM) when the widget is made visible again using TK.Widget#show.

remove_child(child)

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

remove_children(a)

Removes an array of children.

set(key, value)

Sets an option.

set_style()

Sets a CSS style property in this widgets DOM element.

show()

Make the widget visible. This does not modify the DOM, instead it will only schedule the widget for rendering.

toggle_hidden()

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

visible_children()

Returns an array of all visible children.

widgetize()

Set the DOM elements of this widgets. This method is usually only used internally. Basically it means to add the id from options and set a basic CSS class. If delegate is true, basic events will be delegated from the element to the widget instance if classify is true, CSS functions will be bound to the widget instance.

Methods inherited from TK.Base

add_event(event, func, prevent, stop)

Register an event handler.

add_events(events, func)

Add multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

delegate_events(element) → {HTMLElement}

Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.

destroy()

Destroys all event handlers and the options object.

fire_event(event, …args)

Fires an event.

fire_events(events)

Fires several events.

get(key)

Get the value of an option.

has_event_listeners(event) → {boolean}

Test if the event descriptor has some handler functions in the queue.

remove_event(event, func)

Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.

remove_events(events, func)

Remove multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

set_options(optionsopt)

Merges a new options object into the existing one including deep copies of objects. If an option key begins with the string "on" it is considered as event handler. In this case the value should be the handler function for the event with the corresponding name without the first "on" characters.

Events

dotsdrawn

Is fired when dots are (re)drawn.

Source:

labelsdrawn

Is fired when labels are (re)drawn.

Source:

markersdrawn

Is fired when markers are (re)drawn.

Source:

Events inherited from TK.Widget

classified

Is fired when a widget is classified.

destroy

Is fired when a widget is destroyed.

hide

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 TK.Pager.

initialized

Is fired when a widget is initialized.

redraw

Is fired when a redraw is executed.

resize

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 TK.Widget#resized event can be used, instead.

resized

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

set

The set event is emitted when an option was set using the TK.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

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

stylized

Is fired when a widget is stylized.

widgetize

Is fired when a widget is widgetized.

Events inherited from TK.Base

delegated

Is fired when an element is delegated.

set_[option]

Is fired when an option is set.