-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathswitches.js
25 lines (22 loc) · 906 Bytes
/
switches.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as d3 from 'd3';
import * as g3 from '../g3.js';
export function toggleFactory(metric, label) {
metric = metric || 'status';
label = label || metric;
return g3.gauge()
.metric(metric)
.fake(g3.categoricalSeries([0, 1]))
.measure(d3.scaleLinear().domain([0, 1]).range([-40, 40]))
.kind('linear')
.append(
g3.put().rotate(-90).on('click', () => alert('clicked')).append(
g3.element('path', {d: 'M 40,40 a 40,40 0 0 0 0,-80 l -80,0 a 40,40 0 0 0 0,80 z'})
.class('g3-fg-stroke').style('stroke-width: 7'),
g3.axisLabels({0: 'off', 1: 'on'}).inset(60).rotate(90),
g3.gaugeLabel(label, {size: 20, y: -60}),
g3.indicatePointer().append(
g3.element('circle', {r: 30}).class('g3-fg-fill')
),
)
);
}