-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboxplot.ts
68 lines (60 loc) · 1.69 KB
/
boxplot.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { DatasetController } from 'chart.js'
class MyType extends DatasetController {
static id = 'MyType'
static defaults = {
datasetElementType: false,
dataElementType: 'point',
dataElementOptions: [
'hitRadius',
'radius'
],
scales: {
_index_: {
type: 'category',
},
_value_: {
type: 'linear',
},
}
}
static beforeRegister() {}
static afterRegister() {}
update(mode) {
console.log('update')
const { data: points = [] } = this._cachedMeta
this.updateElements(points, 0, points.length, mode)
}
updateElements(points, start, count, mode) {
const me = this;
const reset = mode === 'reset';
const {xScale, yScale, _stacked} = me._cachedMeta;
const firstOpts = me.resolveDataElementOptions(start, mode);
const sharedOptions = me.getSharedOptions(firstOpts);
const includeOptions = me.includeOptions(mode, sharedOptions);
let prevParsed = start > 0 && me.getParsed(start - 1);
for (let i = start; i < start + count; ++i) {
const point = points[i];
const parsed = me.getParsed(i);
const x = xScale.getPixelForValue(parsed.x, i);
const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me.applyStack(yScale, parsed) : parsed.y, i);
const properties: any = {
x,
y,
skip: isNaN(x) || isNaN(y),
stop: false
};
if (includeOptions) {
properties.options = sharedOptions || me.resolveDataElementOptions(i, mode);
}
me.updateElement(point, i, properties, mode);
prevParsed = parsed;
}
me.updateSharedOptions(sharedOptions, mode, firstOpts);
}
draw() {
super.draw()
}
removeHoverStyle() {}
setHoverStyle() {}
}
export default MyType