Constructor
new Dial(container, oopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
container |
object | DOM container for the widget. | |
o |
object |
<optional> |
options. |
|
|||
|
|||
|
|||
|
|||
|
|||
|
Methods
(private) _calcArcStrokeWidth() → {number}
Calcultes the stroke width for the background and active arcs.
Returns:
- Arc stroke width;
- Type
- number
(private) _calcDialRadius() → {number}
Calculates the dial radius.
Returns:
- Radius of the dial.
- Type
- number
_calcMovePrecision()
Calculates the precision with which the state value changes when moved.
(private) _calcNeedleAngle() → {number}
Calculates the needle angle for a given state val.
Returns:
- Angle of the needle.
- Type
- number
(private) _calcNeedleCenter() → {object}
Calculates the center of the needle.
Returns:
- {x, y} object representing the needle center coordinates.
- Type
- object
(private) _calcNeedleEnd() → {object}
Calculates the position of end of the needle
Returns:
- {x, y} object representing the end of the needle.
- Type
- object
(private) _calcNeedleWidth() → {number}
Calculates the needle width.
Returns:
- The width of the needle in px.
- Type
- number
(private) _calcSvgArcPath(cx, cy, r, startAngle, endAngle) → {string}
Calculates the path for an svg arc based on cx, cy, r, startAngle, endAngle.
The input parameters are the way arcs are represented in HTML canvas.
Parameters:
| Name | Type | Description |
|---|---|---|
cx |
number | Center X. |
cy |
number | Center Y. |
r |
number | Radius. |
startAngle |
number | Start angle in radians. |
endAngle |
number | End angle in radians. |
Returns:
- A string to be used for the arc path by an SVG arc object.
- Type
- string
(private) _initHandlers()
Initializes mouse and touch event handlers.
(private) _initOptions()
Initializes the options.
(private) _initState()
Initializes state.
(private) _initStateConstraints()
Initializes state constraints.
(private) _initSvgEls()
Initializes the svg elements.
(private) _update()
Updates (redraws) components based on state.
getVal() → {number}
Returns the dial value.
Returns:
- Value of the dial.
- Type
- number
setInternalVal(newVal)
Sets the dial value.
Same as setVal(), but will not trigger observer callbacks.
Parameters:
| Name | Type | Description |
|---|---|---|
newVal |
number | The new value. |
setOptions(o)
Sets the options.
Parameters:
| Name | Type | Description |
|---|---|---|
o |
object | Options. |
setVal(newVal)
Sets the dial value.
Same as setInternalVal(), but will trigger observer callbacks.
Parameters:
| Name | Type | Description |
|---|---|---|
newVal |
number | The new value. |