cx 23.4.3 → 23.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.css +649 -0
- package/dist/charts.js +4811 -0
- package/dist/data.js +2109 -0
- package/dist/hooks.js +146 -0
- package/dist/manifest.js +1373 -0
- package/dist/reset.css +89 -0
- package/dist/svg.css +19 -0
- package/dist/svg.js +807 -0
- package/dist/ui.js +4456 -0
- package/dist/util.js +1538 -0
- package/dist/widgets.css +5242 -0
- package/dist/widgets.js +19417 -0
- package/package.json +1 -1
package/dist/charts.js
ADDED
|
@@ -0,0 +1,4811 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PureContainer,
|
|
3
|
+
Widget,
|
|
4
|
+
getContent,
|
|
5
|
+
Selection,
|
|
6
|
+
withHoverSync,
|
|
7
|
+
Container,
|
|
8
|
+
VDOM,
|
|
9
|
+
CSS,
|
|
10
|
+
Format as Format$1,
|
|
11
|
+
} from "cx/ui";
|
|
12
|
+
import {
|
|
13
|
+
isNumber,
|
|
14
|
+
isArray,
|
|
15
|
+
isUndefined,
|
|
16
|
+
parseStyle,
|
|
17
|
+
shallowEquals,
|
|
18
|
+
debug,
|
|
19
|
+
isDefined,
|
|
20
|
+
stopPropagation,
|
|
21
|
+
closest,
|
|
22
|
+
getTopLevelBoundingClientRect,
|
|
23
|
+
Format,
|
|
24
|
+
zeroTime,
|
|
25
|
+
} from "cx/util";
|
|
26
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
+
import {
|
|
28
|
+
tooltipMouseMove,
|
|
29
|
+
tooltipMouseLeave,
|
|
30
|
+
HtmlElement,
|
|
31
|
+
tooltipParentWillUnmount,
|
|
32
|
+
tooltipParentWillReceiveProps,
|
|
33
|
+
tooltipParentDidMount,
|
|
34
|
+
captureMouseOrTouch,
|
|
35
|
+
getCursorPos,
|
|
36
|
+
} from "cx/widgets";
|
|
37
|
+
|
|
38
|
+
function ownKeys(object, enumerableOnly) {
|
|
39
|
+
var keys = Object.keys(object);
|
|
40
|
+
if (Object.getOwnPropertySymbols) {
|
|
41
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
42
|
+
enumerableOnly &&
|
|
43
|
+
(symbols = symbols.filter(function (sym) {
|
|
44
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
45
|
+
})),
|
|
46
|
+
keys.push.apply(keys, symbols);
|
|
47
|
+
}
|
|
48
|
+
return keys;
|
|
49
|
+
}
|
|
50
|
+
function _objectSpread2(target) {
|
|
51
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
52
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
53
|
+
i % 2
|
|
54
|
+
? ownKeys(Object(source), !0).forEach(function (key) {
|
|
55
|
+
_defineProperty(target, key, source[key]);
|
|
56
|
+
})
|
|
57
|
+
: Object.getOwnPropertyDescriptors
|
|
58
|
+
? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source))
|
|
59
|
+
: ownKeys(Object(source)).forEach(function (key) {
|
|
60
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function _defineProperty(obj, key, value) {
|
|
66
|
+
key = _toPropertyKey(key);
|
|
67
|
+
if (key in obj) {
|
|
68
|
+
Object.defineProperty(obj, key, {
|
|
69
|
+
value: value,
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
obj[key] = value;
|
|
76
|
+
}
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
function _inheritsLoose(subClass, superClass) {
|
|
80
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
81
|
+
subClass.prototype.constructor = subClass;
|
|
82
|
+
_setPrototypeOf(subClass, superClass);
|
|
83
|
+
}
|
|
84
|
+
function _setPrototypeOf(o, p) {
|
|
85
|
+
_setPrototypeOf = Object.setPrototypeOf
|
|
86
|
+
? Object.setPrototypeOf.bind()
|
|
87
|
+
: function _setPrototypeOf(o, p) {
|
|
88
|
+
o.__proto__ = p;
|
|
89
|
+
return o;
|
|
90
|
+
};
|
|
91
|
+
return _setPrototypeOf(o, p);
|
|
92
|
+
}
|
|
93
|
+
function _toPrimitive(input, hint) {
|
|
94
|
+
if (typeof input !== "object" || input === null) return input;
|
|
95
|
+
var prim = input[Symbol.toPrimitive];
|
|
96
|
+
if (prim !== undefined) {
|
|
97
|
+
var res = prim.call(input, hint || "default");
|
|
98
|
+
if (typeof res !== "object") return res;
|
|
99
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
100
|
+
}
|
|
101
|
+
return (hint === "string" ? String : Number)(input);
|
|
102
|
+
}
|
|
103
|
+
function _toPropertyKey(arg) {
|
|
104
|
+
var key = _toPrimitive(arg, "string");
|
|
105
|
+
return typeof key === "symbol" ? key : String(key);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var Rect = /*#__PURE__*/ (function () {
|
|
109
|
+
function Rect(config) {
|
|
110
|
+
Object.assign(this, config);
|
|
111
|
+
}
|
|
112
|
+
var _proto = Rect.prototype;
|
|
113
|
+
_proto.width = function width() {
|
|
114
|
+
return this.r - this.l;
|
|
115
|
+
};
|
|
116
|
+
_proto.height = function height() {
|
|
117
|
+
return this.b - this.t;
|
|
118
|
+
};
|
|
119
|
+
_proto.valid = function valid() {
|
|
120
|
+
return this.r > this.l && this.b > this.t;
|
|
121
|
+
};
|
|
122
|
+
_proto.makeValid = function makeValid() {
|
|
123
|
+
return new Rect({
|
|
124
|
+
l: Math.min(this.l, this.r),
|
|
125
|
+
r: Math.max(this.l, this.r),
|
|
126
|
+
t: Math.min(this.t, this.b),
|
|
127
|
+
b: Math.max(this.t, this.b),
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
_proto.isEqual = function isEqual(r) {
|
|
131
|
+
if (!r || !r.isRect) return false;
|
|
132
|
+
return r.l == this.l && r.r == this.r && r.t == this.t && r.b == this.b;
|
|
133
|
+
};
|
|
134
|
+
Rect.add = function add(a, b) {
|
|
135
|
+
return new Rect({
|
|
136
|
+
l: a.l + b.l,
|
|
137
|
+
t: a.t + b.t,
|
|
138
|
+
r: a.r + b.r,
|
|
139
|
+
b: a.b + b.b,
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
Rect.multiply = function multiply(a, b) {
|
|
143
|
+
return new Rect({
|
|
144
|
+
l: a.l + (a.r - a.l) * b.l,
|
|
145
|
+
r: a.l + (a.r - a.l) * b.r,
|
|
146
|
+
t: a.t + (a.b - a.t) * b.t,
|
|
147
|
+
b: a.t + (a.b - a.t) * b.b,
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
Rect.margin = function margin(r, m) {
|
|
151
|
+
var mr = Rect.convertMargin(m);
|
|
152
|
+
return Rect.add(r, mr);
|
|
153
|
+
};
|
|
154
|
+
Rect.convertMargin = function convertMargin(m) {
|
|
155
|
+
if (!m) return new Rect();
|
|
156
|
+
if (m.isRect) return m;
|
|
157
|
+
if (isNumber(m))
|
|
158
|
+
return new Rect({
|
|
159
|
+
l: m,
|
|
160
|
+
t: m,
|
|
161
|
+
r: -m,
|
|
162
|
+
b: -m,
|
|
163
|
+
});
|
|
164
|
+
var m = Rect.convert(m);
|
|
165
|
+
m.b = -m.b;
|
|
166
|
+
m.r = -m.r;
|
|
167
|
+
return m;
|
|
168
|
+
};
|
|
169
|
+
Rect.convert = function convert(r) {
|
|
170
|
+
if (!r)
|
|
171
|
+
return new Rect({
|
|
172
|
+
l: 0,
|
|
173
|
+
r: 0,
|
|
174
|
+
t: 0,
|
|
175
|
+
b: 0,
|
|
176
|
+
});
|
|
177
|
+
if (r.isRect) return r;
|
|
178
|
+
if (typeof r === "string") r = r.split(" ");
|
|
179
|
+
if (isArray(r)) {
|
|
180
|
+
return new Rect({
|
|
181
|
+
t: parseFloat(r[0]),
|
|
182
|
+
r: parseFloat(r[1]),
|
|
183
|
+
b: parseFloat(r[2]),
|
|
184
|
+
l: parseFloat(r[3]),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return new Rect(r);
|
|
188
|
+
};
|
|
189
|
+
return Rect;
|
|
190
|
+
})();
|
|
191
|
+
Rect.prototype.isRect = true;
|
|
192
|
+
Rect.prototype.l = 0; //left;
|
|
193
|
+
Rect.prototype.r = 0; //right
|
|
194
|
+
Rect.prototype.t = 0; //top
|
|
195
|
+
Rect.prototype.b = 0; //bottom
|
|
196
|
+
|
|
197
|
+
var BoundedObject = /*#__PURE__*/ (function (_PureContainer) {
|
|
198
|
+
_inheritsLoose(BoundedObject, _PureContainer);
|
|
199
|
+
function BoundedObject() {
|
|
200
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
201
|
+
}
|
|
202
|
+
var _proto = BoundedObject.prototype;
|
|
203
|
+
_proto.declareData = function declareData() {
|
|
204
|
+
var _PureContainer$protot;
|
|
205
|
+
return (_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
206
|
+
_PureContainer$protot,
|
|
207
|
+
[
|
|
208
|
+
this,
|
|
209
|
+
{
|
|
210
|
+
anchors: undefined,
|
|
211
|
+
offset: undefined,
|
|
212
|
+
margin: undefined,
|
|
213
|
+
padding: undefined,
|
|
214
|
+
},
|
|
215
|
+
].concat(Array.prototype.slice.call(arguments))
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
219
|
+
_PureContainer.prototype.prepareData.call(this, context, instance);
|
|
220
|
+
var data = instance.data;
|
|
221
|
+
data.anchors = Rect.convert(data.anchors);
|
|
222
|
+
data.offset = Rect.convert(data.offset);
|
|
223
|
+
data.margin = Rect.convertMargin(data.margin);
|
|
224
|
+
data.padding = Rect.convertMargin(data.padding);
|
|
225
|
+
};
|
|
226
|
+
_proto.calculateBounds = function calculateBounds(context, instance) {
|
|
227
|
+
var data = instance.data;
|
|
228
|
+
return Rect.add(Rect.add(Rect.multiply(instance.parentRect, data.anchors), data.offset), data.margin);
|
|
229
|
+
};
|
|
230
|
+
_proto.prepareBounds = function prepareBounds(context, instance) {
|
|
231
|
+
var data = instance.data;
|
|
232
|
+
if (
|
|
233
|
+
instance.shouldUpdate ||
|
|
234
|
+
!instance.cached.parentRect ||
|
|
235
|
+
!instance.cached.parentRect.isEqual(context.parentRect) ||
|
|
236
|
+
!data.bounds
|
|
237
|
+
) {
|
|
238
|
+
if (!context.parentRect) throw new Error("Parent bounds were not provided through the context.");
|
|
239
|
+
instance.parentRect = context.parentRect;
|
|
240
|
+
instance.cache("parentRect", context.parentRect);
|
|
241
|
+
instance.markShouldUpdate(context);
|
|
242
|
+
data.bounds = this.calculateBounds(context, instance);
|
|
243
|
+
data.childrenBounds = Rect.add(data.bounds, data.padding);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
_proto.prepare = function prepare(context, instance) {
|
|
247
|
+
this.prepareBounds(context, instance);
|
|
248
|
+
context.push("parentRect", instance.data.childrenBounds);
|
|
249
|
+
};
|
|
250
|
+
_proto.prepareCleanup = function prepareCleanup(context, instance) {
|
|
251
|
+
context.pop("parentRect");
|
|
252
|
+
};
|
|
253
|
+
return BoundedObject;
|
|
254
|
+
})(PureContainer);
|
|
255
|
+
BoundedObject.prototype.anchors = 0;
|
|
256
|
+
BoundedObject.prototype.margin = 0;
|
|
257
|
+
BoundedObject.prototype.offset = 0;
|
|
258
|
+
BoundedObject.prototype.padding = 0;
|
|
259
|
+
BoundedObject.prototype.isPureContainer = false;
|
|
260
|
+
BoundedObject.prototype.styled = true;
|
|
261
|
+
|
|
262
|
+
var Axis = /*#__PURE__*/ (function (_BoundedObject) {
|
|
263
|
+
_inheritsLoose(Axis, _BoundedObject);
|
|
264
|
+
function Axis() {
|
|
265
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
266
|
+
}
|
|
267
|
+
var _proto = Axis.prototype;
|
|
268
|
+
_proto.init = function init() {
|
|
269
|
+
if (this.labelAnchor == "auto") this.labelAnchor = this.vertical ? (this.secondary ? "start" : "end") : "middle";
|
|
270
|
+
if (this.labelDx == "auto") this.labelDx = 0;
|
|
271
|
+
if (this.labelDy == "auto") this.labelDy = this.vertical ? "0.4em" : this.secondary ? 0 : "0.8em";
|
|
272
|
+
if (isUndefined(this.minLabelDistance))
|
|
273
|
+
this.minLabelDistance = this.vertical ? this.minLabelDistanceVertical : this.minLabelDistanceHorizontal;
|
|
274
|
+
if (this.labelLineCountDyFactor == "auto")
|
|
275
|
+
this.labelLineCountDyFactor = this.vertical ? -0.5 : this.secondary ? -1 : 0;
|
|
276
|
+
this.lineStyle = parseStyle(this.lineStyle);
|
|
277
|
+
this.tickStyle = parseStyle(this.tickStyle);
|
|
278
|
+
this.labelStyle = parseStyle(this.labelStyle);
|
|
279
|
+
_BoundedObject.prototype.init.call(this);
|
|
280
|
+
};
|
|
281
|
+
_proto.declareData = function declareData() {
|
|
282
|
+
var _BoundedObject$protot;
|
|
283
|
+
(_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
284
|
+
_BoundedObject$protot,
|
|
285
|
+
[
|
|
286
|
+
this,
|
|
287
|
+
{
|
|
288
|
+
anchors: undefined,
|
|
289
|
+
hideLabels: undefined,
|
|
290
|
+
hideLine: undefined,
|
|
291
|
+
hideTicks: undefined,
|
|
292
|
+
labelRotation: undefined,
|
|
293
|
+
labelAnchor: undefined,
|
|
294
|
+
lineStyle: undefined,
|
|
295
|
+
lineClass: undefined,
|
|
296
|
+
labelStyle: undefined,
|
|
297
|
+
labelClass: undefined,
|
|
298
|
+
tickStyle: undefined,
|
|
299
|
+
tickClass: undefined,
|
|
300
|
+
},
|
|
301
|
+
].concat(Array.prototype.slice.call(arguments))
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
_proto.report = function report(context, instance) {
|
|
305
|
+
return instance.calculator;
|
|
306
|
+
};
|
|
307
|
+
_proto.renderTicksAndLabels = function renderTicksAndLabels(context, instance, valueFormatter) {
|
|
308
|
+
var _this = this;
|
|
309
|
+
if (this.hidden) return false;
|
|
310
|
+
var data = instance.data,
|
|
311
|
+
calculator = instance.calculator;
|
|
312
|
+
var bounds = data.bounds;
|
|
313
|
+
var CSS = this.CSS,
|
|
314
|
+
baseClass = this.baseClass;
|
|
315
|
+
var size = calculator.findTickSize(this.minLabelDistance);
|
|
316
|
+
var labelClass = CSS.expand(CSS.element(baseClass, "label"), data.labelClass);
|
|
317
|
+
var offsetClass = CSS.element(baseClass, "label-offset");
|
|
318
|
+
var x1,
|
|
319
|
+
y1,
|
|
320
|
+
x2,
|
|
321
|
+
y2,
|
|
322
|
+
tickSize = this.tickSize;
|
|
323
|
+
if (this.vertical) {
|
|
324
|
+
x1 = x2 = this.secondary ? bounds.r : bounds.l;
|
|
325
|
+
y1 = bounds.b;
|
|
326
|
+
y2 = bounds.t;
|
|
327
|
+
} else {
|
|
328
|
+
x1 = bounds.l;
|
|
329
|
+
x2 = bounds.r;
|
|
330
|
+
y1 = y2 = this.secondary ? bounds.t : bounds.b;
|
|
331
|
+
}
|
|
332
|
+
var res = [null, null];
|
|
333
|
+
if (!data.hideLine) {
|
|
334
|
+
res[0] = /*#__PURE__*/ jsx(
|
|
335
|
+
"line",
|
|
336
|
+
{
|
|
337
|
+
className: CSS.expand(CSS.element(baseClass, "line"), data.lineClass),
|
|
338
|
+
style: data.lineStyle,
|
|
339
|
+
x1: x1,
|
|
340
|
+
y1: y1,
|
|
341
|
+
x2: x2,
|
|
342
|
+
y2: y2,
|
|
343
|
+
},
|
|
344
|
+
"line"
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
var t = [];
|
|
348
|
+
if (size > 0 && !data.hideLabels) {
|
|
349
|
+
var ticks = calculator.getTicks([size]);
|
|
350
|
+
ticks.forEach(function (serie, si) {
|
|
351
|
+
serie.forEach(function (v, i) {
|
|
352
|
+
var s = calculator.map(v);
|
|
353
|
+
if (_this.secondary) {
|
|
354
|
+
x1 = _this.vertical ? bounds.r : s;
|
|
355
|
+
y1 = _this.vertical ? s : bounds.t;
|
|
356
|
+
x2 = _this.vertical ? bounds.r + tickSize : s;
|
|
357
|
+
y2 = _this.vertical ? s : bounds.t - tickSize;
|
|
358
|
+
} else {
|
|
359
|
+
x1 = _this.vertical ? bounds.l : s;
|
|
360
|
+
y1 = _this.vertical ? s : bounds.b;
|
|
361
|
+
x2 = _this.vertical ? bounds.l - tickSize : s;
|
|
362
|
+
y2 = _this.vertical ? s : bounds.b + tickSize;
|
|
363
|
+
}
|
|
364
|
+
t.push("M " + x1 + " " + y1 + " L " + x2 + " " + y2);
|
|
365
|
+
var x, y;
|
|
366
|
+
if (_this.secondary) {
|
|
367
|
+
x = _this.vertical ? bounds.r + _this.labelOffset : s;
|
|
368
|
+
y = _this.vertical ? s : bounds.t - _this.labelOffset;
|
|
369
|
+
} else {
|
|
370
|
+
x = _this.vertical ? bounds.l - _this.labelOffset : s;
|
|
371
|
+
y = _this.vertical ? s : bounds.b + _this.labelOffset;
|
|
372
|
+
}
|
|
373
|
+
var transform = data.labelRotation ? "rotate(" + data.labelRotation + " " + x + " " + y + ")" : null;
|
|
374
|
+
res.push(
|
|
375
|
+
/*#__PURE__*/ jsx(
|
|
376
|
+
"text",
|
|
377
|
+
{
|
|
378
|
+
className: labelClass,
|
|
379
|
+
style: data.labelStyle,
|
|
380
|
+
x: x,
|
|
381
|
+
y: y,
|
|
382
|
+
dx: _this.labelDx,
|
|
383
|
+
textAnchor: data.labelAnchor,
|
|
384
|
+
transform: transform,
|
|
385
|
+
children: _this.wrapLines(valueFormatter(v), x, _this.labelDy, offsetClass),
|
|
386
|
+
},
|
|
387
|
+
"label-" + si + "-" + i
|
|
388
|
+
)
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
if (!data.hideTicks) {
|
|
394
|
+
res[1] = /*#__PURE__*/ jsx(
|
|
395
|
+
"path",
|
|
396
|
+
{
|
|
397
|
+
className: CSS.expand(CSS.element(baseClass, "ticks"), data.tickClass),
|
|
398
|
+
style: data.tickStyle,
|
|
399
|
+
d: t.join(" "),
|
|
400
|
+
},
|
|
401
|
+
"ticks"
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
return res;
|
|
405
|
+
};
|
|
406
|
+
_proto.wrapLines = function wrapLines(str, x, dy, offsetClass) {
|
|
407
|
+
if (!this.labelWrap || typeof str != "string")
|
|
408
|
+
return /*#__PURE__*/ jsx("tspan", {
|
|
409
|
+
x: x,
|
|
410
|
+
dy: dy,
|
|
411
|
+
children: str,
|
|
412
|
+
});
|
|
413
|
+
var parts = str.split(" ");
|
|
414
|
+
if (parts.length == 0) return null;
|
|
415
|
+
var lines = [];
|
|
416
|
+
var line = null;
|
|
417
|
+
for (var i = 0; i < parts.length; i++) {
|
|
418
|
+
if (!line) line = parts[i];
|
|
419
|
+
else if (parts[i].length + line.length < this.labelMaxLineLength) line += " " + parts[i];
|
|
420
|
+
else {
|
|
421
|
+
lines.push(line);
|
|
422
|
+
line = parts[i];
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
lines.push(line);
|
|
426
|
+
if (lines.length == 1)
|
|
427
|
+
return /*#__PURE__*/ jsx("tspan", {
|
|
428
|
+
x: x,
|
|
429
|
+
dy: dy,
|
|
430
|
+
children: str,
|
|
431
|
+
});
|
|
432
|
+
var offset = this.labelLineCountDyFactor * (lines.length - 1);
|
|
433
|
+
var result = [
|
|
434
|
+
dy != null &&
|
|
435
|
+
/*#__PURE__*/ jsx(
|
|
436
|
+
"tspan",
|
|
437
|
+
{
|
|
438
|
+
className: offsetClass,
|
|
439
|
+
dy: dy,
|
|
440
|
+
children: "_",
|
|
441
|
+
},
|
|
442
|
+
-2
|
|
443
|
+
),
|
|
444
|
+
];
|
|
445
|
+
lines.forEach(function (p, i) {
|
|
446
|
+
result.push(
|
|
447
|
+
/*#__PURE__*/ jsx(
|
|
448
|
+
"tspan",
|
|
449
|
+
{
|
|
450
|
+
dy: (i == 0 ? offset : 1) + "em",
|
|
451
|
+
x: x,
|
|
452
|
+
children: p,
|
|
453
|
+
},
|
|
454
|
+
i
|
|
455
|
+
)
|
|
456
|
+
);
|
|
457
|
+
});
|
|
458
|
+
return result;
|
|
459
|
+
};
|
|
460
|
+
_proto.prepare = function prepare(context, instance) {
|
|
461
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
462
|
+
var bounds = instance.data.bounds;
|
|
463
|
+
var _ref = !this.vertical ? [bounds.l, bounds.r] : [bounds.b, bounds.t],
|
|
464
|
+
a = _ref[0],
|
|
465
|
+
b = _ref[1];
|
|
466
|
+
instance.calculator.measure(a, b);
|
|
467
|
+
if (this.onMeasured) instance.invoke("onMeasured", instance.calculator.hash(), instance);
|
|
468
|
+
if (!instance.calculator.isSame(instance.cached.axis)) instance.markShouldUpdate(context);
|
|
469
|
+
};
|
|
470
|
+
_proto.cleanup = function cleanup(context, instance) {
|
|
471
|
+
var cached = instance.cached,
|
|
472
|
+
calculator = instance.calculator;
|
|
473
|
+
cached.axis = calculator.hash();
|
|
474
|
+
};
|
|
475
|
+
return Axis;
|
|
476
|
+
})(BoundedObject);
|
|
477
|
+
Axis.prototype.anchors = "0 1 1 0";
|
|
478
|
+
Axis.prototype.styled = true;
|
|
479
|
+
Axis.prototype.vertical = false;
|
|
480
|
+
Axis.prototype.secondary = false;
|
|
481
|
+
Axis.prototype.inverted = false;
|
|
482
|
+
Axis.prototype.hidden = false;
|
|
483
|
+
Axis.prototype.hideLabels = false;
|
|
484
|
+
Axis.prototype.hideTicks = false;
|
|
485
|
+
Axis.prototype.hideLine = false;
|
|
486
|
+
Axis.prototype.tickSize = 3;
|
|
487
|
+
Axis.prototype.minTickDistance = 25;
|
|
488
|
+
Axis.prototype.minLabelDistanceVertical = 40;
|
|
489
|
+
Axis.prototype.minLabelDistanceHorizontal = 50;
|
|
490
|
+
Axis.prototype.labelOffset = 10;
|
|
491
|
+
Axis.prototype.labelRotation = 0;
|
|
492
|
+
Axis.prototype.labelAnchor = "auto";
|
|
493
|
+
Axis.prototype.labelDx = "auto";
|
|
494
|
+
Axis.prototype.labelDy = "auto";
|
|
495
|
+
Axis.prototype.labelWrap = false;
|
|
496
|
+
Axis.prototype.labelLineCountDyFactor = "auto";
|
|
497
|
+
Axis.prototype.labelMaxLineLength = 10;
|
|
498
|
+
Axis.namespace = "ui.svg.chart.axis";
|
|
499
|
+
|
|
500
|
+
var Chart = /*#__PURE__*/ (function (_BoundedObject) {
|
|
501
|
+
_inheritsLoose(Chart, _BoundedObject);
|
|
502
|
+
function Chart() {
|
|
503
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
504
|
+
}
|
|
505
|
+
var _proto = Chart.prototype;
|
|
506
|
+
_proto.init = function init() {
|
|
507
|
+
_BoundedObject.prototype.init.call(this);
|
|
508
|
+
if (!this.axes) this.axes = {};
|
|
509
|
+
for (var axis in this.axes) {
|
|
510
|
+
this.axes[axis] = Axis.create(this.axes[axis]);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
_proto.explore = function explore(context, instance) {
|
|
514
|
+
instance.calculators = _objectSpread2({}, context.axes);
|
|
515
|
+
context.push("axes", instance.calculators);
|
|
516
|
+
instance.axes = {};
|
|
517
|
+
|
|
518
|
+
//axes need to be registered before children to be processed first
|
|
519
|
+
for (var axis in this.axes) {
|
|
520
|
+
var axisInstance = instance.getChild(context, this.axes[axis]);
|
|
521
|
+
if (axisInstance.scheduleExploreIfVisible(context)) {
|
|
522
|
+
instance.axes[axis] = axisInstance;
|
|
523
|
+
instance.calculators[axis] = this.axes[axis].report(context, axisInstance);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
527
|
+
};
|
|
528
|
+
_proto.exploreCleanup = function exploreCleanup(context, instance) {
|
|
529
|
+
context.pop("axes");
|
|
530
|
+
};
|
|
531
|
+
_proto.prepare = function prepare(context, instance) {
|
|
532
|
+
context.push("axes", instance.calculators);
|
|
533
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
534
|
+
};
|
|
535
|
+
_proto.prepareCleanup = function prepareCleanup(context, instance) {
|
|
536
|
+
context.pop("axes");
|
|
537
|
+
_BoundedObject.prototype.prepareCleanup.call(this, context, instance);
|
|
538
|
+
};
|
|
539
|
+
_proto.render = function render(context, instance, key) {
|
|
540
|
+
var axes = [];
|
|
541
|
+
for (var k in instance.axes) {
|
|
542
|
+
axes.push(getContent(instance.axes[k].render(context, key + "-axis-" + k)));
|
|
543
|
+
}
|
|
544
|
+
var result = [];
|
|
545
|
+
if (!this.axesOnTop) result.push(axes);
|
|
546
|
+
result.push(this.renderChildren(context, instance));
|
|
547
|
+
if (this.axesOnTop) result.push(axes);
|
|
548
|
+
return result;
|
|
549
|
+
};
|
|
550
|
+
return Chart;
|
|
551
|
+
})(BoundedObject);
|
|
552
|
+
Chart.prototype.anchors = "0 1 1 0";
|
|
553
|
+
Chart.prototype.styled = true;
|
|
554
|
+
Chart.prototype.isPureContainer = true;
|
|
555
|
+
Chart.prototype.axesOnTop = false;
|
|
556
|
+
Widget.alias("chart", Chart);
|
|
557
|
+
|
|
558
|
+
var PieChart = /*#__PURE__*/ (function (_BoundedObject) {
|
|
559
|
+
_inheritsLoose(PieChart, _BoundedObject);
|
|
560
|
+
function PieChart() {
|
|
561
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
562
|
+
}
|
|
563
|
+
var _proto = PieChart.prototype;
|
|
564
|
+
_proto.declareData = function declareData() {
|
|
565
|
+
var _BoundedObject$protot;
|
|
566
|
+
(_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
567
|
+
_BoundedObject$protot,
|
|
568
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
569
|
+
{
|
|
570
|
+
angle: undefined,
|
|
571
|
+
startAngle: 0,
|
|
572
|
+
clockwise: undefined,
|
|
573
|
+
},
|
|
574
|
+
])
|
|
575
|
+
);
|
|
576
|
+
};
|
|
577
|
+
_proto.explore = function explore(context, instance) {
|
|
578
|
+
if (!instance.pie) instance.pie = new PieCalculator();
|
|
579
|
+
var data = instance.data;
|
|
580
|
+
instance.pie.reset(data.angle, data.startAngle, data.clockwise);
|
|
581
|
+
context.push("pie", instance.pie);
|
|
582
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
583
|
+
};
|
|
584
|
+
_proto.exploreCleanup = function exploreCleanup(context, instance) {
|
|
585
|
+
context.pop("pie");
|
|
586
|
+
};
|
|
587
|
+
_proto.prepare = function prepare(context, instance) {
|
|
588
|
+
this.prepareBounds(context, instance);
|
|
589
|
+
var data = instance.data,
|
|
590
|
+
pie = instance.pie;
|
|
591
|
+
pie.measure(data.bounds);
|
|
592
|
+
var hash = pie.hash();
|
|
593
|
+
instance.cache("hash", hash);
|
|
594
|
+
pie.shouldUpdate = !shallowEquals(hash, instance.cached.hash);
|
|
595
|
+
if (!pie.shouldUpdate) instance.markShouldUpdate(context);
|
|
596
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
597
|
+
};
|
|
598
|
+
return PieChart;
|
|
599
|
+
})(BoundedObject);
|
|
600
|
+
PieChart.prototype.anchors = "0 1 1 0";
|
|
601
|
+
var PieCalculator = /*#__PURE__*/ (function () {
|
|
602
|
+
function PieCalculator() {}
|
|
603
|
+
var _proto2 = PieCalculator.prototype;
|
|
604
|
+
_proto2.reset = function reset(angle, startAngle, clockwise) {
|
|
605
|
+
this.angleTotal = (angle / 180) * Math.PI;
|
|
606
|
+
this.startAngle = (startAngle / 180) * Math.PI;
|
|
607
|
+
this.clockwise = clockwise;
|
|
608
|
+
this.stacks = {};
|
|
609
|
+
};
|
|
610
|
+
_proto2.acknowledge = function acknowledge(stack, value) {
|
|
611
|
+
var s = this.stacks[stack];
|
|
612
|
+
if (!s)
|
|
613
|
+
s = this.stacks[stack] = {
|
|
614
|
+
total: 0,
|
|
615
|
+
};
|
|
616
|
+
if (value > 0) s.total += value;
|
|
617
|
+
};
|
|
618
|
+
_proto2.hash = function hash() {
|
|
619
|
+
var _this = this;
|
|
620
|
+
return {
|
|
621
|
+
angleTotal: this.angleTotal,
|
|
622
|
+
startAngle: this.startAngle,
|
|
623
|
+
clockwise: this.clockwise,
|
|
624
|
+
stacks: Object.keys(this.stacks)
|
|
625
|
+
.map(function (s) {
|
|
626
|
+
return "" + _this.stacks[s].angleFactor;
|
|
627
|
+
})
|
|
628
|
+
.join(":"),
|
|
629
|
+
cx: this.cx,
|
|
630
|
+
cy: this.cy,
|
|
631
|
+
R: this.R,
|
|
632
|
+
};
|
|
633
|
+
};
|
|
634
|
+
_proto2.measure = function measure(rect) {
|
|
635
|
+
for (var s in this.stacks) {
|
|
636
|
+
var stack = this.stacks[s];
|
|
637
|
+
stack.angleFactor = stack.total > 0 ? this.angleTotal / stack.total : 0;
|
|
638
|
+
stack.lastAngle = this.startAngle;
|
|
639
|
+
}
|
|
640
|
+
this.cx = (rect.l + rect.r) / 2;
|
|
641
|
+
this.cy = (rect.t + rect.b) / 2;
|
|
642
|
+
this.R = Math.max(0, Math.min(rect.width(), rect.height())) / 2;
|
|
643
|
+
};
|
|
644
|
+
_proto2.map = function map(stack, value) {
|
|
645
|
+
var s = this.stacks[stack];
|
|
646
|
+
var angle = value * s.angleFactor;
|
|
647
|
+
var startAngle = s.lastAngle;
|
|
648
|
+
if (!this.clockwise) s.lastAngle += angle;
|
|
649
|
+
else s.lastAngle -= angle;
|
|
650
|
+
return {
|
|
651
|
+
startAngle: startAngle,
|
|
652
|
+
endAngle: s.lastAngle,
|
|
653
|
+
midAngle: (startAngle + s.lastAngle) / 2,
|
|
654
|
+
cx: this.cx,
|
|
655
|
+
cy: this.cy,
|
|
656
|
+
R: this.R,
|
|
657
|
+
};
|
|
658
|
+
};
|
|
659
|
+
return PieCalculator;
|
|
660
|
+
})();
|
|
661
|
+
function createSvgArc(x, y, r0, r, startAngle, endAngle) {
|
|
662
|
+
if (startAngle > endAngle) {
|
|
663
|
+
var s = startAngle;
|
|
664
|
+
startAngle = endAngle;
|
|
665
|
+
endAngle = s;
|
|
666
|
+
}
|
|
667
|
+
var largeArc = endAngle - startAngle <= Math.PI ? 0 : 1;
|
|
668
|
+
if (endAngle - startAngle >= 2 * Math.PI - 0.0001) endAngle = startAngle + 2 * Math.PI - 0.0001;
|
|
669
|
+
var result = [];
|
|
670
|
+
var startX, startY;
|
|
671
|
+
if (r0 > 0) {
|
|
672
|
+
startX = x + Math.cos(endAngle) * r0;
|
|
673
|
+
startY = y - Math.sin(endAngle) * r0;
|
|
674
|
+
result.push("M", startX, startY);
|
|
675
|
+
result.push("A", r0, r0, 0, largeArc, 1, x + Math.cos(startAngle) * r0, y - Math.sin(startAngle) * r0);
|
|
676
|
+
} else {
|
|
677
|
+
startX = x;
|
|
678
|
+
startY = y;
|
|
679
|
+
result.push("M", startX, startY);
|
|
680
|
+
}
|
|
681
|
+
result.push(
|
|
682
|
+
"L",
|
|
683
|
+
x + Math.cos(startAngle) * r,
|
|
684
|
+
y - Math.sin(startAngle) * r,
|
|
685
|
+
"A",
|
|
686
|
+
r,
|
|
687
|
+
r,
|
|
688
|
+
0,
|
|
689
|
+
largeArc,
|
|
690
|
+
0,
|
|
691
|
+
x + Math.cos(endAngle) * r,
|
|
692
|
+
y - Math.sin(endAngle) * r,
|
|
693
|
+
"L",
|
|
694
|
+
startX,
|
|
695
|
+
startY
|
|
696
|
+
);
|
|
697
|
+
return result.join(" ");
|
|
698
|
+
}
|
|
699
|
+
PieChart.prototype.anchors = "0 1 1 0";
|
|
700
|
+
PieChart.prototype.angle = 360;
|
|
701
|
+
Widget.alias("pie-slice");
|
|
702
|
+
var PieSlice = /*#__PURE__*/ (function (_Container) {
|
|
703
|
+
_inheritsLoose(PieSlice, _Container);
|
|
704
|
+
function PieSlice() {
|
|
705
|
+
return _Container.apply(this, arguments) || this;
|
|
706
|
+
}
|
|
707
|
+
var _proto3 = PieSlice.prototype;
|
|
708
|
+
_proto3.init = function init() {
|
|
709
|
+
this.selection = Selection.create(this.selection);
|
|
710
|
+
_Container.prototype.init.call(this);
|
|
711
|
+
};
|
|
712
|
+
_proto3.declareData = function declareData() {
|
|
713
|
+
var _Container$prototype$;
|
|
714
|
+
var selection = this.selection.configureWidget(this);
|
|
715
|
+
(_Container$prototype$ = _Container.prototype.declareData).call.apply(
|
|
716
|
+
_Container$prototype$,
|
|
717
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
718
|
+
selection,
|
|
719
|
+
{
|
|
720
|
+
active: true,
|
|
721
|
+
r0: undefined,
|
|
722
|
+
r: undefined,
|
|
723
|
+
colorIndex: undefined,
|
|
724
|
+
colorMap: undefined,
|
|
725
|
+
colorName: undefined,
|
|
726
|
+
offset: undefined,
|
|
727
|
+
value: undefined,
|
|
728
|
+
disabled: undefined,
|
|
729
|
+
innerPointRadius: undefined,
|
|
730
|
+
outerPointRadius: undefined,
|
|
731
|
+
name: undefined,
|
|
732
|
+
stack: undefined,
|
|
733
|
+
legend: undefined,
|
|
734
|
+
hoverId: undefined,
|
|
735
|
+
},
|
|
736
|
+
])
|
|
737
|
+
);
|
|
738
|
+
};
|
|
739
|
+
_proto3.prepareData = function prepareData(context, instance) {
|
|
740
|
+
var data = instance.data;
|
|
741
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
742
|
+
_Container.prototype.prepareData.call(this, context, instance);
|
|
743
|
+
};
|
|
744
|
+
_proto3.explore = function explore(context, instance) {
|
|
745
|
+
instance.pie = context.pie;
|
|
746
|
+
if (!instance.pie) throw new Error("Pie.Slice must be placed inside a Pie.");
|
|
747
|
+
var data = instance.data;
|
|
748
|
+
instance.valid = isNumber(data.value) && data.value > 0;
|
|
749
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
750
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
751
|
+
instance.hoverSync = context.hoverSync;
|
|
752
|
+
if (instance.valid && data.active) {
|
|
753
|
+
instance.pie.acknowledge(data.stack, data.value);
|
|
754
|
+
_Container.prototype.explore.call(this, context, instance);
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
_proto3.prepare = function prepare(context, instance) {
|
|
758
|
+
var _this2 = this;
|
|
759
|
+
var data = instance.data,
|
|
760
|
+
segment = instance.segment,
|
|
761
|
+
pie = instance.pie,
|
|
762
|
+
colorMap = instance.colorMap;
|
|
763
|
+
if (colorMap && data.colorName) {
|
|
764
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
765
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
766
|
+
}
|
|
767
|
+
if (instance.valid && data.active) {
|
|
768
|
+
var seg = pie.map(data.stack, data.value);
|
|
769
|
+
if (
|
|
770
|
+
!segment ||
|
|
771
|
+
instance.shouldUpdate ||
|
|
772
|
+
seg.startAngle != segment.startAngle ||
|
|
773
|
+
seg.endAngle != segment.endAngle ||
|
|
774
|
+
pie.shouldUpdate
|
|
775
|
+
) {
|
|
776
|
+
if (data.offset > 0) {
|
|
777
|
+
seg.ox = seg.cx + Math.cos(seg.midAngle) * data.offset;
|
|
778
|
+
seg.oy = seg.cy - Math.sin(seg.midAngle) * data.offset;
|
|
779
|
+
} else {
|
|
780
|
+
seg.ox = seg.cx;
|
|
781
|
+
seg.oy = seg.cy;
|
|
782
|
+
}
|
|
783
|
+
seg.radiusMultiplier = 1;
|
|
784
|
+
if (this.percentageRadius) seg.radiusMultiplier = seg.R / 100;
|
|
785
|
+
var innerR = data.innerPointRadius != null ? data.innerPointRadius : data.r0;
|
|
786
|
+
var outerR = data.outerPointRadius != null ? data.outerPointRadius : data.r;
|
|
787
|
+
var ix = seg.ox + Math.cos(seg.midAngle) * innerR * seg.radiusMultiplier;
|
|
788
|
+
var iy = seg.oy - Math.sin(seg.midAngle) * innerR * seg.radiusMultiplier;
|
|
789
|
+
var ox = seg.ox + Math.cos(seg.midAngle) * outerR * seg.radiusMultiplier;
|
|
790
|
+
var oy = seg.oy - Math.sin(seg.midAngle) * outerR * seg.radiusMultiplier;
|
|
791
|
+
instance.segment = seg;
|
|
792
|
+
instance.bounds = new Rect({
|
|
793
|
+
l: ix,
|
|
794
|
+
r: ox,
|
|
795
|
+
t: iy,
|
|
796
|
+
b: oy,
|
|
797
|
+
});
|
|
798
|
+
instance.markShouldUpdate(context);
|
|
799
|
+
}
|
|
800
|
+
context.push("parentRect", instance.bounds);
|
|
801
|
+
}
|
|
802
|
+
if (data.name && data.legend && context.addLegendEntry)
|
|
803
|
+
context.addLegendEntry(data.legend, {
|
|
804
|
+
name: data.name,
|
|
805
|
+
active: data.active,
|
|
806
|
+
colorIndex: data.colorIndex,
|
|
807
|
+
disabled: data.disabled,
|
|
808
|
+
selected: this.selection.isInstanceSelected(instance),
|
|
809
|
+
style: data.style,
|
|
810
|
+
shape: this.legendShape,
|
|
811
|
+
hoverId: data.hoverId,
|
|
812
|
+
hoverChannel: this.hoverChannel,
|
|
813
|
+
hoverSync: instance.hoverSync,
|
|
814
|
+
onClick: function onClick(e) {
|
|
815
|
+
_this2.onLegendClick(e, instance);
|
|
816
|
+
},
|
|
817
|
+
});
|
|
818
|
+
};
|
|
819
|
+
_proto3.prepareCleanup = function prepareCleanup(context, instance) {
|
|
820
|
+
if (instance.valid && instance.data.active) {
|
|
821
|
+
context.pop("parentRect");
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
_proto3.onLegendClick = function onLegendClick(e, instance) {
|
|
825
|
+
var allActions = this.legendAction == "auto";
|
|
826
|
+
var data = instance.data;
|
|
827
|
+
if (allActions || this.legendAction == "toggle") if (instance.set("active", !data.active)) return;
|
|
828
|
+
if (allActions || this.legendAction == "select") this.handleClick(e, instance);
|
|
829
|
+
};
|
|
830
|
+
_proto3.render = function render(context, instance, key) {
|
|
831
|
+
var _this3 = this;
|
|
832
|
+
var segment = instance.segment,
|
|
833
|
+
data = instance.data;
|
|
834
|
+
if (!instance.valid || !data.active) return null;
|
|
835
|
+
return withHoverSync(key, instance.hoverSync, this.hoverChannel, data.hoverId, function (_ref) {
|
|
836
|
+
var _stateMods;
|
|
837
|
+
var hover = _ref.hover,
|
|
838
|
+
_onMouseMove = _ref.onMouseMove,
|
|
839
|
+
_onMouseLeave = _ref.onMouseLeave;
|
|
840
|
+
var stateMods =
|
|
841
|
+
((_stateMods = {
|
|
842
|
+
selected: _this3.selection.isInstanceSelected(instance),
|
|
843
|
+
disabled: data.disabled,
|
|
844
|
+
selectable: !_this3.selection.isDummy,
|
|
845
|
+
}),
|
|
846
|
+
(_stateMods["color-" + data.colorIndex] = data.colorIndex != null),
|
|
847
|
+
(_stateMods.hover = hover),
|
|
848
|
+
_stateMods);
|
|
849
|
+
var d = createSvgArc(
|
|
850
|
+
segment.ox,
|
|
851
|
+
segment.oy,
|
|
852
|
+
data.r0 * segment.radiusMultiplier,
|
|
853
|
+
data.r * segment.radiusMultiplier,
|
|
854
|
+
segment.startAngle,
|
|
855
|
+
segment.endAngle
|
|
856
|
+
);
|
|
857
|
+
return /*#__PURE__*/ jsxs(
|
|
858
|
+
"g",
|
|
859
|
+
{
|
|
860
|
+
className: data.classNames,
|
|
861
|
+
children: [
|
|
862
|
+
/*#__PURE__*/ jsx("path", {
|
|
863
|
+
className: _this3.CSS.element(_this3.baseClass, "slice", stateMods),
|
|
864
|
+
style: data.style,
|
|
865
|
+
d: d,
|
|
866
|
+
onMouseMove: function onMouseMove(e) {
|
|
867
|
+
_onMouseMove(e, instance);
|
|
868
|
+
tooltipMouseMove(e, instance, _this3.tooltip);
|
|
869
|
+
},
|
|
870
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
871
|
+
_onMouseLeave(e, instance);
|
|
872
|
+
tooltipMouseLeave(e, instance, _this3.tooltip);
|
|
873
|
+
},
|
|
874
|
+
onClick: function onClick(e) {
|
|
875
|
+
_this3.handleClick(e, instance);
|
|
876
|
+
},
|
|
877
|
+
}),
|
|
878
|
+
_this3.renderChildren(context, instance),
|
|
879
|
+
],
|
|
880
|
+
},
|
|
881
|
+
key
|
|
882
|
+
);
|
|
883
|
+
});
|
|
884
|
+
};
|
|
885
|
+
_proto3.handleClick = function handleClick(e, instance) {
|
|
886
|
+
if (!this.selection.isDummy) {
|
|
887
|
+
this.selection.selectInstance(instance, {
|
|
888
|
+
toggle: e.ctrlKey,
|
|
889
|
+
});
|
|
890
|
+
e.stopPropagation();
|
|
891
|
+
e.preventDefault();
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
return PieSlice;
|
|
895
|
+
})(Container);
|
|
896
|
+
PieSlice.prototype.offset = 0;
|
|
897
|
+
PieSlice.prototype.r0 = 0;
|
|
898
|
+
PieSlice.prototype.r = 50;
|
|
899
|
+
PieSlice.prototype.percentageRadius = true;
|
|
900
|
+
PieSlice.prototype.baseClass = "pieslice";
|
|
901
|
+
PieSlice.prototype.legend = "legend";
|
|
902
|
+
PieSlice.prototype.active = true;
|
|
903
|
+
PieSlice.prototype.stack = "stack";
|
|
904
|
+
PieSlice.prototype.legendAction = "auto";
|
|
905
|
+
PieSlice.prototype.legendShape = "rect";
|
|
906
|
+
PieSlice.prototype.hoverChannel = "default";
|
|
907
|
+
PieSlice.prototype.styled = true;
|
|
908
|
+
Widget.alias("pie-chart", PieChart);
|
|
909
|
+
|
|
910
|
+
debug("The Pie class is deprecated. Please use PieChart instead.");
|
|
911
|
+
var Pie = PieChart;
|
|
912
|
+
Pie.Slice = PieSlice;
|
|
913
|
+
|
|
914
|
+
var PieLabel = /*#__PURE__*/ (function (_BoundedObject) {
|
|
915
|
+
_inheritsLoose(PieLabel, _BoundedObject);
|
|
916
|
+
function PieLabel() {
|
|
917
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
918
|
+
}
|
|
919
|
+
var _proto = PieLabel.prototype;
|
|
920
|
+
_proto.init = function init() {
|
|
921
|
+
this.lineStyle = parseStyle(this.lineStyle);
|
|
922
|
+
_BoundedObject.prototype.init.call(this);
|
|
923
|
+
};
|
|
924
|
+
_proto.declareData = function declareData() {
|
|
925
|
+
var _BoundedObject$protot;
|
|
926
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
927
|
+
args[_key] = arguments[_key];
|
|
928
|
+
}
|
|
929
|
+
(_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
930
|
+
_BoundedObject$protot,
|
|
931
|
+
[this].concat(args, [
|
|
932
|
+
{
|
|
933
|
+
distance: undefined,
|
|
934
|
+
lineStyle: {
|
|
935
|
+
structured: true,
|
|
936
|
+
},
|
|
937
|
+
lineStroke: undefined,
|
|
938
|
+
lineClass: {
|
|
939
|
+
structured: true,
|
|
940
|
+
},
|
|
941
|
+
lineColorIndex: undefined,
|
|
942
|
+
},
|
|
943
|
+
])
|
|
944
|
+
);
|
|
945
|
+
};
|
|
946
|
+
_proto.calculateBounds = function calculateBounds(context, instance) {
|
|
947
|
+
var data = instance.data;
|
|
948
|
+
var bounds = Rect.add(Rect.add(Rect.multiply(instance.parentRect, data.anchors), data.offset), data.margin);
|
|
949
|
+
instance.originalBounds = bounds;
|
|
950
|
+
instance.actualBounds = context.placePieLabel(bounds, data.distance);
|
|
951
|
+
return new Rect({
|
|
952
|
+
t: 0,
|
|
953
|
+
r: bounds.width(),
|
|
954
|
+
b: bounds.height(),
|
|
955
|
+
l: 0,
|
|
956
|
+
});
|
|
957
|
+
};
|
|
958
|
+
_proto.prepare = function prepare(context, instance) {
|
|
959
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
960
|
+
if (!context.registerPieLabel)
|
|
961
|
+
throw new Error("PieLabel components are allowed only within PieLabelsContainer components.");
|
|
962
|
+
context.registerPieLabel(instance);
|
|
963
|
+
};
|
|
964
|
+
_proto.render = function render(context, instance, key) {
|
|
965
|
+
var originalBounds = instance.originalBounds,
|
|
966
|
+
actualBounds = instance.actualBounds,
|
|
967
|
+
data = instance.data;
|
|
968
|
+
return /*#__PURE__*/ jsxs(
|
|
969
|
+
"g",
|
|
970
|
+
{
|
|
971
|
+
className: data.classNames,
|
|
972
|
+
children: [
|
|
973
|
+
/*#__PURE__*/ jsx("line", {
|
|
974
|
+
className: this.CSS.element(
|
|
975
|
+
this.baseClass,
|
|
976
|
+
"line",
|
|
977
|
+
data.lineColorIndex != null && "color-" + data.lineColorIndex
|
|
978
|
+
),
|
|
979
|
+
x1: actualBounds.l < originalBounds.l ? actualBounds.r : actualBounds.l,
|
|
980
|
+
y1: (actualBounds.t + actualBounds.b) / 2,
|
|
981
|
+
x2: (originalBounds.l + originalBounds.r) / 2,
|
|
982
|
+
y2: (originalBounds.t + originalBounds.b) / 2,
|
|
983
|
+
stroke: data.lineStroke,
|
|
984
|
+
style: data.lineStyle,
|
|
985
|
+
}),
|
|
986
|
+
/*#__PURE__*/ jsx("g", {
|
|
987
|
+
transform: "translate(" + instance.actualBounds.l + " " + instance.actualBounds.t + ")",
|
|
988
|
+
children: this.renderChildren(context, instance),
|
|
989
|
+
}),
|
|
990
|
+
],
|
|
991
|
+
},
|
|
992
|
+
key
|
|
993
|
+
);
|
|
994
|
+
};
|
|
995
|
+
return PieLabel;
|
|
996
|
+
})(BoundedObject);
|
|
997
|
+
PieLabel.prototype.distance = 100;
|
|
998
|
+
PieLabel.prototype.baseClass = "pielabel";
|
|
999
|
+
PieLabel.prototype.styled = true;
|
|
1000
|
+
|
|
1001
|
+
var PieLabelsContainer = /*#__PURE__*/ (function (_BoundedObject) {
|
|
1002
|
+
_inheritsLoose(PieLabelsContainer, _BoundedObject);
|
|
1003
|
+
function PieLabelsContainer() {
|
|
1004
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
1005
|
+
}
|
|
1006
|
+
var _proto = PieLabelsContainer.prototype;
|
|
1007
|
+
_proto.prepare = function prepare(context, instance) {
|
|
1008
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
1009
|
+
var bounds = instance.data.bounds;
|
|
1010
|
+
var cx2 = bounds.l + bounds.r;
|
|
1011
|
+
context.push("placePieLabel", function (labelBounds, distance) {
|
|
1012
|
+
var clone = new Rect(labelBounds);
|
|
1013
|
+
var w = clone.r - clone.l;
|
|
1014
|
+
if (clone.l + clone.r > cx2) {
|
|
1015
|
+
clone.r = Math.min(clone.r + distance, bounds.r);
|
|
1016
|
+
clone.l = clone.r - w;
|
|
1017
|
+
} else {
|
|
1018
|
+
clone.l = Math.max(bounds.l, clone.l - distance);
|
|
1019
|
+
clone.r = clone.l + w;
|
|
1020
|
+
}
|
|
1021
|
+
return clone;
|
|
1022
|
+
});
|
|
1023
|
+
instance.leftLabels = [];
|
|
1024
|
+
instance.rightLabels = [];
|
|
1025
|
+
context.push("registerPieLabel", function (label) {
|
|
1026
|
+
if (label.actualBounds.l + label.actualBounds.r < cx2) instance.leftLabels.push(label);
|
|
1027
|
+
else instance.rightLabels.push(label);
|
|
1028
|
+
});
|
|
1029
|
+
};
|
|
1030
|
+
_proto.prepareCleanup = function prepareCleanup(context, instance) {
|
|
1031
|
+
context.pop("placePieLabel");
|
|
1032
|
+
context.pop("registerPieLabel");
|
|
1033
|
+
_BoundedObject.prototype.prepareCleanup.call(this, context, instance);
|
|
1034
|
+
this.distributeLabels(instance.leftLabels, instance);
|
|
1035
|
+
this.distributeLabels(instance.rightLabels, instance);
|
|
1036
|
+
};
|
|
1037
|
+
_proto.distributeLabels = function distributeLabels(labels, instance) {
|
|
1038
|
+
labels.sort(function (a, b) {
|
|
1039
|
+
return a.actualBounds.t + a.actualBounds.b - (b.actualBounds.t + b.actualBounds.b);
|
|
1040
|
+
});
|
|
1041
|
+
var totalHeight = labels.reduce(function (h, l) {
|
|
1042
|
+
return h + l.actualBounds.height();
|
|
1043
|
+
}, 0);
|
|
1044
|
+
var bounds = instance.data.bounds;
|
|
1045
|
+
var avgHeight = Math.min(totalHeight, bounds.height()) / labels.length;
|
|
1046
|
+
var at = bounds.t;
|
|
1047
|
+
for (var i = 0; i < labels.length; i++) {
|
|
1048
|
+
var ab = labels[i].actualBounds;
|
|
1049
|
+
ab.t = Math.max(at, Math.min(ab.t, bounds.b - (labels.length - i) * avgHeight));
|
|
1050
|
+
ab.b = ab.t + avgHeight;
|
|
1051
|
+
at = ab.b;
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
return PieLabelsContainer;
|
|
1055
|
+
})(BoundedObject);
|
|
1056
|
+
PieLabelsContainer.prototype.anchors = "0 1 1 0";
|
|
1057
|
+
|
|
1058
|
+
var ColumnBarBase = /*#__PURE__*/ (function (_PureContainer) {
|
|
1059
|
+
_inheritsLoose(ColumnBarBase, _PureContainer);
|
|
1060
|
+
function ColumnBarBase() {
|
|
1061
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
1062
|
+
}
|
|
1063
|
+
var _proto = ColumnBarBase.prototype;
|
|
1064
|
+
_proto.init = function init() {
|
|
1065
|
+
this.selection = Selection.create(this.selection);
|
|
1066
|
+
_PureContainer.prototype.init.call(this);
|
|
1067
|
+
};
|
|
1068
|
+
_proto.declareData = function declareData() {
|
|
1069
|
+
var _PureContainer$protot;
|
|
1070
|
+
var selection = this.selection.configureWidget(this);
|
|
1071
|
+
return (_PureContainer$protot = _PureContainer.prototype.declareData).call.apply(
|
|
1072
|
+
_PureContainer$protot,
|
|
1073
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
1074
|
+
selection,
|
|
1075
|
+
{
|
|
1076
|
+
x: undefined,
|
|
1077
|
+
y: undefined,
|
|
1078
|
+
style: {
|
|
1079
|
+
structured: true,
|
|
1080
|
+
},
|
|
1081
|
+
class: {
|
|
1082
|
+
structured: true,
|
|
1083
|
+
},
|
|
1084
|
+
className: {
|
|
1085
|
+
structured: true,
|
|
1086
|
+
},
|
|
1087
|
+
disabled: undefined,
|
|
1088
|
+
colorIndex: undefined,
|
|
1089
|
+
colorMap: undefined,
|
|
1090
|
+
colorName: undefined,
|
|
1091
|
+
name: undefined,
|
|
1092
|
+
active: true,
|
|
1093
|
+
stacked: undefined,
|
|
1094
|
+
stack: undefined,
|
|
1095
|
+
offset: undefined,
|
|
1096
|
+
hoverId: undefined,
|
|
1097
|
+
},
|
|
1098
|
+
])
|
|
1099
|
+
);
|
|
1100
|
+
};
|
|
1101
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
1102
|
+
instance.axes = context.axes;
|
|
1103
|
+
instance.xAxis = context.axes[this.xAxis];
|
|
1104
|
+
instance.yAxis = context.axes[this.yAxis];
|
|
1105
|
+
instance.hoverSync = context.hoverSync;
|
|
1106
|
+
var data = instance.data;
|
|
1107
|
+
data.valid = this.checkValid(data);
|
|
1108
|
+
if (!data.colorName && data.name) data.colorName = data.name;
|
|
1109
|
+
_PureContainer.prototype.prepareData.call(this, context, instance);
|
|
1110
|
+
};
|
|
1111
|
+
_proto.checkValid = function checkValid(data) {
|
|
1112
|
+
return true;
|
|
1113
|
+
};
|
|
1114
|
+
_proto.prepare = function prepare(context, instance) {
|
|
1115
|
+
var _this = this;
|
|
1116
|
+
var data = instance.data,
|
|
1117
|
+
colorMap = instance.colorMap;
|
|
1118
|
+
if (colorMap && data.colorName) {
|
|
1119
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
1120
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
1121
|
+
}
|
|
1122
|
+
if (!data.valid) return;
|
|
1123
|
+
if (data.active) {
|
|
1124
|
+
instance.bounds = this.calculateRect(instance);
|
|
1125
|
+
instance.cache("bounds", instance.bounds);
|
|
1126
|
+
if (!instance.bounds.isEqual(instance.cached.bounds)) instance.markShouldUpdate(context);
|
|
1127
|
+
context.push("parentRect", instance.bounds);
|
|
1128
|
+
if (instance.xAxis.shouldUpdate || instance.yAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
1129
|
+
}
|
|
1130
|
+
if (data.name && context.addLegendEntry)
|
|
1131
|
+
context.addLegendEntry(this.legend, {
|
|
1132
|
+
name: data.name,
|
|
1133
|
+
active: data.active,
|
|
1134
|
+
colorIndex: data.colorIndex,
|
|
1135
|
+
disabled: data.disabled,
|
|
1136
|
+
selected: this.selection.isInstanceSelected(instance),
|
|
1137
|
+
style: data.style,
|
|
1138
|
+
shape: this.legendShape,
|
|
1139
|
+
onClick: function onClick(e) {
|
|
1140
|
+
_this.onLegendClick(e, instance);
|
|
1141
|
+
},
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1144
|
+
_proto.prepareCleanup = function prepareCleanup(context, instance) {
|
|
1145
|
+
var data = instance.data;
|
|
1146
|
+
if (data.valid && data.active) context.pop("parentRect");
|
|
1147
|
+
};
|
|
1148
|
+
_proto.onLegendClick = function onLegendClick(e, instance) {
|
|
1149
|
+
var allActions = this.legendAction == "auto";
|
|
1150
|
+
var data = instance.data;
|
|
1151
|
+
if (allActions || this.legendAction == "toggle") if (instance.set("active", !data.active)) return;
|
|
1152
|
+
if (allActions || this.legendAction == "select") this.handleClick(e, instance);
|
|
1153
|
+
};
|
|
1154
|
+
_proto.calculateRect = function calculateRect(context, instance) {
|
|
1155
|
+
throw new Error("Abstract method.");
|
|
1156
|
+
};
|
|
1157
|
+
_proto.render = function render(context, instance, key) {
|
|
1158
|
+
var _this2 = this;
|
|
1159
|
+
var data = instance.data,
|
|
1160
|
+
bounds = instance.bounds;
|
|
1161
|
+
if (!data.active || !data.valid) return null;
|
|
1162
|
+
return withHoverSync(key, instance.hoverSync, this.hoverChannel, data.hoverId, function (_ref) {
|
|
1163
|
+
var _stateMods;
|
|
1164
|
+
var hover = _ref.hover,
|
|
1165
|
+
_onMouseMove = _ref.onMouseMove,
|
|
1166
|
+
_onMouseLeave = _ref.onMouseLeave,
|
|
1167
|
+
key = _ref.key;
|
|
1168
|
+
var stateMods =
|
|
1169
|
+
((_stateMods = {
|
|
1170
|
+
selected: _this2.selection.isInstanceSelected(instance),
|
|
1171
|
+
disabled: data.disabled,
|
|
1172
|
+
selectable: !_this2.selection.isDummy,
|
|
1173
|
+
}),
|
|
1174
|
+
(_stateMods["color-" + data.colorIndex] = data.colorIndex != null),
|
|
1175
|
+
(_stateMods.hover = hover),
|
|
1176
|
+
_stateMods);
|
|
1177
|
+
return /*#__PURE__*/ jsxs(
|
|
1178
|
+
"g",
|
|
1179
|
+
{
|
|
1180
|
+
className: data.classNames,
|
|
1181
|
+
children: [
|
|
1182
|
+
/*#__PURE__*/ jsx("rect", {
|
|
1183
|
+
className: _this2.CSS.element(_this2.baseClass, "rect", stateMods),
|
|
1184
|
+
style: data.style,
|
|
1185
|
+
x: bounds.l,
|
|
1186
|
+
y: bounds.t,
|
|
1187
|
+
width: Math.max(0.0001, bounds.width()),
|
|
1188
|
+
height: Math.max(0.0001, bounds.height()),
|
|
1189
|
+
onMouseMove: function onMouseMove(e) {
|
|
1190
|
+
_onMouseMove(e, instance);
|
|
1191
|
+
tooltipMouseMove(e, instance, _this2.tooltip);
|
|
1192
|
+
},
|
|
1193
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
1194
|
+
_onMouseLeave(e, instance);
|
|
1195
|
+
tooltipMouseLeave(e, instance, _this2.tooltip);
|
|
1196
|
+
},
|
|
1197
|
+
onClick: function onClick(e) {
|
|
1198
|
+
_this2.handleClick(e, instance);
|
|
1199
|
+
},
|
|
1200
|
+
}),
|
|
1201
|
+
_this2.renderChildren(context, instance),
|
|
1202
|
+
],
|
|
1203
|
+
},
|
|
1204
|
+
key
|
|
1205
|
+
);
|
|
1206
|
+
});
|
|
1207
|
+
};
|
|
1208
|
+
_proto.handleClick = function handleClick(e, instance) {
|
|
1209
|
+
if (!this.selection.isDummy) {
|
|
1210
|
+
this.selection.selectInstance(instance, {
|
|
1211
|
+
toggle: e.ctrlKey,
|
|
1212
|
+
});
|
|
1213
|
+
e.stopPropagation();
|
|
1214
|
+
e.preventDefault();
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
return ColumnBarBase;
|
|
1218
|
+
})(PureContainer);
|
|
1219
|
+
ColumnBarBase.prototype.xAxis = "x";
|
|
1220
|
+
ColumnBarBase.prototype.yAxis = "y";
|
|
1221
|
+
ColumnBarBase.prototype.offset = 0;
|
|
1222
|
+
ColumnBarBase.prototype.legend = "legend";
|
|
1223
|
+
ColumnBarBase.prototype.legendAction = "auto";
|
|
1224
|
+
ColumnBarBase.prototype.active = true;
|
|
1225
|
+
ColumnBarBase.prototype.stacked = false;
|
|
1226
|
+
ColumnBarBase.prototype.stack = "stack";
|
|
1227
|
+
ColumnBarBase.prototype.legendShape = "rect";
|
|
1228
|
+
ColumnBarBase.prototype.styled = true;
|
|
1229
|
+
ColumnBarBase.prototype.hoverChannel = "default";
|
|
1230
|
+
|
|
1231
|
+
var Column = /*#__PURE__*/ (function (_ColumnBarBase) {
|
|
1232
|
+
_inheritsLoose(Column, _ColumnBarBase);
|
|
1233
|
+
function Column() {
|
|
1234
|
+
return _ColumnBarBase.apply(this, arguments) || this;
|
|
1235
|
+
}
|
|
1236
|
+
var _proto = Column.prototype;
|
|
1237
|
+
_proto.init = function init() {
|
|
1238
|
+
if (isDefined(this.width)) this.size = this.width;
|
|
1239
|
+
_ColumnBarBase.prototype.init.call(this);
|
|
1240
|
+
};
|
|
1241
|
+
_proto.declareData = function declareData() {
|
|
1242
|
+
var _ColumnBarBase$protot;
|
|
1243
|
+
return (_ColumnBarBase$protot = _ColumnBarBase.prototype.declareData).call.apply(
|
|
1244
|
+
_ColumnBarBase$protot,
|
|
1245
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
1246
|
+
{
|
|
1247
|
+
y0: undefined,
|
|
1248
|
+
size: undefined,
|
|
1249
|
+
autoSize: undefined,
|
|
1250
|
+
},
|
|
1251
|
+
])
|
|
1252
|
+
);
|
|
1253
|
+
};
|
|
1254
|
+
_proto.checkValid = function checkValid(data) {
|
|
1255
|
+
return data.x != null && data.y != null && data.y0 != null;
|
|
1256
|
+
};
|
|
1257
|
+
_proto.explore = function explore(context, instance) {
|
|
1258
|
+
var data = instance.data,
|
|
1259
|
+
xAxis = instance.xAxis,
|
|
1260
|
+
yAxis = instance.yAxis;
|
|
1261
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
1262
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
1263
|
+
if (!data.valid) return;
|
|
1264
|
+
if (data.active) {
|
|
1265
|
+
xAxis.acknowledge(data.x, data.size, data.offset);
|
|
1266
|
+
if (data.autoSize) xAxis.book(data.x, data.stacked ? data.stack : data.name);
|
|
1267
|
+
if (data.stacked) {
|
|
1268
|
+
yAxis.stacknowledge(data.stack, data.x, data.y0);
|
|
1269
|
+
yAxis.stacknowledge(data.stack, data.x, data.y);
|
|
1270
|
+
} else {
|
|
1271
|
+
if (!this.hiddenBase) yAxis.acknowledge(data.y0);
|
|
1272
|
+
yAxis.acknowledge(data.y);
|
|
1273
|
+
}
|
|
1274
|
+
_ColumnBarBase.prototype.explore.call(this, context, instance);
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
_proto.calculateRect = function calculateRect(instance) {
|
|
1278
|
+
var data = instance.data;
|
|
1279
|
+
var offset = data.offset,
|
|
1280
|
+
size = data.size;
|
|
1281
|
+
if (data.autoSize) {
|
|
1282
|
+
var _instance$xAxis$locat = instance.xAxis.locate(data.x, data.stacked ? data.stack : data.name),
|
|
1283
|
+
index = _instance$xAxis$locat[0],
|
|
1284
|
+
count = _instance$xAxis$locat[1];
|
|
1285
|
+
offset = (size / count) * (index - count / 2 + 0.5);
|
|
1286
|
+
size = size / count;
|
|
1287
|
+
}
|
|
1288
|
+
var x1 = instance.xAxis.map(data.x, offset - size / 2);
|
|
1289
|
+
var x2 = instance.xAxis.map(data.x, offset + size / 2);
|
|
1290
|
+
var y1 = data.stacked ? instance.yAxis.stack(data.stack, data.x, data.y0) : instance.yAxis.map(data.y0);
|
|
1291
|
+
var y2 = data.stacked ? instance.yAxis.stack(data.stack, data.x, data.y) : instance.yAxis.map(data.y);
|
|
1292
|
+
if (Math.abs(y2 - y1) < this.minPixelHeight) {
|
|
1293
|
+
if (y1 <= y2) y2 = y1 + this.minPixelHeight;
|
|
1294
|
+
else y2 = y1 - this.minPixelHeight;
|
|
1295
|
+
}
|
|
1296
|
+
var bounds = new Rect({
|
|
1297
|
+
l: Math.min(x1, x2),
|
|
1298
|
+
r: Math.max(x1, x2),
|
|
1299
|
+
t: Math.min(y1, y2),
|
|
1300
|
+
b: Math.max(y1, y2),
|
|
1301
|
+
});
|
|
1302
|
+
return bounds;
|
|
1303
|
+
};
|
|
1304
|
+
return Column;
|
|
1305
|
+
})(ColumnBarBase);
|
|
1306
|
+
Column.prototype.baseClass = "column";
|
|
1307
|
+
Column.prototype.y0 = 0;
|
|
1308
|
+
Column.prototype.size = 1;
|
|
1309
|
+
Column.prototype.autoSize = false;
|
|
1310
|
+
Column.prototype.legendShape = "column";
|
|
1311
|
+
Column.prototype.hiddenBase = false;
|
|
1312
|
+
Column.prototype.minPixelHeight = 0.5;
|
|
1313
|
+
Widget.alias("column", Column);
|
|
1314
|
+
|
|
1315
|
+
var Bar = /*#__PURE__*/ (function (_ColumnBarBase) {
|
|
1316
|
+
_inheritsLoose(Bar, _ColumnBarBase);
|
|
1317
|
+
function Bar() {
|
|
1318
|
+
return _ColumnBarBase.apply(this, arguments) || this;
|
|
1319
|
+
}
|
|
1320
|
+
var _proto = Bar.prototype;
|
|
1321
|
+
_proto.init = function init() {
|
|
1322
|
+
if (isDefined(this.height)) this.size = this.height;
|
|
1323
|
+
_ColumnBarBase.prototype.init.call(this);
|
|
1324
|
+
};
|
|
1325
|
+
_proto.declareData = function declareData() {
|
|
1326
|
+
var _ColumnBarBase$protot;
|
|
1327
|
+
return (_ColumnBarBase$protot = _ColumnBarBase.prototype.declareData).call.apply(
|
|
1328
|
+
_ColumnBarBase$protot,
|
|
1329
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
1330
|
+
{
|
|
1331
|
+
x0: undefined,
|
|
1332
|
+
size: undefined,
|
|
1333
|
+
autoSize: undefined,
|
|
1334
|
+
},
|
|
1335
|
+
])
|
|
1336
|
+
);
|
|
1337
|
+
};
|
|
1338
|
+
_proto.checkValid = function checkValid(data) {
|
|
1339
|
+
return data.y != null && data.x != null && data.x0 != null;
|
|
1340
|
+
};
|
|
1341
|
+
_proto.explore = function explore(context, instance) {
|
|
1342
|
+
var data = instance.data,
|
|
1343
|
+
xAxis = instance.xAxis,
|
|
1344
|
+
yAxis = instance.yAxis;
|
|
1345
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
1346
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
1347
|
+
if (!data.valid) return;
|
|
1348
|
+
if (data.active) {
|
|
1349
|
+
yAxis.acknowledge(data.y, data.size, data.offset);
|
|
1350
|
+
if (data.autoSize) yAxis.book(data.y, data.stacked ? data.stack : data.name);
|
|
1351
|
+
if (data.stacked) {
|
|
1352
|
+
xAxis.stacknowledge(data.stack, data.y, data.x0);
|
|
1353
|
+
xAxis.stacknowledge(data.stack, data.y, data.x);
|
|
1354
|
+
} else {
|
|
1355
|
+
if (!this.hiddenBase) xAxis.acknowledge(data.x0);
|
|
1356
|
+
xAxis.acknowledge(data.x);
|
|
1357
|
+
}
|
|
1358
|
+
_ColumnBarBase.prototype.explore.call(this, context, instance);
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
_proto.calculateRect = function calculateRect(instance) {
|
|
1362
|
+
var data = instance.data;
|
|
1363
|
+
var offset = data.offset,
|
|
1364
|
+
size = data.size;
|
|
1365
|
+
if (data.autoSize) {
|
|
1366
|
+
var _instance$yAxis$locat = instance.yAxis.locate(data.y, data.stacked ? data.stack : data.name),
|
|
1367
|
+
index = _instance$yAxis$locat[0],
|
|
1368
|
+
count = _instance$yAxis$locat[1];
|
|
1369
|
+
offset = (size / count) * (index - count / 2 + 0.5);
|
|
1370
|
+
size = size / count;
|
|
1371
|
+
}
|
|
1372
|
+
var x1 = data.stacked ? instance.xAxis.stack(data.stack, data.y, data.x0) : instance.xAxis.map(data.x0);
|
|
1373
|
+
var x2 = data.stacked ? instance.xAxis.stack(data.stack, data.y, data.x) : instance.xAxis.map(data.x);
|
|
1374
|
+
var y1 = instance.yAxis.map(data.y, offset - size / 2);
|
|
1375
|
+
var y2 = instance.yAxis.map(data.y, offset + size / 2);
|
|
1376
|
+
var bounds = new Rect({
|
|
1377
|
+
l: Math.min(x1, x2),
|
|
1378
|
+
r: Math.max(x1, x2),
|
|
1379
|
+
t: Math.min(y1, y2),
|
|
1380
|
+
b: Math.max(y1, y2),
|
|
1381
|
+
});
|
|
1382
|
+
return bounds;
|
|
1383
|
+
};
|
|
1384
|
+
return Bar;
|
|
1385
|
+
})(ColumnBarBase);
|
|
1386
|
+
Bar.prototype.baseClass = "bar";
|
|
1387
|
+
Bar.prototype.x0 = 0;
|
|
1388
|
+
Bar.prototype.size = 1;
|
|
1389
|
+
Bar.prototype.autoSize = false;
|
|
1390
|
+
Bar.prototype.legendShape = "bar";
|
|
1391
|
+
Bar.prototype.hiddenBase = false;
|
|
1392
|
+
Widget.alias("bar", Bar);
|
|
1393
|
+
|
|
1394
|
+
var shapes = {};
|
|
1395
|
+
var warnings = {};
|
|
1396
|
+
function registerShape(name, callback) {
|
|
1397
|
+
shapes[name] = callback;
|
|
1398
|
+
}
|
|
1399
|
+
function getShape(shapeName) {
|
|
1400
|
+
if (shapes[shapeName]) return shapes[shapeName];
|
|
1401
|
+
if (!warnings[shapeName]) {
|
|
1402
|
+
warnings[shapeName] = true;
|
|
1403
|
+
debug("Unknown shape '" + shapeName + "'. Using square instead.");
|
|
1404
|
+
}
|
|
1405
|
+
return shapes["square"];
|
|
1406
|
+
}
|
|
1407
|
+
function getAvailableShapes() {
|
|
1408
|
+
return Object.keys(shapes);
|
|
1409
|
+
}
|
|
1410
|
+
function circle(cx, cy, size, props, options) {
|
|
1411
|
+
return /*#__PURE__*/ jsx(
|
|
1412
|
+
"circle",
|
|
1413
|
+
_objectSpread2(
|
|
1414
|
+
_objectSpread2({}, props),
|
|
1415
|
+
{},
|
|
1416
|
+
{
|
|
1417
|
+
cx: cx,
|
|
1418
|
+
cy: cy,
|
|
1419
|
+
r: size / 2,
|
|
1420
|
+
}
|
|
1421
|
+
)
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
registerShape("circle", circle);
|
|
1425
|
+
function square(cx, cy, size, props, options) {
|
|
1426
|
+
size *= 0.9;
|
|
1427
|
+
return /*#__PURE__*/ jsx(
|
|
1428
|
+
"rect",
|
|
1429
|
+
_objectSpread2(
|
|
1430
|
+
_objectSpread2({}, props),
|
|
1431
|
+
{},
|
|
1432
|
+
{
|
|
1433
|
+
x: cx - size / 2,
|
|
1434
|
+
y: cy - size / 2,
|
|
1435
|
+
width: size,
|
|
1436
|
+
height: size,
|
|
1437
|
+
}
|
|
1438
|
+
)
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
registerShape("square", square);
|
|
1442
|
+
registerShape("rect", square);
|
|
1443
|
+
function bar(cx, cy, size, props, options) {
|
|
1444
|
+
size *= 0.9;
|
|
1445
|
+
return /*#__PURE__*/ jsx(
|
|
1446
|
+
"rect",
|
|
1447
|
+
_objectSpread2(
|
|
1448
|
+
_objectSpread2({}, props),
|
|
1449
|
+
{},
|
|
1450
|
+
{
|
|
1451
|
+
x: cx - size / 2,
|
|
1452
|
+
y: cy - size / 4,
|
|
1453
|
+
width: size,
|
|
1454
|
+
height: size / 2,
|
|
1455
|
+
}
|
|
1456
|
+
)
|
|
1457
|
+
);
|
|
1458
|
+
}
|
|
1459
|
+
registerShape("bar", bar);
|
|
1460
|
+
function column(cx, cy, size, props, options) {
|
|
1461
|
+
size *= 0.9;
|
|
1462
|
+
return /*#__PURE__*/ jsx(
|
|
1463
|
+
"rect",
|
|
1464
|
+
_objectSpread2(
|
|
1465
|
+
_objectSpread2({}, props),
|
|
1466
|
+
{},
|
|
1467
|
+
{
|
|
1468
|
+
x: cx - size / 4,
|
|
1469
|
+
y: cy - size / 2,
|
|
1470
|
+
width: size / 2,
|
|
1471
|
+
height: size,
|
|
1472
|
+
}
|
|
1473
|
+
)
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1476
|
+
registerShape("column", column);
|
|
1477
|
+
function line(cx, cy, size, props, options) {
|
|
1478
|
+
size *= 0.9;
|
|
1479
|
+
return /*#__PURE__*/ jsx(
|
|
1480
|
+
"line",
|
|
1481
|
+
_objectSpread2(
|
|
1482
|
+
_objectSpread2({}, props),
|
|
1483
|
+
{},
|
|
1484
|
+
{
|
|
1485
|
+
x1: cx - size / 2,
|
|
1486
|
+
y1: cy,
|
|
1487
|
+
x2: cx + size / 2,
|
|
1488
|
+
y2: cy,
|
|
1489
|
+
}
|
|
1490
|
+
)
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
registerShape("line", line);
|
|
1494
|
+
registerShape("hline", line);
|
|
1495
|
+
function vline(cx, cy, size, props, options) {
|
|
1496
|
+
size *= 0.9;
|
|
1497
|
+
return /*#__PURE__*/ jsx(
|
|
1498
|
+
"line",
|
|
1499
|
+
_objectSpread2(
|
|
1500
|
+
_objectSpread2({}, props),
|
|
1501
|
+
{},
|
|
1502
|
+
{
|
|
1503
|
+
x1: cx,
|
|
1504
|
+
y1: cy - size / 2,
|
|
1505
|
+
x2: cx,
|
|
1506
|
+
y2: cy + size / 2,
|
|
1507
|
+
}
|
|
1508
|
+
)
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
registerShape("vline", vline);
|
|
1512
|
+
function triangle(cx, cy, size, props, options) {
|
|
1513
|
+
size *= 1.29;
|
|
1514
|
+
var d = "";
|
|
1515
|
+
var cos = Math.cos(Math.PI / 6);
|
|
1516
|
+
var sin = Math.sin(Math.PI / 6);
|
|
1517
|
+
d += "M " + cx + " " + (cy - size / 2) + " ";
|
|
1518
|
+
d += "L " + (cx + (cos * size) / 2) + " " + (cy + (sin * size) / 2) + " ";
|
|
1519
|
+
d += "L " + (cx - (cos * size) / 2) + " " + (cy + (sin * size) / 2) + " ";
|
|
1520
|
+
d += "Z";
|
|
1521
|
+
return /*#__PURE__*/ jsx(
|
|
1522
|
+
"path",
|
|
1523
|
+
_objectSpread2(
|
|
1524
|
+
_objectSpread2({}, props),
|
|
1525
|
+
{},
|
|
1526
|
+
{
|
|
1527
|
+
d: d,
|
|
1528
|
+
}
|
|
1529
|
+
)
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
registerShape("triangle", triangle);
|
|
1533
|
+
|
|
1534
|
+
var Legend = /*#__PURE__*/ (function (_HtmlElement) {
|
|
1535
|
+
_inheritsLoose(Legend, _HtmlElement);
|
|
1536
|
+
function Legend() {
|
|
1537
|
+
return _HtmlElement.apply(this, arguments) || this;
|
|
1538
|
+
}
|
|
1539
|
+
var _proto = Legend.prototype;
|
|
1540
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
1541
|
+
var data = instance.data;
|
|
1542
|
+
data.stateMods = Object.assign(data.stateMods || {}, {
|
|
1543
|
+
vertical: this.vertical,
|
|
1544
|
+
});
|
|
1545
|
+
_HtmlElement.prototype.prepareData.call(this, context, instance);
|
|
1546
|
+
};
|
|
1547
|
+
_proto.isValidHtmlAttribute = function isValidHtmlAttribute(attrName) {
|
|
1548
|
+
switch (attrName) {
|
|
1549
|
+
case "shapeSize":
|
|
1550
|
+
case "svgSize":
|
|
1551
|
+
return false;
|
|
1552
|
+
default:
|
|
1553
|
+
return _HtmlElement.prototype.isValidHtmlAttribute.call(this, attrName);
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
_proto.explore = function explore(context, instance) {
|
|
1557
|
+
if (!context.legends) context.legends = {};
|
|
1558
|
+
instance.legends = context.legends;
|
|
1559
|
+
context.addLegendEntry = function (legendName, entry) {
|
|
1560
|
+
//case when all legends are scoped and new entry is added outside the scope
|
|
1561
|
+
if (!context.legends) return;
|
|
1562
|
+
var legend = context.legends[legendName];
|
|
1563
|
+
if (!legend)
|
|
1564
|
+
legend = context.legends[legendName] = {
|
|
1565
|
+
entries: [],
|
|
1566
|
+
names: {},
|
|
1567
|
+
};
|
|
1568
|
+
if (!legend.names[entry.name]) {
|
|
1569
|
+
legend.entries.push(entry);
|
|
1570
|
+
legend.names[entry.name] = entry;
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
_HtmlElement.prototype.explore.call(this, context, instance);
|
|
1574
|
+
};
|
|
1575
|
+
_proto.renderChildren = function renderChildren(context, instance) {
|
|
1576
|
+
var _this = this;
|
|
1577
|
+
var CSS = this.CSS;
|
|
1578
|
+
var entries = instance.legends[this.name] && instance.legends[this.name].entries,
|
|
1579
|
+
list;
|
|
1580
|
+
if (isArray(entries) && entries.length > 0) {
|
|
1581
|
+
list = /*#__PURE__*/ jsx(
|
|
1582
|
+
"div",
|
|
1583
|
+
{
|
|
1584
|
+
className: CSS.element(this.baseClass, "wrap"),
|
|
1585
|
+
children: entries.map(function (e, i) {
|
|
1586
|
+
return withHoverSync(i, e.hoverSync, e.hoverChannel, e.hoverId, function (_ref) {
|
|
1587
|
+
var onMouseMove = _ref.onMouseMove,
|
|
1588
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
1589
|
+
hover = _ref.hover;
|
|
1590
|
+
return /*#__PURE__*/ jsxs(
|
|
1591
|
+
"div",
|
|
1592
|
+
{
|
|
1593
|
+
className: CSS.element(_this.baseClass, "entry", {
|
|
1594
|
+
"color-root": true,
|
|
1595
|
+
hover: hover,
|
|
1596
|
+
disabled: e.disabled,
|
|
1597
|
+
selected: e.selected,
|
|
1598
|
+
}),
|
|
1599
|
+
onClick: e.onClick,
|
|
1600
|
+
onMouseMove: onMouseMove,
|
|
1601
|
+
onMouseLeave: onMouseLeave,
|
|
1602
|
+
children: [_this.renderShape(e), e.name],
|
|
1603
|
+
},
|
|
1604
|
+
i
|
|
1605
|
+
);
|
|
1606
|
+
});
|
|
1607
|
+
}),
|
|
1608
|
+
},
|
|
1609
|
+
"wrap"
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
return [list, _HtmlElement.prototype.renderChildren.call(this, context, instance)];
|
|
1613
|
+
};
|
|
1614
|
+
_proto.renderShape = function renderShape(entry) {
|
|
1615
|
+
var _this$CSS$element;
|
|
1616
|
+
var className = this.CSS.element(
|
|
1617
|
+
this.baseClass,
|
|
1618
|
+
"shape",
|
|
1619
|
+
((_this$CSS$element = {}),
|
|
1620
|
+
(_this$CSS$element["color-" + entry.colorIndex] =
|
|
1621
|
+
entry.colorIndex != null && (isUndefined(entry.active) || entry.active)),
|
|
1622
|
+
_this$CSS$element)
|
|
1623
|
+
);
|
|
1624
|
+
var shape = getShape(entry.shape || "square");
|
|
1625
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
1626
|
+
className: this.CSS.element(this.baseClass, "svg"),
|
|
1627
|
+
style: {
|
|
1628
|
+
width: this.svgSize + "px",
|
|
1629
|
+
height: this.svgSize + "px",
|
|
1630
|
+
marginTop: -this.svgSize / 2 + "px",
|
|
1631
|
+
},
|
|
1632
|
+
children: shape(this.svgSize / 2, this.svgSize / 2, entry.shapeSize || this.shapeSize, {
|
|
1633
|
+
style: entry.style,
|
|
1634
|
+
className: className,
|
|
1635
|
+
}),
|
|
1636
|
+
});
|
|
1637
|
+
};
|
|
1638
|
+
return Legend;
|
|
1639
|
+
})(HtmlElement);
|
|
1640
|
+
Legend.prototype.name = "legend";
|
|
1641
|
+
Legend.prototype.baseClass = "legend";
|
|
1642
|
+
Legend.prototype.vertical = false;
|
|
1643
|
+
Legend.prototype.memoize = false;
|
|
1644
|
+
Legend.prototype.shapeSize = 18;
|
|
1645
|
+
Legend.prototype.svgSize = 20;
|
|
1646
|
+
Widget.alias("legend", Legend);
|
|
1647
|
+
Legend.Scope = /*#__PURE__*/ (function (_PureContainer) {
|
|
1648
|
+
_inheritsLoose(_class, _PureContainer);
|
|
1649
|
+
function _class() {
|
|
1650
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
1651
|
+
}
|
|
1652
|
+
var _proto2 = _class.prototype;
|
|
1653
|
+
_proto2.explore = function explore(context, instance) {
|
|
1654
|
+
context.push("legends", (instance.legends = {}));
|
|
1655
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
1656
|
+
};
|
|
1657
|
+
_proto2.exploreCleanup = function exploreCleanup(context, instance) {
|
|
1658
|
+
context.pop("legends");
|
|
1659
|
+
};
|
|
1660
|
+
_proto2.prepare = function prepare(context, instance) {
|
|
1661
|
+
context.push("legends", instance.legends);
|
|
1662
|
+
};
|
|
1663
|
+
_proto2.prepareCleanup = function prepareCleanup(context, instance) {
|
|
1664
|
+
context.pop("legends");
|
|
1665
|
+
};
|
|
1666
|
+
return _class;
|
|
1667
|
+
})(PureContainer);
|
|
1668
|
+
var LegendScope = Legend.Scope;
|
|
1669
|
+
|
|
1670
|
+
var LegendEntry = /*#__PURE__*/ (function (_HtmlElement) {
|
|
1671
|
+
_inheritsLoose(LegendEntry, _HtmlElement);
|
|
1672
|
+
function LegendEntry() {
|
|
1673
|
+
return _HtmlElement.apply(this, arguments) || this;
|
|
1674
|
+
}
|
|
1675
|
+
var _proto = LegendEntry.prototype;
|
|
1676
|
+
_proto.init = function init() {
|
|
1677
|
+
this.selection = Selection.create(this.selection);
|
|
1678
|
+
_HtmlElement.prototype.init.call(this);
|
|
1679
|
+
};
|
|
1680
|
+
_proto.declareData = function declareData() {
|
|
1681
|
+
var _HtmlElement$prototyp;
|
|
1682
|
+
var selection = this.selection.configureWidget(this);
|
|
1683
|
+
(_HtmlElement$prototyp = _HtmlElement.prototype.declareData).call.apply(
|
|
1684
|
+
_HtmlElement$prototyp,
|
|
1685
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
1686
|
+
selection,
|
|
1687
|
+
{
|
|
1688
|
+
selected: undefined,
|
|
1689
|
+
shape: undefined,
|
|
1690
|
+
colorIndex: undefined,
|
|
1691
|
+
colorMap: undefined,
|
|
1692
|
+
colorName: undefined,
|
|
1693
|
+
name: undefined,
|
|
1694
|
+
active: true,
|
|
1695
|
+
size: undefined,
|
|
1696
|
+
},
|
|
1697
|
+
])
|
|
1698
|
+
);
|
|
1699
|
+
};
|
|
1700
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
1701
|
+
var data = instance.data;
|
|
1702
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
1703
|
+
_HtmlElement.prototype.prepareData.call(this, context, instance);
|
|
1704
|
+
};
|
|
1705
|
+
_proto.explore = function explore(context, instance) {
|
|
1706
|
+
var data = instance.data;
|
|
1707
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
1708
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
1709
|
+
_HtmlElement.prototype.explore.call(this, context, instance);
|
|
1710
|
+
};
|
|
1711
|
+
_proto.prepare = function prepare(context, instance) {
|
|
1712
|
+
var data = instance.data,
|
|
1713
|
+
colorMap = instance.colorMap;
|
|
1714
|
+
if (colorMap && data.colorName) {
|
|
1715
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
1716
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
_proto.attachProps = function attachProps(context, instance, props) {
|
|
1720
|
+
var _this = this;
|
|
1721
|
+
var shape = this.renderShape(instance);
|
|
1722
|
+
props.children = [shape, props.children];
|
|
1723
|
+
props.onMouseDown = stopPropagation;
|
|
1724
|
+
props.onClick = function (e) {
|
|
1725
|
+
_this.handleClick(e, instance);
|
|
1726
|
+
};
|
|
1727
|
+
delete props.active;
|
|
1728
|
+
delete props.selection;
|
|
1729
|
+
delete props.colorMap;
|
|
1730
|
+
delete props.colorIndex;
|
|
1731
|
+
delete props.shape;
|
|
1732
|
+
delete props.name;
|
|
1733
|
+
delete props.selected;
|
|
1734
|
+
delete props.svgSize;
|
|
1735
|
+
};
|
|
1736
|
+
_proto.handleClick = function handleClick(e, instance) {
|
|
1737
|
+
if (this.onClick && instance.invoke("onClick", e, instance) === false) return;
|
|
1738
|
+
e.stopPropagation();
|
|
1739
|
+
var any = this.legendAction == "auto";
|
|
1740
|
+
if (any || this.legendAction == "toggle") if (instance.set("active", !instance.data.active)) return;
|
|
1741
|
+
if ((any || this.legendAction == "select") && !this.selection.isDummy) this.selection.selectInstance(instance);
|
|
1742
|
+
};
|
|
1743
|
+
_proto.renderShape = function renderShape(instance) {
|
|
1744
|
+
var _this$CSS$element;
|
|
1745
|
+
var entry = instance.data;
|
|
1746
|
+
var className = this.CSS.element(
|
|
1747
|
+
this.baseClass,
|
|
1748
|
+
"shape",
|
|
1749
|
+
((_this$CSS$element = {
|
|
1750
|
+
disabled: entry.disabled,
|
|
1751
|
+
selected: entry.selected || this.selection.isInstanceSelected(instance),
|
|
1752
|
+
}),
|
|
1753
|
+
(_this$CSS$element["color-" + entry.colorIndex] =
|
|
1754
|
+
entry.colorIndex != null && (isUndefined(entry.active) || entry.active)),
|
|
1755
|
+
_this$CSS$element)
|
|
1756
|
+
);
|
|
1757
|
+
var shape = getShape(entry.shape || "square");
|
|
1758
|
+
return /*#__PURE__*/ jsx(
|
|
1759
|
+
"svg",
|
|
1760
|
+
{
|
|
1761
|
+
className: this.CSS.element(this.baseClass, "svg"),
|
|
1762
|
+
style: {
|
|
1763
|
+
width: this.svgSize + "px",
|
|
1764
|
+
height: this.svgSize + "px",
|
|
1765
|
+
marginTop: -this.svgSize / 2 + "px",
|
|
1766
|
+
},
|
|
1767
|
+
children: shape(this.svgSize / 2, this.svgSize / 2, entry.size, {
|
|
1768
|
+
style: entry.style,
|
|
1769
|
+
className: className,
|
|
1770
|
+
}),
|
|
1771
|
+
},
|
|
1772
|
+
"svg"
|
|
1773
|
+
);
|
|
1774
|
+
};
|
|
1775
|
+
return LegendEntry;
|
|
1776
|
+
})(HtmlElement);
|
|
1777
|
+
LegendEntry.prototype.baseClass = "legendentry";
|
|
1778
|
+
LegendEntry.prototype.shape = "square";
|
|
1779
|
+
LegendEntry.prototype.legendAction = "auto";
|
|
1780
|
+
LegendEntry.prototype.size = 18;
|
|
1781
|
+
LegendEntry.prototype.svgSize = 20;
|
|
1782
|
+
Widget.alias("legend-entry", LegendEntry);
|
|
1783
|
+
|
|
1784
|
+
var ColorMap = /*#__PURE__*/ (function (_Widget) {
|
|
1785
|
+
_inheritsLoose(ColorMap, _Widget);
|
|
1786
|
+
function ColorMap() {
|
|
1787
|
+
return _Widget.apply(this, arguments) || this;
|
|
1788
|
+
}
|
|
1789
|
+
var _proto = ColorMap.prototype;
|
|
1790
|
+
_proto.declareData = function declareData() {
|
|
1791
|
+
var _Widget$prototype$dec;
|
|
1792
|
+
(_Widget$prototype$dec = _Widget.prototype.declareData).call.apply(
|
|
1793
|
+
_Widget$prototype$dec,
|
|
1794
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
1795
|
+
{
|
|
1796
|
+
names: undefined,
|
|
1797
|
+
offset: undefined,
|
|
1798
|
+
step: undefined,
|
|
1799
|
+
size: undefined,
|
|
1800
|
+
},
|
|
1801
|
+
])
|
|
1802
|
+
);
|
|
1803
|
+
};
|
|
1804
|
+
_proto.explore = function explore(context, instance) {
|
|
1805
|
+
var _this = this;
|
|
1806
|
+
if (!context.colorMaps) context.colorMaps = {};
|
|
1807
|
+
context.getColorMap = function (colorMap) {
|
|
1808
|
+
var map = context.colorMaps[colorMap];
|
|
1809
|
+
if (!map) {
|
|
1810
|
+
var cache = _this.onGetCache ? instance.invoke("onGetCache") : {};
|
|
1811
|
+
map = cache[colorMap];
|
|
1812
|
+
if (!map) {
|
|
1813
|
+
var data = instance.data;
|
|
1814
|
+
map =
|
|
1815
|
+
context.colorMaps[colorMap] =
|
|
1816
|
+
cache[colorMap] =
|
|
1817
|
+
new ColorIndex({
|
|
1818
|
+
offset: data.offset,
|
|
1819
|
+
step: data.step,
|
|
1820
|
+
size: data.size,
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
if (Array.isArray(instance.data.names))
|
|
1824
|
+
instance.data.names.forEach(function (name) {
|
|
1825
|
+
return map.acknowledge(name);
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
return map;
|
|
1829
|
+
};
|
|
1830
|
+
};
|
|
1831
|
+
_proto.render = function render() {
|
|
1832
|
+
return null;
|
|
1833
|
+
};
|
|
1834
|
+
return ColorMap;
|
|
1835
|
+
})(Widget);
|
|
1836
|
+
ColorMap.prototype.offset = 0;
|
|
1837
|
+
ColorMap.prototype.step = null;
|
|
1838
|
+
ColorMap.prototype.size = 16;
|
|
1839
|
+
var ColorMapScope = /*#__PURE__*/ (function (_PureContainer) {
|
|
1840
|
+
_inheritsLoose(ColorMapScope, _PureContainer);
|
|
1841
|
+
function ColorMapScope() {
|
|
1842
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
1843
|
+
}
|
|
1844
|
+
var _proto2 = ColorMapScope.prototype;
|
|
1845
|
+
_proto2.explore = function explore(context, instance) {
|
|
1846
|
+
context.push("colorMaps", (instance.colorMaps = {}));
|
|
1847
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
1848
|
+
};
|
|
1849
|
+
_proto2.exploreCleanup = function exploreCleanup(context, instance) {
|
|
1850
|
+
context.pop("colorMaps");
|
|
1851
|
+
};
|
|
1852
|
+
_proto2.prepare = function prepare(context, instance) {
|
|
1853
|
+
context.push("colorMaps", instance.colorMaps);
|
|
1854
|
+
};
|
|
1855
|
+
_proto2.prepareCleanup = function prepareCleanup(context, instance) {
|
|
1856
|
+
context.pop("colorMaps");
|
|
1857
|
+
};
|
|
1858
|
+
return ColorMapScope;
|
|
1859
|
+
})(PureContainer);
|
|
1860
|
+
ColorMap.Scope = ColorMapScope;
|
|
1861
|
+
Widget.alias("color-map", ColorMap);
|
|
1862
|
+
var ColorIndex = /*#__PURE__*/ (function () {
|
|
1863
|
+
function ColorIndex(_ref) {
|
|
1864
|
+
var offset = _ref.offset,
|
|
1865
|
+
step = _ref.step,
|
|
1866
|
+
size = _ref.size;
|
|
1867
|
+
this.colorMap = {};
|
|
1868
|
+
this.dirty = true;
|
|
1869
|
+
this.offset = offset;
|
|
1870
|
+
this.step = step;
|
|
1871
|
+
this.size = size;
|
|
1872
|
+
}
|
|
1873
|
+
var _proto3 = ColorIndex.prototype;
|
|
1874
|
+
_proto3.acknowledge = function acknowledge(name) {
|
|
1875
|
+
if (!(name in this.colorMap)) {
|
|
1876
|
+
this.colorMap[name] = Object.keys(this.colorMap).length;
|
|
1877
|
+
this.dirty = true;
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
_proto3.map = function map(name) {
|
|
1881
|
+
if (this.dirty) {
|
|
1882
|
+
this.dirty = false;
|
|
1883
|
+
if (!this.step) {
|
|
1884
|
+
var n = Object.keys(this.colorMap).length;
|
|
1885
|
+
this.step = n > 0 ? this.size / n : 1;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
var index = this.colorMap[name] || 0;
|
|
1889
|
+
return Math.round(this.offset + this.step * index + this.size) % this.size;
|
|
1890
|
+
};
|
|
1891
|
+
return ColorIndex;
|
|
1892
|
+
})();
|
|
1893
|
+
|
|
1894
|
+
var Marker = /*#__PURE__*/ (function (_BoundedObject) {
|
|
1895
|
+
_inheritsLoose(Marker, _BoundedObject);
|
|
1896
|
+
function Marker() {
|
|
1897
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
1898
|
+
}
|
|
1899
|
+
var _proto = Marker.prototype;
|
|
1900
|
+
_proto.init = function init() {
|
|
1901
|
+
this.selection = Selection.create(this.selection);
|
|
1902
|
+
if (this.draggable) {
|
|
1903
|
+
this.draggableX = true;
|
|
1904
|
+
this.draggableY = true;
|
|
1905
|
+
}
|
|
1906
|
+
if (this.constrain) {
|
|
1907
|
+
this.constrainX = true;
|
|
1908
|
+
this.constrainY = true;
|
|
1909
|
+
}
|
|
1910
|
+
_BoundedObject.prototype.init.call(this);
|
|
1911
|
+
};
|
|
1912
|
+
_proto.declareData = function declareData() {
|
|
1913
|
+
var _BoundedObject$protot;
|
|
1914
|
+
var selection = this.selection.configureWidget(this);
|
|
1915
|
+
return (_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
1916
|
+
_BoundedObject$protot,
|
|
1917
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
1918
|
+
selection,
|
|
1919
|
+
{
|
|
1920
|
+
x: undefined,
|
|
1921
|
+
y: undefined,
|
|
1922
|
+
size: undefined,
|
|
1923
|
+
shape: undefined,
|
|
1924
|
+
disabled: undefined,
|
|
1925
|
+
colorMap: undefined,
|
|
1926
|
+
colorIndex: undefined,
|
|
1927
|
+
colorName: undefined,
|
|
1928
|
+
legendColorIndex: undefined,
|
|
1929
|
+
name: undefined,
|
|
1930
|
+
active: true,
|
|
1931
|
+
},
|
|
1932
|
+
])
|
|
1933
|
+
);
|
|
1934
|
+
};
|
|
1935
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
1936
|
+
instance.axes = context.axes;
|
|
1937
|
+
instance.xAxis = context.axes[this.xAxis];
|
|
1938
|
+
instance.yAxis = context.axes[this.yAxis];
|
|
1939
|
+
var data = instance.data;
|
|
1940
|
+
data.selected = this.selection.isInstanceSelected(instance);
|
|
1941
|
+
data.stateMods = {
|
|
1942
|
+
selected: data.selected,
|
|
1943
|
+
disabled: data.disabled,
|
|
1944
|
+
selectable: !this.selection.isDummy,
|
|
1945
|
+
"draggable-x": this.draggableX && !this.draggableY,
|
|
1946
|
+
"draggable-y": this.draggableY && !this.draggableX,
|
|
1947
|
+
"draggable-xy": this.draggableY && this.draggableX,
|
|
1948
|
+
};
|
|
1949
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
1950
|
+
_BoundedObject.prototype.prepareData.call(this, context, instance);
|
|
1951
|
+
};
|
|
1952
|
+
_proto.calculateBounds = function calculateBounds(context, instance) {
|
|
1953
|
+
var data = instance.data,
|
|
1954
|
+
xAxis = instance.xAxis,
|
|
1955
|
+
yAxis = instance.yAxis;
|
|
1956
|
+
var x, y;
|
|
1957
|
+
if (data.x == null || data.y == null) {
|
|
1958
|
+
var bounds = _BoundedObject.prototype.calculateBounds.call(this, context, instance);
|
|
1959
|
+
x = (bounds.l + bounds.r) / 2;
|
|
1960
|
+
y = (bounds.t + bounds.b) / 2;
|
|
1961
|
+
}
|
|
1962
|
+
if (data.x != null) x = xAxis.map(data.x);
|
|
1963
|
+
if (data.y != null) y = yAxis.map(data.y);
|
|
1964
|
+
return new Rect({
|
|
1965
|
+
l: x - data.size / 2,
|
|
1966
|
+
r: x + data.size / 2,
|
|
1967
|
+
t: y - data.size / 2,
|
|
1968
|
+
b: y + data.size / 2,
|
|
1969
|
+
});
|
|
1970
|
+
};
|
|
1971
|
+
_proto.explore = function explore(context, instance) {
|
|
1972
|
+
var data = instance.data,
|
|
1973
|
+
xAxis = instance.xAxis,
|
|
1974
|
+
yAxis = instance.yAxis;
|
|
1975
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
1976
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
1977
|
+
if (data.active) {
|
|
1978
|
+
if (this.affectsAxes) {
|
|
1979
|
+
if (xAxis && data.x != null) xAxis.acknowledge(data.x, 0, this.xOffset);
|
|
1980
|
+
if (yAxis && data.y != null) yAxis.acknowledge(data.y, 0, this.yOffset);
|
|
1981
|
+
}
|
|
1982
|
+
if (context.pointReducer) context.pointReducer(data.x, data.y, data.name, data);
|
|
1983
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
_proto.prepare = function prepare(context, instance) {
|
|
1987
|
+
var _this = this;
|
|
1988
|
+
var data = instance.data,
|
|
1989
|
+
xAxis = instance.xAxis,
|
|
1990
|
+
yAxis = instance.yAxis,
|
|
1991
|
+
colorMap = instance.colorMap;
|
|
1992
|
+
if (colorMap && data.colorName) {
|
|
1993
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
1994
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
1995
|
+
}
|
|
1996
|
+
if (data.active) {
|
|
1997
|
+
if (xAxis && xAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
1998
|
+
if (yAxis && yAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
1999
|
+
}
|
|
2000
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
2001
|
+
if (data.name && context.addLegendEntry)
|
|
2002
|
+
context.addLegendEntry(this.legend, {
|
|
2003
|
+
name: data.name,
|
|
2004
|
+
active: data.active,
|
|
2005
|
+
colorIndex: data.legendColorIndex || data.colorIndex,
|
|
2006
|
+
disabled: data.disabled,
|
|
2007
|
+
selected: data.selected,
|
|
2008
|
+
style: data.style,
|
|
2009
|
+
shape: data.shape,
|
|
2010
|
+
onClick: function onClick(e) {
|
|
2011
|
+
_this.onLegendClick(e, instance);
|
|
2012
|
+
},
|
|
2013
|
+
});
|
|
2014
|
+
};
|
|
2015
|
+
_proto.onLegendClick = function onLegendClick(e, instance) {
|
|
2016
|
+
var allActions = this.legendAction == "auto";
|
|
2017
|
+
var data = instance.data;
|
|
2018
|
+
if (allActions || this.legendAction == "toggle") if (instance.set("active", !data.active)) return;
|
|
2019
|
+
if (allActions || this.legendAction == "select") this.handleClick(e, instance);
|
|
2020
|
+
};
|
|
2021
|
+
_proto.render = function render(context, instance, key) {
|
|
2022
|
+
var data = instance.data;
|
|
2023
|
+
if (!data.active || data.x === null || data.y === null) return null;
|
|
2024
|
+
return /*#__PURE__*/ jsx(
|
|
2025
|
+
MarkerComponent,
|
|
2026
|
+
{
|
|
2027
|
+
instance: instance,
|
|
2028
|
+
data: instance.data,
|
|
2029
|
+
shouldUpdate: instance.shouldUpdate,
|
|
2030
|
+
children: this.renderChildren(context, instance),
|
|
2031
|
+
},
|
|
2032
|
+
key
|
|
2033
|
+
);
|
|
2034
|
+
};
|
|
2035
|
+
_proto.handleMouseDown = function handleMouseDown(e, instance) {
|
|
2036
|
+
var _this2 = this;
|
|
2037
|
+
if (this.draggableX || this.draggableY) {
|
|
2038
|
+
var svgEl = closest(e.target, function (el) {
|
|
2039
|
+
return el.tagName == "svg";
|
|
2040
|
+
});
|
|
2041
|
+
if (svgEl)
|
|
2042
|
+
captureMouseOrTouch(
|
|
2043
|
+
e,
|
|
2044
|
+
function (e, captureData) {
|
|
2045
|
+
_this2.handleDragMove(e, instance, captureData);
|
|
2046
|
+
},
|
|
2047
|
+
null,
|
|
2048
|
+
{
|
|
2049
|
+
svgEl: svgEl,
|
|
2050
|
+
el: e.target,
|
|
2051
|
+
},
|
|
2052
|
+
e.target.style.cursor
|
|
2053
|
+
);
|
|
2054
|
+
} else {
|
|
2055
|
+
if (!this.selection.isDummy) this.selection.selectInstance(instance);
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
_proto.handleClick = function handleClick(e, instance) {
|
|
2059
|
+
if (this.onClick) instance.invoke("onClick", e, instance);
|
|
2060
|
+
};
|
|
2061
|
+
_proto.handleDragMove = function handleDragMove(e, instance, captureData) {
|
|
2062
|
+
var cursor = getCursorPos(e);
|
|
2063
|
+
var svgBounds = getTopLevelBoundingClientRect(captureData.svgEl);
|
|
2064
|
+
var xAxis = instance.xAxis,
|
|
2065
|
+
yAxis = instance.yAxis;
|
|
2066
|
+
if (this.draggableX && xAxis) {
|
|
2067
|
+
var x = xAxis.trackValue(cursor.clientX - svgBounds.left, this.xOffset);
|
|
2068
|
+
if (this.constrainX) x = xAxis.constrainValue(x);
|
|
2069
|
+
instance.set("x", xAxis.encodeValue(x));
|
|
2070
|
+
}
|
|
2071
|
+
if (this.draggableY && yAxis) {
|
|
2072
|
+
var y = yAxis.trackValue(cursor.clientY - svgBounds.top, this.yOffset);
|
|
2073
|
+
if (this.constrainY) y = yAxis.constrainValue(y);
|
|
2074
|
+
instance.set("y", yAxis.encodeValue(y));
|
|
2075
|
+
}
|
|
2076
|
+
tooltipMouseMove(e, instance, this.tooltip, {
|
|
2077
|
+
target: captureData.el,
|
|
2078
|
+
});
|
|
2079
|
+
};
|
|
2080
|
+
return Marker;
|
|
2081
|
+
})(BoundedObject);
|
|
2082
|
+
Marker.prototype.xOffset = 0;
|
|
2083
|
+
Marker.prototype.yOffset = 0;
|
|
2084
|
+
Marker.prototype.size = 5;
|
|
2085
|
+
Marker.prototype.anchors = "0.5 0.5 0.5 0.5";
|
|
2086
|
+
Marker.prototype.xAxis = "x";
|
|
2087
|
+
Marker.prototype.yAxis = "y";
|
|
2088
|
+
Marker.prototype.baseClass = "marker";
|
|
2089
|
+
Marker.prototype.draggableX = false;
|
|
2090
|
+
Marker.prototype.draggableY = false;
|
|
2091
|
+
Marker.prototype.draggable = false;
|
|
2092
|
+
Marker.prototype.constrainX = false;
|
|
2093
|
+
Marker.prototype.constrainY = false;
|
|
2094
|
+
Marker.prototype.constrain = false;
|
|
2095
|
+
Marker.prototype.legend = "legend";
|
|
2096
|
+
Marker.prototype.legendAction = "auto";
|
|
2097
|
+
Marker.prototype.shape = "circle";
|
|
2098
|
+
Marker.prototype.styled = true;
|
|
2099
|
+
Marker.prototype.hidden = false;
|
|
2100
|
+
Marker.prototype.affectsAxes = true;
|
|
2101
|
+
BoundedObject.alias("marker", Marker);
|
|
2102
|
+
var MarkerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
2103
|
+
_inheritsLoose(MarkerComponent, _VDOM$Component);
|
|
2104
|
+
function MarkerComponent() {
|
|
2105
|
+
return _VDOM$Component.apply(this, arguments) || this;
|
|
2106
|
+
}
|
|
2107
|
+
var _proto2 = MarkerComponent.prototype;
|
|
2108
|
+
_proto2.shouldComponentUpdate = function shouldComponentUpdate(props) {
|
|
2109
|
+
return props.shouldUpdate;
|
|
2110
|
+
};
|
|
2111
|
+
_proto2.render = function render() {
|
|
2112
|
+
var _CSS$element,
|
|
2113
|
+
_this3 = this;
|
|
2114
|
+
var _this$props = this.props,
|
|
2115
|
+
instance = _this$props.instance,
|
|
2116
|
+
children = _this$props.children,
|
|
2117
|
+
data = _this$props.data;
|
|
2118
|
+
var widget = instance.widget;
|
|
2119
|
+
var CSS = widget.CSS,
|
|
2120
|
+
baseClass = widget.baseClass;
|
|
2121
|
+
var bounds = data.bounds,
|
|
2122
|
+
shape = data.shape;
|
|
2123
|
+
var shapeRenderer = getShape(shape);
|
|
2124
|
+
var shapeProps = {
|
|
2125
|
+
className: CSS.element(
|
|
2126
|
+
baseClass,
|
|
2127
|
+
"shape",
|
|
2128
|
+
((_CSS$element = {}),
|
|
2129
|
+
(_CSS$element["color-" + data.colorIndex] = data.colorIndex != null),
|
|
2130
|
+
(_CSS$element.selected = data.selected),
|
|
2131
|
+
_CSS$element)
|
|
2132
|
+
),
|
|
2133
|
+
style: data.style,
|
|
2134
|
+
cx: (bounds.l + bounds.r) / 2,
|
|
2135
|
+
cy: (bounds.t + bounds.b) / 2,
|
|
2136
|
+
r: data.size / 2,
|
|
2137
|
+
onMouseMove: function onMouseMove(e) {
|
|
2138
|
+
tooltipMouseMove(e, instance, widget.tooltip);
|
|
2139
|
+
},
|
|
2140
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
2141
|
+
tooltipMouseLeave(e, instance, widget.tooltip);
|
|
2142
|
+
},
|
|
2143
|
+
onMouseDown: function onMouseDown(e) {
|
|
2144
|
+
widget.handleMouseDown(e, instance);
|
|
2145
|
+
},
|
|
2146
|
+
onTouchStart: function onTouchStart(e) {
|
|
2147
|
+
widget.handleMouseDown(e, instance);
|
|
2148
|
+
},
|
|
2149
|
+
onClick: function onClick(e) {
|
|
2150
|
+
widget.handleClick(e, instance);
|
|
2151
|
+
},
|
|
2152
|
+
};
|
|
2153
|
+
if (widget.tooltip) {
|
|
2154
|
+
shapeProps.ref = function (c) {
|
|
2155
|
+
_this3.el = c;
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
return /*#__PURE__*/ jsxs("g", {
|
|
2159
|
+
className: data.classNames,
|
|
2160
|
+
children: [
|
|
2161
|
+
!widget.hidden && shapeRenderer((bounds.l + bounds.r) / 2, (bounds.t + bounds.b) / 2, data.size, shapeProps),
|
|
2162
|
+
children,
|
|
2163
|
+
],
|
|
2164
|
+
});
|
|
2165
|
+
};
|
|
2166
|
+
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
2167
|
+
tooltipParentWillUnmount(this.props.instance);
|
|
2168
|
+
};
|
|
2169
|
+
_proto2.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(props) {
|
|
2170
|
+
tooltipParentWillReceiveProps(this.el, props.instance, props.instance.widget.tooltip);
|
|
2171
|
+
};
|
|
2172
|
+
_proto2.componentDidMount = function componentDidMount() {
|
|
2173
|
+
tooltipParentDidMount(this.el, this.props.instance, this.props.instance.widget.tooltip);
|
|
2174
|
+
};
|
|
2175
|
+
return MarkerComponent;
|
|
2176
|
+
})(VDOM.Component);
|
|
2177
|
+
|
|
2178
|
+
var MarkerLine = /*#__PURE__*/ (function (_BoundedObject) {
|
|
2179
|
+
_inheritsLoose(MarkerLine, _BoundedObject);
|
|
2180
|
+
function MarkerLine() {
|
|
2181
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
2182
|
+
}
|
|
2183
|
+
var _proto = MarkerLine.prototype;
|
|
2184
|
+
_proto.init = function init() {
|
|
2185
|
+
if (isDefined(this.x)) this.x1 = this.x2 = this.x;
|
|
2186
|
+
if (isDefined(this.y)) this.y1 = this.y2 = this.y;
|
|
2187
|
+
_BoundedObject.prototype.init.call(this);
|
|
2188
|
+
};
|
|
2189
|
+
_proto.declareData = function declareData() {
|
|
2190
|
+
var _BoundedObject$protot;
|
|
2191
|
+
(_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
2192
|
+
_BoundedObject$protot,
|
|
2193
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
2194
|
+
{
|
|
2195
|
+
x1: undefined,
|
|
2196
|
+
y1: undefined,
|
|
2197
|
+
x2: undefined,
|
|
2198
|
+
y2: undefined,
|
|
2199
|
+
colorIndex: undefined,
|
|
2200
|
+
active: true,
|
|
2201
|
+
name: undefined,
|
|
2202
|
+
legend: undefined,
|
|
2203
|
+
},
|
|
2204
|
+
])
|
|
2205
|
+
);
|
|
2206
|
+
};
|
|
2207
|
+
_proto.explore = function explore(context, instance) {
|
|
2208
|
+
var data = instance.data;
|
|
2209
|
+
var xAxis = (instance.xAxis = context.axes[this.xAxis]);
|
|
2210
|
+
var yAxis = (instance.yAxis = context.axes[this.yAxis]);
|
|
2211
|
+
if (data.active) {
|
|
2212
|
+
if (this.affectsAxes) {
|
|
2213
|
+
if (data.x1 != null) xAxis.acknowledge(data.x1);
|
|
2214
|
+
if (data.x2 != null) xAxis.acknowledge(data.x2);
|
|
2215
|
+
if (data.y1 != null) yAxis.acknowledge(data.y1);
|
|
2216
|
+
if (data.y2 != null) yAxis.acknowledge(data.y2);
|
|
2217
|
+
}
|
|
2218
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
2219
|
+
}
|
|
2220
|
+
};
|
|
2221
|
+
_proto.prepare = function prepare(context, instance) {
|
|
2222
|
+
var _this = this;
|
|
2223
|
+
var data = instance.data,
|
|
2224
|
+
xAxis = instance.xAxis,
|
|
2225
|
+
yAxis = instance.yAxis;
|
|
2226
|
+
if ((xAxis && xAxis.shouldUpdate) || (yAxis && yAxis.shouldUpdate)) instance.markShouldUpdate(context);
|
|
2227
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
2228
|
+
if (data.name && data.legend && context.addLegendEntry)
|
|
2229
|
+
context.addLegendEntry(data.legend, {
|
|
2230
|
+
name: data.name,
|
|
2231
|
+
active: data.active,
|
|
2232
|
+
colorIndex: data.colorIndex,
|
|
2233
|
+
style: data.style,
|
|
2234
|
+
shape: "line",
|
|
2235
|
+
onClick: function onClick(e) {
|
|
2236
|
+
_this.onLegendClick(e, instance);
|
|
2237
|
+
},
|
|
2238
|
+
});
|
|
2239
|
+
};
|
|
2240
|
+
_proto.calculateBounds = function calculateBounds(context, instance) {
|
|
2241
|
+
var data = instance.data,
|
|
2242
|
+
xAxis = instance.xAxis,
|
|
2243
|
+
yAxis = instance.yAxis;
|
|
2244
|
+
var bounds = _BoundedObject.prototype.calculateBounds.call(this, context, instance);
|
|
2245
|
+
var x1 = bounds.l,
|
|
2246
|
+
x2 = bounds.r,
|
|
2247
|
+
y1 = bounds.t,
|
|
2248
|
+
y2 = bounds.b;
|
|
2249
|
+
if (data.x1 != null) x1 = xAxis.map(data.x1);
|
|
2250
|
+
if (data.x2 != null) x2 = xAxis.map(data.x2);
|
|
2251
|
+
if (data.y1 != null) y1 = yAxis.map(data.y1);
|
|
2252
|
+
if (data.y2 != null) y2 = yAxis.map(data.y2);
|
|
2253
|
+
bounds.l = Math.min(x1, x2);
|
|
2254
|
+
bounds.t = Math.min(y1, y2);
|
|
2255
|
+
bounds.r = Math.max(x1, x2);
|
|
2256
|
+
bounds.b = Math.max(y1, y2);
|
|
2257
|
+
instance.x1 = x1;
|
|
2258
|
+
instance.x2 = x2;
|
|
2259
|
+
instance.y1 = y1;
|
|
2260
|
+
instance.y2 = y2;
|
|
2261
|
+
return bounds;
|
|
2262
|
+
};
|
|
2263
|
+
_proto.render = function render(context, instance, key) {
|
|
2264
|
+
var _stateMods;
|
|
2265
|
+
var data = instance.data,
|
|
2266
|
+
x1 = instance.x1,
|
|
2267
|
+
x2 = instance.x2,
|
|
2268
|
+
y1 = instance.y1,
|
|
2269
|
+
y2 = instance.y2;
|
|
2270
|
+
if (!data.active || data.x1 === null || data.x2 === null || data.y1 === null || data.y2 === null) return null;
|
|
2271
|
+
var stateMods = ((_stateMods = {}), (_stateMods["color-" + data.colorIndex] = data.colorIndex != null), _stateMods);
|
|
2272
|
+
return /*#__PURE__*/ jsxs(
|
|
2273
|
+
"g",
|
|
2274
|
+
{
|
|
2275
|
+
className: data.classNames,
|
|
2276
|
+
children: [
|
|
2277
|
+
/*#__PURE__*/ jsx("line", {
|
|
2278
|
+
className: this.CSS.element(this.baseClass, "line", stateMods),
|
|
2279
|
+
style: data.style,
|
|
2280
|
+
x1: x1,
|
|
2281
|
+
y1: y1,
|
|
2282
|
+
x2: x2,
|
|
2283
|
+
y2: y2,
|
|
2284
|
+
}),
|
|
2285
|
+
this.renderChildren(context, instance),
|
|
2286
|
+
],
|
|
2287
|
+
},
|
|
2288
|
+
key
|
|
2289
|
+
);
|
|
2290
|
+
};
|
|
2291
|
+
return MarkerLine;
|
|
2292
|
+
})(BoundedObject);
|
|
2293
|
+
MarkerLine.prototype.xAxis = "x";
|
|
2294
|
+
MarkerLine.prototype.yAxis = "y";
|
|
2295
|
+
MarkerLine.prototype.anchors = "0 1 1 0";
|
|
2296
|
+
MarkerLine.prototype.baseClass = "markerline";
|
|
2297
|
+
MarkerLine.prototype.legend = "legend";
|
|
2298
|
+
MarkerLine.prototype.legendAction = "auto";
|
|
2299
|
+
MarkerLine.prototype.affectsAxes = true;
|
|
2300
|
+
BoundedObject.alias("marker-line", MarkerLine);
|
|
2301
|
+
|
|
2302
|
+
var Range = /*#__PURE__*/ (function (_BoundedObject) {
|
|
2303
|
+
_inheritsLoose(Range, _BoundedObject);
|
|
2304
|
+
function Range() {
|
|
2305
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
2306
|
+
}
|
|
2307
|
+
var _proto = Range.prototype;
|
|
2308
|
+
_proto.declareData = function declareData() {
|
|
2309
|
+
var _BoundedObject$protot;
|
|
2310
|
+
(_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
2311
|
+
_BoundedObject$protot,
|
|
2312
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
2313
|
+
{
|
|
2314
|
+
x1: undefined,
|
|
2315
|
+
y1: undefined,
|
|
2316
|
+
x2: undefined,
|
|
2317
|
+
y2: undefined,
|
|
2318
|
+
colorIndex: undefined,
|
|
2319
|
+
active: true,
|
|
2320
|
+
name: undefined,
|
|
2321
|
+
legend: undefined,
|
|
2322
|
+
},
|
|
2323
|
+
])
|
|
2324
|
+
);
|
|
2325
|
+
};
|
|
2326
|
+
_proto.explore = function explore(context, instance) {
|
|
2327
|
+
var data = instance.data;
|
|
2328
|
+
var xAxis = (instance.xAxis = context.axes[this.xAxis]);
|
|
2329
|
+
var yAxis = (instance.yAxis = context.axes[this.yAxis]);
|
|
2330
|
+
if (data.active) {
|
|
2331
|
+
if (xAxis) {
|
|
2332
|
+
if (data.x1 != null) instance.xAxis.acknowledge(data.x1, this.xSize, this.xOffset);
|
|
2333
|
+
if (data.x2 != null) instance.xAxis.acknowledge(data.x2, this.xSize, this.xOffset);
|
|
2334
|
+
}
|
|
2335
|
+
if (yAxis) {
|
|
2336
|
+
if (data.y1 != null) instance.yAxis.acknowledge(data.y1, this.ySize, this.yOffset);
|
|
2337
|
+
if (data.y2 != null) instance.yAxis.acknowledge(data.y2, this.ySize, this.yOffset);
|
|
2338
|
+
}
|
|
2339
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
_proto.prepare = function prepare(context, instance) {
|
|
2343
|
+
var _this = this;
|
|
2344
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
2345
|
+
var data = instance.data,
|
|
2346
|
+
xAxis = instance.xAxis,
|
|
2347
|
+
yAxis = instance.yAxis;
|
|
2348
|
+
if (xAxis && xAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
2349
|
+
if (yAxis && yAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
2350
|
+
if (data.name && data.legend && context.addLegendEntry)
|
|
2351
|
+
context.addLegendEntry(data.legend, {
|
|
2352
|
+
name: data.name,
|
|
2353
|
+
active: data.active,
|
|
2354
|
+
colorIndex: data.colorIndex,
|
|
2355
|
+
style: data.style,
|
|
2356
|
+
shape: "rect",
|
|
2357
|
+
onClick: function onClick(e) {
|
|
2358
|
+
_this.onLegendClick(e, instance);
|
|
2359
|
+
},
|
|
2360
|
+
});
|
|
2361
|
+
};
|
|
2362
|
+
_proto.onLegendClick = function onLegendClick(e, instance) {
|
|
2363
|
+
var allActions = this.legendAction == "auto";
|
|
2364
|
+
var data = instance.data;
|
|
2365
|
+
if (allActions || this.legendAction == "toggle") instance.set("active", !data.active);
|
|
2366
|
+
};
|
|
2367
|
+
_proto.calculateBounds = function calculateBounds(context, instance) {
|
|
2368
|
+
var bounds = _BoundedObject.prototype.calculateBounds.call(this, context, instance);
|
|
2369
|
+
var data = instance.data,
|
|
2370
|
+
xAxis = instance.xAxis,
|
|
2371
|
+
yAxis = instance.yAxis;
|
|
2372
|
+
if (data.x1 != null) bounds.l = xAxis.map(data.x1, this.xOffset - this.xSize / 2);
|
|
2373
|
+
if (data.x2 != null) bounds.r = xAxis.map(data.x2, this.xOffset + this.xSize / 2);
|
|
2374
|
+
if (data.y1 != null) bounds.t = yAxis.map(data.y1, this.yOffset - this.ySize / 2);
|
|
2375
|
+
if (data.y2 != null) bounds.b = yAxis.map(data.y2, this.yOffset + this.ySize / 2);
|
|
2376
|
+
return bounds;
|
|
2377
|
+
};
|
|
2378
|
+
_proto.render = function render(context, instance, key) {
|
|
2379
|
+
var _stateMods,
|
|
2380
|
+
_this2 = this;
|
|
2381
|
+
var data = instance.data;
|
|
2382
|
+
if (!data.active) return null;
|
|
2383
|
+
var bounds = data.bounds;
|
|
2384
|
+
var x1 = Math.min(bounds.l, bounds.r),
|
|
2385
|
+
y1 = Math.min(bounds.t, bounds.b),
|
|
2386
|
+
x2 = Math.max(bounds.l, bounds.r),
|
|
2387
|
+
y2 = Math.max(bounds.t, bounds.b);
|
|
2388
|
+
var stateMods = ((_stateMods = {}), (_stateMods["color-" + data.colorIndex] = data.colorIndex != null), _stateMods);
|
|
2389
|
+
return /*#__PURE__*/ jsxs(
|
|
2390
|
+
"g",
|
|
2391
|
+
{
|
|
2392
|
+
className: data.classNames,
|
|
2393
|
+
children: [
|
|
2394
|
+
!this.hidden &&
|
|
2395
|
+
/*#__PURE__*/ jsx("rect", {
|
|
2396
|
+
className: this.CSS.element(this.baseClass, "rect", stateMods),
|
|
2397
|
+
style: data.style,
|
|
2398
|
+
x: x1,
|
|
2399
|
+
y: y1,
|
|
2400
|
+
width: x2 - x1,
|
|
2401
|
+
height: y2 - y1,
|
|
2402
|
+
onMouseDown: function onMouseDown(e) {
|
|
2403
|
+
return _this2.handleMouseDown(e, instance);
|
|
2404
|
+
},
|
|
2405
|
+
onTouchStart: function onTouchStart(e) {
|
|
2406
|
+
return _this2.handleMouseDown(e, instance);
|
|
2407
|
+
},
|
|
2408
|
+
}),
|
|
2409
|
+
this.renderChildren(context, instance),
|
|
2410
|
+
],
|
|
2411
|
+
},
|
|
2412
|
+
key
|
|
2413
|
+
);
|
|
2414
|
+
};
|
|
2415
|
+
_proto.handleClick = function handleClick(e, instance) {
|
|
2416
|
+
if (this.onClick) instance.invoke("onClick", e, instance);
|
|
2417
|
+
};
|
|
2418
|
+
_proto.handleMouseDown = function handleMouseDown(e, instance) {
|
|
2419
|
+
var _this3 = this;
|
|
2420
|
+
if (this.draggableX || this.draggableY) {
|
|
2421
|
+
var svgEl = closest(e.target, function (el) {
|
|
2422
|
+
return el.tagName == "svg";
|
|
2423
|
+
});
|
|
2424
|
+
var svgBounds = getTopLevelBoundingClientRect(svgEl);
|
|
2425
|
+
var cursor = getCursorPos(e);
|
|
2426
|
+
var data = instance.data,
|
|
2427
|
+
xAxis = instance.xAxis,
|
|
2428
|
+
yAxis = instance.yAxis;
|
|
2429
|
+
var captureData = {
|
|
2430
|
+
svgBounds: svgBounds,
|
|
2431
|
+
start: {
|
|
2432
|
+
x1: data.x1,
|
|
2433
|
+
x2: data.x2,
|
|
2434
|
+
y1: data.y1,
|
|
2435
|
+
y2: data.y2,
|
|
2436
|
+
},
|
|
2437
|
+
};
|
|
2438
|
+
if (this.draggableX && xAxis)
|
|
2439
|
+
captureData.start.x = xAxis.trackValue(cursor.clientX - svgBounds.left, this.xOffset, this.constrainX);
|
|
2440
|
+
if (this.draggableY && yAxis)
|
|
2441
|
+
captureData.start.y = yAxis.trackValue(cursor.clientY - svgBounds.top, this.yOffset, this.constrainY);
|
|
2442
|
+
if (svgEl)
|
|
2443
|
+
captureMouseOrTouch(
|
|
2444
|
+
e,
|
|
2445
|
+
function (e, captureData) {
|
|
2446
|
+
_this3.handleDragMove(e, instance, captureData);
|
|
2447
|
+
},
|
|
2448
|
+
null,
|
|
2449
|
+
captureData,
|
|
2450
|
+
e.target.style.cursor
|
|
2451
|
+
);
|
|
2452
|
+
}
|
|
2453
|
+
};
|
|
2454
|
+
_proto.handleDragMove = function handleDragMove(e, instance, captureData) {
|
|
2455
|
+
var cursor = getCursorPos(e);
|
|
2456
|
+
var xAxis = instance.xAxis,
|
|
2457
|
+
yAxis = instance.yAxis;
|
|
2458
|
+
var svgBounds = captureData.svgBounds;
|
|
2459
|
+
captureData.start;
|
|
2460
|
+
if (this.draggableX && xAxis) {
|
|
2461
|
+
var dist = xAxis.trackValue(cursor.clientX - svgBounds.left, this.xOffset, this.constrainX) - captureData.start.x;
|
|
2462
|
+
var x1v = xAxis.decodeValue(captureData.start.x1);
|
|
2463
|
+
var x2v = xAxis.decodeValue(captureData.start.x2);
|
|
2464
|
+
if (this.constrainX) {
|
|
2465
|
+
if (dist > 0) dist = Math.min(xAxis.constrainValue(x2v + dist) - x2v, dist);
|
|
2466
|
+
else dist = Math.max(xAxis.constrainValue(x1v + dist) - x1v, dist);
|
|
2467
|
+
}
|
|
2468
|
+
instance.set("x1", xAxis.encodeValue(x1v + dist));
|
|
2469
|
+
instance.set("x2", xAxis.encodeValue(x2v + dist));
|
|
2470
|
+
}
|
|
2471
|
+
if (this.draggableY && yAxis) {
|
|
2472
|
+
var dist = yAxis.trackValue(cursor.clientY - svgBounds.left, this.yOffset, this.constrainY) - captureData.start.y;
|
|
2473
|
+
var y1v = yAxis.decodeValue(captureData.start.y1);
|
|
2474
|
+
var y2v = yAxis.decodeValue(captureData.start.y2);
|
|
2475
|
+
if (this.constrainY)
|
|
2476
|
+
dist = Math.max(yAxis.constrainValue(y1v + dist) - y1v, Math.min(yAxis.constrainValue(y2v + dist) - y2v, dist));
|
|
2477
|
+
instance.set("y1", yAxis.encodeValue(y1v + dist));
|
|
2478
|
+
instance.set("y2", yAxis.encodeValue(y2v + dist));
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
return Range;
|
|
2482
|
+
})(BoundedObject);
|
|
2483
|
+
Range.prototype.invisible = false;
|
|
2484
|
+
Range.prototype.xAxis = "x";
|
|
2485
|
+
Range.prototype.yAxis = "y";
|
|
2486
|
+
Range.prototype.xSize = 0;
|
|
2487
|
+
Range.prototype.ySize = 0;
|
|
2488
|
+
Range.prototype.xOffset = 0;
|
|
2489
|
+
Range.prototype.yOffset = 0;
|
|
2490
|
+
Range.prototype.anchors = "0 1 1 0";
|
|
2491
|
+
Range.prototype.baseClass = "range";
|
|
2492
|
+
Range.prototype.legend = "legend";
|
|
2493
|
+
Range.prototype.legendAction = "auto";
|
|
2494
|
+
BoundedObject.alias("range", Range);
|
|
2495
|
+
|
|
2496
|
+
var Gridlines = /*#__PURE__*/ (function (_BoundedObject) {
|
|
2497
|
+
_inheritsLoose(Gridlines, _BoundedObject);
|
|
2498
|
+
function Gridlines() {
|
|
2499
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
2500
|
+
}
|
|
2501
|
+
var _proto = Gridlines.prototype;
|
|
2502
|
+
_proto.explore = function explore(context, instance) {
|
|
2503
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
2504
|
+
instance.xAxis = context.axes[this.xAxis];
|
|
2505
|
+
instance.yAxis = context.axes[this.yAxis];
|
|
2506
|
+
};
|
|
2507
|
+
_proto.prepare = function prepare(context, instance) {
|
|
2508
|
+
_BoundedObject.prototype.prepare.call(this, context, instance);
|
|
2509
|
+
var xAxis = instance.xAxis,
|
|
2510
|
+
yAxis = instance.yAxis;
|
|
2511
|
+
if ((xAxis && xAxis.shouldUpdate) || (yAxis && yAxis.shouldUpdate)) instance.markShouldUpdate(context);
|
|
2512
|
+
};
|
|
2513
|
+
_proto.render = function render(context, instance, key) {
|
|
2514
|
+
var data = instance.data,
|
|
2515
|
+
xAxis = instance.xAxis,
|
|
2516
|
+
yAxis = instance.yAxis;
|
|
2517
|
+
var bounds = data.bounds;
|
|
2518
|
+
var path = "",
|
|
2519
|
+
xTicks,
|
|
2520
|
+
yTicks;
|
|
2521
|
+
if (xAxis) {
|
|
2522
|
+
xTicks = xAxis.mapGridlines();
|
|
2523
|
+
xTicks.forEach(function (x) {
|
|
2524
|
+
path += "M " + x + " " + bounds.t + " L " + x + " " + bounds.b;
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
if (yAxis) {
|
|
2528
|
+
yTicks = yAxis.mapGridlines();
|
|
2529
|
+
yTicks.forEach(function (y) {
|
|
2530
|
+
path += "M " + bounds.l + " " + y + " L " + bounds.r + " " + y;
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
return /*#__PURE__*/ jsx(
|
|
2534
|
+
"g",
|
|
2535
|
+
{
|
|
2536
|
+
className: data.classNames,
|
|
2537
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
2538
|
+
style: data.style,
|
|
2539
|
+
d: path,
|
|
2540
|
+
}),
|
|
2541
|
+
},
|
|
2542
|
+
key
|
|
2543
|
+
);
|
|
2544
|
+
};
|
|
2545
|
+
return Gridlines;
|
|
2546
|
+
})(BoundedObject);
|
|
2547
|
+
Gridlines.prototype.xAxis = "x";
|
|
2548
|
+
Gridlines.prototype.yAxis = "y";
|
|
2549
|
+
Gridlines.prototype.anchors = "0 1 1 0";
|
|
2550
|
+
Gridlines.prototype.baseClass = "gridlines";
|
|
2551
|
+
BoundedObject.alias("gridlines", Gridlines);
|
|
2552
|
+
|
|
2553
|
+
var LineGraph = /*#__PURE__*/ (function (_Widget) {
|
|
2554
|
+
_inheritsLoose(LineGraph, _Widget);
|
|
2555
|
+
function LineGraph() {
|
|
2556
|
+
return _Widget.apply(this, arguments) || this;
|
|
2557
|
+
}
|
|
2558
|
+
var _proto = LineGraph.prototype;
|
|
2559
|
+
_proto.declareData = function declareData() {
|
|
2560
|
+
var _Widget$prototype$dec;
|
|
2561
|
+
(_Widget$prototype$dec = _Widget.prototype.declareData).call.apply(
|
|
2562
|
+
_Widget$prototype$dec,
|
|
2563
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
2564
|
+
{
|
|
2565
|
+
data: undefined,
|
|
2566
|
+
colorIndex: undefined,
|
|
2567
|
+
colorMap: undefined,
|
|
2568
|
+
class: {
|
|
2569
|
+
structured: true,
|
|
2570
|
+
},
|
|
2571
|
+
className: {
|
|
2572
|
+
structured: true,
|
|
2573
|
+
},
|
|
2574
|
+
lineStyle: {
|
|
2575
|
+
structured: true,
|
|
2576
|
+
},
|
|
2577
|
+
areaStyle: {
|
|
2578
|
+
structured: true,
|
|
2579
|
+
},
|
|
2580
|
+
area: undefined,
|
|
2581
|
+
line: undefined,
|
|
2582
|
+
y0: undefined,
|
|
2583
|
+
name: undefined,
|
|
2584
|
+
active: true,
|
|
2585
|
+
stack: undefined,
|
|
2586
|
+
stacked: undefined,
|
|
2587
|
+
},
|
|
2588
|
+
])
|
|
2589
|
+
);
|
|
2590
|
+
};
|
|
2591
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
2592
|
+
var data = instance.data;
|
|
2593
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
2594
|
+
_Widget.prototype.prepareData.call(this, context, instance);
|
|
2595
|
+
};
|
|
2596
|
+
_proto.explore = function explore(context, instance) {
|
|
2597
|
+
var _this = this;
|
|
2598
|
+
var data = instance.data;
|
|
2599
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
2600
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
2601
|
+
if (data.active) {
|
|
2602
|
+
instance.axes = context.axes;
|
|
2603
|
+
instance.xAxis = instance.axes[this.xAxis];
|
|
2604
|
+
instance.yAxis = instance.axes[this.yAxis];
|
|
2605
|
+
_Widget.prototype.explore.call(this, context, instance);
|
|
2606
|
+
if (isArray(data.data)) {
|
|
2607
|
+
data.data.forEach(function (p, index) {
|
|
2608
|
+
var x = p[_this.xField];
|
|
2609
|
+
instance.xAxis.acknowledge(x);
|
|
2610
|
+
if (data.stacked) {
|
|
2611
|
+
instance.yAxis.stacknowledge(data.stack, x, _this.y0Field ? p[_this.y0Field] : data.y0);
|
|
2612
|
+
instance.yAxis.stacknowledge(data.stack, x, p[_this.yField]);
|
|
2613
|
+
} else {
|
|
2614
|
+
instance.yAxis.acknowledge(p[_this.yField]);
|
|
2615
|
+
if (data.area) {
|
|
2616
|
+
if (!_this.hiddenBase) instance.yAxis.acknowledge(_this.y0Field ? p[_this.y0Field] : data.y0);
|
|
2617
|
+
if (context.pointReducer && _this.y0Field)
|
|
2618
|
+
context.pointReducer(x, p[_this.y0Field], data.name, p, data, index);
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
if (context.pointReducer) context.pointReducer(x, p[_this.yField], data.name, p, data, index);
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
};
|
|
2626
|
+
_proto.prepare = function prepare(context, instance) {
|
|
2627
|
+
var _this2 = this;
|
|
2628
|
+
var data = instance.data,
|
|
2629
|
+
colorMap = instance.colorMap;
|
|
2630
|
+
if (colorMap && data.colorName) {
|
|
2631
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
2632
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
2633
|
+
}
|
|
2634
|
+
if (data.active) {
|
|
2635
|
+
if (instance.axes[this.xAxis].shouldUpdate || instance.axes[this.yAxis].shouldUpdate)
|
|
2636
|
+
instance.markShouldUpdate(context);
|
|
2637
|
+
}
|
|
2638
|
+
if (data.name && context.addLegendEntry)
|
|
2639
|
+
context.addLegendEntry(this.legend, {
|
|
2640
|
+
name: data.name,
|
|
2641
|
+
active: data.active,
|
|
2642
|
+
colorIndex: data.colorIndex,
|
|
2643
|
+
disabled: data.disabled,
|
|
2644
|
+
//selected: this.selection.isInstanceSelected(instance),
|
|
2645
|
+
style: parseStyle(data.style || data.lineStyle),
|
|
2646
|
+
shape: this.legendShape,
|
|
2647
|
+
onClick: function onClick(e) {
|
|
2648
|
+
_this2.onLegendClick(e, instance);
|
|
2649
|
+
},
|
|
2650
|
+
});
|
|
2651
|
+
};
|
|
2652
|
+
_proto.onLegendClick = function onLegendClick(e, instance) {
|
|
2653
|
+
var allActions = this.legendAction == "auto";
|
|
2654
|
+
var data = instance.data;
|
|
2655
|
+
if (allActions || this.legendAction == "toggle") instance.set("active", !data.active);
|
|
2656
|
+
};
|
|
2657
|
+
_proto.render = function render(context, instance, key) {
|
|
2658
|
+
var _this3 = this,
|
|
2659
|
+
_stateMods;
|
|
2660
|
+
var data = instance.data,
|
|
2661
|
+
xAxis = instance.xAxis,
|
|
2662
|
+
yAxis = instance.yAxis;
|
|
2663
|
+
if (!data.active) return null;
|
|
2664
|
+
var spans = [];
|
|
2665
|
+
var span = [];
|
|
2666
|
+
isArray(data.data) &&
|
|
2667
|
+
data.data.forEach(function (p) {
|
|
2668
|
+
var ax = p[_this3.xField],
|
|
2669
|
+
ay = p[_this3.yField],
|
|
2670
|
+
ay0 = _this3.y0Field ? p[_this3.y0Field] : data.y0,
|
|
2671
|
+
x,
|
|
2672
|
+
y,
|
|
2673
|
+
y0;
|
|
2674
|
+
if (ax != null && ay != null && ay0 != null) {
|
|
2675
|
+
x = xAxis.map(ax);
|
|
2676
|
+
y0 = data.stacked ? yAxis.stack(data.stack, ax, ay0) : yAxis.map(ay0);
|
|
2677
|
+
y = data.stacked ? yAxis.stack(data.stack, ax, ay) : yAxis.map(ay);
|
|
2678
|
+
}
|
|
2679
|
+
if (x != null && y != null && y0 != null)
|
|
2680
|
+
span.push({
|
|
2681
|
+
x: x,
|
|
2682
|
+
y: y,
|
|
2683
|
+
y0: y0,
|
|
2684
|
+
});
|
|
2685
|
+
else if (span.length > 0) {
|
|
2686
|
+
spans.push(span);
|
|
2687
|
+
span = [];
|
|
2688
|
+
}
|
|
2689
|
+
});
|
|
2690
|
+
if (span.length > 0) spans.push(span);
|
|
2691
|
+
var stateMods = ((_stateMods = {}), (_stateMods["color-" + data.colorIndex] = data.colorIndex != null), _stateMods);
|
|
2692
|
+
var line, area;
|
|
2693
|
+
if (data.line) {
|
|
2694
|
+
var linePath = "";
|
|
2695
|
+
spans.forEach(function (span) {
|
|
2696
|
+
span.forEach(function (p, i) {
|
|
2697
|
+
linePath += i == 0 ? " M " : " L ";
|
|
2698
|
+
linePath += p.x + " " + p.y;
|
|
2699
|
+
});
|
|
2700
|
+
});
|
|
2701
|
+
line = /*#__PURE__*/ jsx("path", {
|
|
2702
|
+
className: this.CSS.element(this.baseClass, "line", stateMods),
|
|
2703
|
+
style: this.CSS.parseStyle(data.lineStyle),
|
|
2704
|
+
d: linePath,
|
|
2705
|
+
});
|
|
2706
|
+
}
|
|
2707
|
+
if (data.area) {
|
|
2708
|
+
var areaPath = "";
|
|
2709
|
+
spans.forEach(function (span) {
|
|
2710
|
+
var closePath = "";
|
|
2711
|
+
span.forEach(function (p, i) {
|
|
2712
|
+
areaPath += i == 0 ? " M " : " L ";
|
|
2713
|
+
areaPath += p.x + " " + p.y;
|
|
2714
|
+
if (data.area) closePath = "L " + p.x + " " + p.y0 + " " + closePath;
|
|
2715
|
+
});
|
|
2716
|
+
areaPath += closePath;
|
|
2717
|
+
areaPath += "L " + span[0].x + " " + span[0].y;
|
|
2718
|
+
});
|
|
2719
|
+
area = /*#__PURE__*/ jsx("path", {
|
|
2720
|
+
className: this.CSS.element(this.baseClass, "area", stateMods),
|
|
2721
|
+
style: this.CSS.parseStyle(data.areaStyle),
|
|
2722
|
+
d: areaPath,
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
return /*#__PURE__*/ jsxs(
|
|
2726
|
+
"g",
|
|
2727
|
+
{
|
|
2728
|
+
className: data.classNames,
|
|
2729
|
+
children: [line, area],
|
|
2730
|
+
},
|
|
2731
|
+
key
|
|
2732
|
+
);
|
|
2733
|
+
};
|
|
2734
|
+
return LineGraph;
|
|
2735
|
+
})(Widget);
|
|
2736
|
+
LineGraph.prototype.xAxis = "x";
|
|
2737
|
+
LineGraph.prototype.yAxis = "y";
|
|
2738
|
+
LineGraph.prototype.area = false;
|
|
2739
|
+
LineGraph.prototype.line = true;
|
|
2740
|
+
LineGraph.prototype.xField = "x";
|
|
2741
|
+
LineGraph.prototype.yField = "y";
|
|
2742
|
+
LineGraph.prototype.baseClass = "linegraph";
|
|
2743
|
+
LineGraph.prototype.y0 = 0;
|
|
2744
|
+
LineGraph.prototype.y0Field = false;
|
|
2745
|
+
LineGraph.prototype.active = true;
|
|
2746
|
+
LineGraph.prototype.legend = "legend";
|
|
2747
|
+
LineGraph.prototype.legendAction = "auto";
|
|
2748
|
+
LineGraph.prototype.legendShape = "rect";
|
|
2749
|
+
LineGraph.prototype.stack = "stack";
|
|
2750
|
+
LineGraph.prototype.hiddenBase = false;
|
|
2751
|
+
Widget.alias("line-graph", LineGraph);
|
|
2752
|
+
|
|
2753
|
+
var ColumnBarGraphBase = /*#__PURE__*/ (function (_Widget) {
|
|
2754
|
+
_inheritsLoose(ColumnBarGraphBase, _Widget);
|
|
2755
|
+
function ColumnBarGraphBase() {
|
|
2756
|
+
return _Widget.apply(this, arguments) || this;
|
|
2757
|
+
}
|
|
2758
|
+
var _proto = ColumnBarGraphBase.prototype;
|
|
2759
|
+
_proto.init = function init() {
|
|
2760
|
+
this.selection = Selection.create(this.selection, {
|
|
2761
|
+
records: this.data,
|
|
2762
|
+
});
|
|
2763
|
+
_Widget.prototype.init.call(this);
|
|
2764
|
+
};
|
|
2765
|
+
_proto.declareData = function declareData() {
|
|
2766
|
+
var _Widget$prototype$dec;
|
|
2767
|
+
var selection = this.selection.configureWidget(this);
|
|
2768
|
+
(_Widget$prototype$dec = _Widget.prototype.declareData).call.apply(
|
|
2769
|
+
_Widget$prototype$dec,
|
|
2770
|
+
[this, selection].concat(Array.prototype.slice.call(arguments), [
|
|
2771
|
+
{
|
|
2772
|
+
data: undefined,
|
|
2773
|
+
colorIndex: undefined,
|
|
2774
|
+
colorMap: undefined,
|
|
2775
|
+
colorName: undefined,
|
|
2776
|
+
name: undefined,
|
|
2777
|
+
size: undefined,
|
|
2778
|
+
offset: undefined,
|
|
2779
|
+
y0: undefined,
|
|
2780
|
+
x0: undefined,
|
|
2781
|
+
autoSize: undefined,
|
|
2782
|
+
active: true,
|
|
2783
|
+
stacked: undefined,
|
|
2784
|
+
stack: undefined,
|
|
2785
|
+
},
|
|
2786
|
+
])
|
|
2787
|
+
);
|
|
2788
|
+
};
|
|
2789
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
2790
|
+
var data = instance.data;
|
|
2791
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
2792
|
+
_Widget.prototype.prepareData.call(this, context, instance);
|
|
2793
|
+
};
|
|
2794
|
+
_proto.explore = function explore(context, instance) {
|
|
2795
|
+
instance.xAxis = context.axes[this.xAxis];
|
|
2796
|
+
instance.yAxis = context.axes[this.yAxis];
|
|
2797
|
+
var data = instance.data;
|
|
2798
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
2799
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
2800
|
+
_Widget.prototype.explore.call(this, context, instance);
|
|
2801
|
+
};
|
|
2802
|
+
_proto.prepare = function prepare(context, instance) {
|
|
2803
|
+
var _this = this;
|
|
2804
|
+
var data = instance.data,
|
|
2805
|
+
colorMap = instance.colorMap,
|
|
2806
|
+
xAxis = instance.xAxis,
|
|
2807
|
+
yAxis = instance.yAxis;
|
|
2808
|
+
if (colorMap && data.name) {
|
|
2809
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
2810
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
2811
|
+
}
|
|
2812
|
+
if (xAxis.shouldUpdate || yAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
2813
|
+
if (data.name && context.addLegendEntry)
|
|
2814
|
+
context.addLegendEntry(this.legend, {
|
|
2815
|
+
name: data.name,
|
|
2816
|
+
active: data.active,
|
|
2817
|
+
colorIndex: data.colorIndex,
|
|
2818
|
+
disabled: data.disabled,
|
|
2819
|
+
selected: this.selection.isInstanceSelected(instance),
|
|
2820
|
+
style: data.style,
|
|
2821
|
+
shape: this.legendShape,
|
|
2822
|
+
onClick: function onClick(e) {
|
|
2823
|
+
_this.onLegendClick(e, instance);
|
|
2824
|
+
},
|
|
2825
|
+
});
|
|
2826
|
+
};
|
|
2827
|
+
_proto.onLegendClick = function onLegendClick(e, instance) {
|
|
2828
|
+
var allActions = this.legendAction == "auto";
|
|
2829
|
+
var data = instance.data;
|
|
2830
|
+
if (allActions || this.legendAction == "toggle") instance.set("active", !data.active);
|
|
2831
|
+
};
|
|
2832
|
+
_proto.render = function render(context, instance, key) {
|
|
2833
|
+
var data = instance.data;
|
|
2834
|
+
return /*#__PURE__*/ jsx(
|
|
2835
|
+
"g",
|
|
2836
|
+
{
|
|
2837
|
+
className: data.classNames,
|
|
2838
|
+
children: data.active && this.renderGraph(context, instance),
|
|
2839
|
+
},
|
|
2840
|
+
key
|
|
2841
|
+
);
|
|
2842
|
+
};
|
|
2843
|
+
_proto.handleClick = function handleClick(e, instance, point, index) {
|
|
2844
|
+
if (this.onClick && instance.invoke("onClick", e, instance, point, index) === false) return;
|
|
2845
|
+
if (!this.selection.isDummy)
|
|
2846
|
+
this.selection.select(instance.store, point, index, {
|
|
2847
|
+
toggle: e.ctrlKey,
|
|
2848
|
+
});
|
|
2849
|
+
};
|
|
2850
|
+
return ColumnBarGraphBase;
|
|
2851
|
+
})(Widget);
|
|
2852
|
+
ColumnBarGraphBase.prototype.xAxis = "x";
|
|
2853
|
+
ColumnBarGraphBase.prototype.yAxis = "y";
|
|
2854
|
+
ColumnBarGraphBase.prototype.xField = "x";
|
|
2855
|
+
ColumnBarGraphBase.prototype.yField = "y";
|
|
2856
|
+
ColumnBarGraphBase.prototype.colorIndexField = false;
|
|
2857
|
+
ColumnBarGraphBase.prototype.size = 1;
|
|
2858
|
+
ColumnBarGraphBase.prototype.legend = "legend";
|
|
2859
|
+
ColumnBarGraphBase.prototype.legendAction = "auto";
|
|
2860
|
+
ColumnBarGraphBase.prototype.legendShape = "rect";
|
|
2861
|
+
ColumnBarGraphBase.prototype.stack = "stack";
|
|
2862
|
+
ColumnBarGraphBase.prototype.stacked = false;
|
|
2863
|
+
ColumnBarGraphBase.prototype.autoSize = 0;
|
|
2864
|
+
ColumnBarGraphBase.prototype.offset = 0;
|
|
2865
|
+
ColumnBarGraphBase.prototype.styled = true;
|
|
2866
|
+
|
|
2867
|
+
var ColumnGraph = /*#__PURE__*/ (function (_ColumnBarGraphBase) {
|
|
2868
|
+
_inheritsLoose(ColumnGraph, _ColumnBarGraphBase);
|
|
2869
|
+
function ColumnGraph() {
|
|
2870
|
+
return _ColumnBarGraphBase.apply(this, arguments) || this;
|
|
2871
|
+
}
|
|
2872
|
+
var _proto = ColumnGraph.prototype;
|
|
2873
|
+
_proto.explore = function explore(context, instance) {
|
|
2874
|
+
var _this = this;
|
|
2875
|
+
_ColumnBarGraphBase.prototype.explore.call(this, context, instance);
|
|
2876
|
+
var data = instance.data,
|
|
2877
|
+
xAxis = instance.xAxis,
|
|
2878
|
+
yAxis = instance.yAxis;
|
|
2879
|
+
if (isArray(data.data)) {
|
|
2880
|
+
data.data.forEach(function (p, index) {
|
|
2881
|
+
var y0 = _this.y0Field ? p[_this.y0Field] : data.y0;
|
|
2882
|
+
var x = p[_this.xField];
|
|
2883
|
+
var y = p[_this.yField];
|
|
2884
|
+
xAxis.acknowledge(x, data.size, data.offset);
|
|
2885
|
+
if (data.autoSize) xAxis.book(x, data.stacked ? data.stack : data.name);
|
|
2886
|
+
if (data.stacked) {
|
|
2887
|
+
yAxis.stacknowledge(data.stack, x, y0);
|
|
2888
|
+
yAxis.stacknowledge(data.stack, x, y);
|
|
2889
|
+
} else {
|
|
2890
|
+
if (!_this.hiddenBase) yAxis.acknowledge(y0);
|
|
2891
|
+
yAxis.acknowledge(y);
|
|
2892
|
+
}
|
|
2893
|
+
if (context.pointReducer) context.pointReducer(x, y, data.name, p, data, index);
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
};
|
|
2897
|
+
_proto.renderGraph = function renderGraph(context, instance) {
|
|
2898
|
+
var _this2 = this;
|
|
2899
|
+
var data = instance.data,
|
|
2900
|
+
xAxis = instance.xAxis,
|
|
2901
|
+
yAxis = instance.yAxis,
|
|
2902
|
+
store = instance.store;
|
|
2903
|
+
if (!isArray(data.data)) return false;
|
|
2904
|
+
var isSelected = this.selection.getIsSelectedDelegate(store);
|
|
2905
|
+
return data.data.map(function (p, i) {
|
|
2906
|
+
var _state;
|
|
2907
|
+
var offset = data.offset,
|
|
2908
|
+
size = data.size;
|
|
2909
|
+
var y0 = _this2.y0Field ? p[_this2.y0Field] : data.y0;
|
|
2910
|
+
var x = p[_this2.xField];
|
|
2911
|
+
var y = p[_this2.yField];
|
|
2912
|
+
if (data.autoSize) {
|
|
2913
|
+
var _instance$xAxis$locat = instance.xAxis.locate(x, data.stacked ? data.stack : data.name),
|
|
2914
|
+
index = _instance$xAxis$locat[0],
|
|
2915
|
+
count = _instance$xAxis$locat[1];
|
|
2916
|
+
offset = (size / count) * (index - count / 2 + 0.5);
|
|
2917
|
+
size = size / count;
|
|
2918
|
+
}
|
|
2919
|
+
var x1 = xAxis.map(x, offset - size / 2);
|
|
2920
|
+
var x2 = xAxis.map(x, offset + size / 2);
|
|
2921
|
+
var y1 = data.stacked ? yAxis.stack(data.stack, x, y0) : yAxis.map(y0);
|
|
2922
|
+
var y2 = data.stacked ? yAxis.stack(data.stack, x, y) : yAxis.map(y);
|
|
2923
|
+
var color = _this2.colorIndexField ? p[_this2.colorIndexField] : data.colorIndex;
|
|
2924
|
+
var state =
|
|
2925
|
+
((_state = {
|
|
2926
|
+
selected: isSelected(p, i),
|
|
2927
|
+
selectable: !_this2.selection.isDummy,
|
|
2928
|
+
}),
|
|
2929
|
+
(_state["color-" + color] = color != null),
|
|
2930
|
+
_state);
|
|
2931
|
+
var mmove, mleave;
|
|
2932
|
+
if (_this2.tooltip) {
|
|
2933
|
+
mmove = function mmove(e) {
|
|
2934
|
+
return tooltipMouseMove(e, instance, _this2.tooltip, {
|
|
2935
|
+
target: e.target.parent,
|
|
2936
|
+
data: {
|
|
2937
|
+
$record: p,
|
|
2938
|
+
},
|
|
2939
|
+
});
|
|
2940
|
+
};
|
|
2941
|
+
mleave = function mleave(e) {
|
|
2942
|
+
return tooltipMouseLeave(e, instance, _this2.tooltip, {
|
|
2943
|
+
target: e.target.parent,
|
|
2944
|
+
data: {
|
|
2945
|
+
$record: p,
|
|
2946
|
+
},
|
|
2947
|
+
});
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
return /*#__PURE__*/ jsx(
|
|
2951
|
+
"rect",
|
|
2952
|
+
{
|
|
2953
|
+
className: _this2.CSS.element(_this2.baseClass, "column", state),
|
|
2954
|
+
onClick: function onClick(e) {
|
|
2955
|
+
_this2.handleClick(e, instance, p, i);
|
|
2956
|
+
},
|
|
2957
|
+
x: Math.min(x1, x2),
|
|
2958
|
+
y: Math.min(y1, y2),
|
|
2959
|
+
width: Math.abs(x2 - x1),
|
|
2960
|
+
height: Math.abs(y2 - y1),
|
|
2961
|
+
style: data.style,
|
|
2962
|
+
onMouseMove: mmove,
|
|
2963
|
+
onMouseLeave: mleave,
|
|
2964
|
+
},
|
|
2965
|
+
i
|
|
2966
|
+
);
|
|
2967
|
+
});
|
|
2968
|
+
};
|
|
2969
|
+
return ColumnGraph;
|
|
2970
|
+
})(ColumnBarGraphBase);
|
|
2971
|
+
ColumnGraph.prototype.baseClass = "columngraph";
|
|
2972
|
+
ColumnGraph.prototype.y0Field = false;
|
|
2973
|
+
ColumnGraph.prototype.y0 = 0;
|
|
2974
|
+
ColumnGraph.prototype.legendShape = "column";
|
|
2975
|
+
ColumnGraph.prototype.hiddenBase = false;
|
|
2976
|
+
Widget.alias("columngraph", ColumnGraph);
|
|
2977
|
+
|
|
2978
|
+
var BarGraph = /*#__PURE__*/ (function (_ColumnBarGraphBase) {
|
|
2979
|
+
_inheritsLoose(BarGraph, _ColumnBarGraphBase);
|
|
2980
|
+
function BarGraph() {
|
|
2981
|
+
return _ColumnBarGraphBase.apply(this, arguments) || this;
|
|
2982
|
+
}
|
|
2983
|
+
var _proto = BarGraph.prototype;
|
|
2984
|
+
_proto.explore = function explore(context, instance) {
|
|
2985
|
+
var _this = this;
|
|
2986
|
+
_ColumnBarGraphBase.prototype.explore.call(this, context, instance);
|
|
2987
|
+
var data = instance.data,
|
|
2988
|
+
yAxis = instance.yAxis,
|
|
2989
|
+
xAxis = instance.xAxis;
|
|
2990
|
+
if (isArray(data.data)) {
|
|
2991
|
+
data.data.forEach(function (p) {
|
|
2992
|
+
var x0 = _this.x0Field ? p[_this.x0Field] : data.x0;
|
|
2993
|
+
var y = p[_this.yField];
|
|
2994
|
+
var x = p[_this.xField];
|
|
2995
|
+
yAxis.acknowledge(y, data.size, data.offset);
|
|
2996
|
+
if (data.autoSize) yAxis.book(y, data.stacked ? data.stack : data.name);
|
|
2997
|
+
if (data.stacked) {
|
|
2998
|
+
xAxis.stacknowledge(data.stack, y, x0);
|
|
2999
|
+
xAxis.stacknowledge(data.stack, y, x);
|
|
3000
|
+
} else {
|
|
3001
|
+
if (!_this.hiddenBase) xAxis.acknowledge(x0);
|
|
3002
|
+
xAxis.acknowledge(x);
|
|
3003
|
+
}
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
_proto.renderGraph = function renderGraph(context, instance) {
|
|
3008
|
+
var _this2 = this;
|
|
3009
|
+
var data = instance.data,
|
|
3010
|
+
yAxis = instance.yAxis,
|
|
3011
|
+
xAxis = instance.xAxis,
|
|
3012
|
+
store = instance.store;
|
|
3013
|
+
if (!isArray(data.data)) return false;
|
|
3014
|
+
var isSelected = this.selection.getIsSelectedDelegate(store);
|
|
3015
|
+
return data.data.map(function (p, i) {
|
|
3016
|
+
var _state;
|
|
3017
|
+
var offset = data.offset,
|
|
3018
|
+
size = data.size;
|
|
3019
|
+
var x0 = _this2.x0Field ? p[_this2.x0Field] : data.x0;
|
|
3020
|
+
var y = p[_this2.yField];
|
|
3021
|
+
var x = p[_this2.xField];
|
|
3022
|
+
if (data.autoSize) {
|
|
3023
|
+
var _instance$yAxis$locat = instance.yAxis.locate(y, data.stacked ? data.stack : data.name),
|
|
3024
|
+
index = _instance$yAxis$locat[0],
|
|
3025
|
+
count = _instance$yAxis$locat[1];
|
|
3026
|
+
offset = (size / count) * (index - count / 2 + 0.5);
|
|
3027
|
+
size = size / count;
|
|
3028
|
+
}
|
|
3029
|
+
var y1 = yAxis.map(y, offset - size / 2);
|
|
3030
|
+
var y2 = yAxis.map(y, offset + size / 2);
|
|
3031
|
+
var x1 = data.stacked ? xAxis.stack(data.stack, y, x0) : xAxis.map(x0);
|
|
3032
|
+
var x2 = data.stacked ? xAxis.stack(data.stack, y, x) : xAxis.map(x);
|
|
3033
|
+
var color = _this2.colorIndexField ? p[_this2.colorIndexField] : data.colorIndex;
|
|
3034
|
+
var state =
|
|
3035
|
+
((_state = {
|
|
3036
|
+
selected: isSelected(p, i),
|
|
3037
|
+
selectable: !_this2.selection.isDummy,
|
|
3038
|
+
}),
|
|
3039
|
+
(_state["color-" + color] = color != null),
|
|
3040
|
+
_state);
|
|
3041
|
+
var mmove, mleave;
|
|
3042
|
+
if (_this2.tooltip) {
|
|
3043
|
+
mmove = function mmove(e) {
|
|
3044
|
+
return tooltipMouseMove(e, instance, _this2.tooltip, {
|
|
3045
|
+
target: e.target.parent,
|
|
3046
|
+
data: {
|
|
3047
|
+
$record: p,
|
|
3048
|
+
},
|
|
3049
|
+
});
|
|
3050
|
+
};
|
|
3051
|
+
mleave = function mleave(e) {
|
|
3052
|
+
return tooltipMouseLeave(e, instance, _this2.tooltip, {
|
|
3053
|
+
target: e.target.parent,
|
|
3054
|
+
data: {
|
|
3055
|
+
$record: p,
|
|
3056
|
+
},
|
|
3057
|
+
});
|
|
3058
|
+
};
|
|
3059
|
+
}
|
|
3060
|
+
return /*#__PURE__*/ jsx(
|
|
3061
|
+
"rect",
|
|
3062
|
+
{
|
|
3063
|
+
className: _this2.CSS.element(_this2.baseClass, "bar", state),
|
|
3064
|
+
onClick: function onClick(e) {
|
|
3065
|
+
_this2.handleClick(e, instance, p, i);
|
|
3066
|
+
},
|
|
3067
|
+
x: Math.min(x1, x2),
|
|
3068
|
+
y: Math.min(y1, y2),
|
|
3069
|
+
width: Math.abs(x2 - x1),
|
|
3070
|
+
height: Math.abs(y2 - y1),
|
|
3071
|
+
style: data.style,
|
|
3072
|
+
onMouseMove: mmove,
|
|
3073
|
+
onMouseLeave: mleave,
|
|
3074
|
+
},
|
|
3075
|
+
i
|
|
3076
|
+
);
|
|
3077
|
+
});
|
|
3078
|
+
};
|
|
3079
|
+
return BarGraph;
|
|
3080
|
+
})(ColumnBarGraphBase);
|
|
3081
|
+
BarGraph.prototype.baseClass = "bargraph";
|
|
3082
|
+
BarGraph.prototype.x0Field = false;
|
|
3083
|
+
BarGraph.prototype.x0 = 0;
|
|
3084
|
+
BarGraph.prototype.legendShape = "bar";
|
|
3085
|
+
BarGraph.prototype.hiddenBase = false;
|
|
3086
|
+
Widget.alias("bargraph", BarGraph);
|
|
3087
|
+
|
|
3088
|
+
var ScatterGraph = /*#__PURE__*/ (function (_Widget) {
|
|
3089
|
+
_inheritsLoose(ScatterGraph, _Widget);
|
|
3090
|
+
function ScatterGraph() {
|
|
3091
|
+
return _Widget.apply(this, arguments) || this;
|
|
3092
|
+
}
|
|
3093
|
+
var _proto = ScatterGraph.prototype;
|
|
3094
|
+
_proto.init = function init() {
|
|
3095
|
+
this.selection = Selection.create(this.selection, {
|
|
3096
|
+
records: this.data,
|
|
3097
|
+
});
|
|
3098
|
+
_Widget.prototype.init.call(this);
|
|
3099
|
+
};
|
|
3100
|
+
_proto.declareData = function declareData() {
|
|
3101
|
+
var _Widget$prototype$dec;
|
|
3102
|
+
var selection = this.selection.configureWidget(this);
|
|
3103
|
+
(_Widget$prototype$dec = _Widget.prototype.declareData).call.apply(
|
|
3104
|
+
_Widget$prototype$dec,
|
|
3105
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
3106
|
+
{
|
|
3107
|
+
data: undefined,
|
|
3108
|
+
size: undefined,
|
|
3109
|
+
shape: undefined,
|
|
3110
|
+
colorIndex: undefined,
|
|
3111
|
+
colorMap: undefined,
|
|
3112
|
+
colorName: undefined,
|
|
3113
|
+
name: undefined,
|
|
3114
|
+
active: true,
|
|
3115
|
+
},
|
|
3116
|
+
selection,
|
|
3117
|
+
])
|
|
3118
|
+
);
|
|
3119
|
+
};
|
|
3120
|
+
_proto.prepareData = function prepareData(context, instance) {
|
|
3121
|
+
var data = instance.data;
|
|
3122
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
3123
|
+
_Widget.prototype.prepareData.call(this, context, instance);
|
|
3124
|
+
};
|
|
3125
|
+
_proto.explore = function explore(context, instance) {
|
|
3126
|
+
var _this = this;
|
|
3127
|
+
_Widget.prototype.explore.call(this, context, instance);
|
|
3128
|
+
var xAxis = (instance.xAxis = context.axes[this.xAxis]);
|
|
3129
|
+
var yAxis = (instance.yAxis = context.axes[this.yAxis]);
|
|
3130
|
+
var data = instance.data;
|
|
3131
|
+
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
3132
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
3133
|
+
if (data.active && isArray(data.data)) {
|
|
3134
|
+
data.data.forEach(function (p) {
|
|
3135
|
+
xAxis.acknowledge(p[_this.xField]);
|
|
3136
|
+
yAxis.acknowledge(p[_this.yField]);
|
|
3137
|
+
});
|
|
3138
|
+
}
|
|
3139
|
+
};
|
|
3140
|
+
_proto.prepare = function prepare(context, instance) {
|
|
3141
|
+
var _this2 = this;
|
|
3142
|
+
var data = instance.data,
|
|
3143
|
+
xAxis = instance.xAxis,
|
|
3144
|
+
yAxis = instance.yAxis,
|
|
3145
|
+
colorMap = instance.colorMap;
|
|
3146
|
+
if (xAxis.shouldUpdate || yAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
3147
|
+
if (colorMap && data.name) {
|
|
3148
|
+
data.colorIndex = colorMap.map(data.colorName);
|
|
3149
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
3150
|
+
}
|
|
3151
|
+
if (data.name && context.addLegendEntry)
|
|
3152
|
+
context.addLegendEntry(this.legend, {
|
|
3153
|
+
name: data.name,
|
|
3154
|
+
active: data.active,
|
|
3155
|
+
colorIndex: data.colorIndex,
|
|
3156
|
+
disabled: data.disabled,
|
|
3157
|
+
style: data.style,
|
|
3158
|
+
shape: data.shape,
|
|
3159
|
+
onClick: function onClick(e) {
|
|
3160
|
+
_this2.onLegendClick(e, instance);
|
|
3161
|
+
},
|
|
3162
|
+
});
|
|
3163
|
+
};
|
|
3164
|
+
_proto.onLegendClick = function onLegendClick(e, instance) {
|
|
3165
|
+
var allActions = this.legendAction == "auto";
|
|
3166
|
+
var data = instance.data;
|
|
3167
|
+
if (allActions || this.legendAction == "toggle") instance.set("active", !data.active);
|
|
3168
|
+
};
|
|
3169
|
+
_proto.render = function render(context, instance, key) {
|
|
3170
|
+
var data = instance.data;
|
|
3171
|
+
return /*#__PURE__*/ jsx(
|
|
3172
|
+
"g",
|
|
3173
|
+
{
|
|
3174
|
+
className: data.classNames,
|
|
3175
|
+
children: this.renderData(context, instance),
|
|
3176
|
+
},
|
|
3177
|
+
key
|
|
3178
|
+
);
|
|
3179
|
+
};
|
|
3180
|
+
_proto.renderData = function renderData(context, instance) {
|
|
3181
|
+
var _this3 = this;
|
|
3182
|
+
var data = instance.data,
|
|
3183
|
+
xAxis = instance.xAxis,
|
|
3184
|
+
yAxis = instance.yAxis,
|
|
3185
|
+
store = instance.store;
|
|
3186
|
+
if (!data.active) return null;
|
|
3187
|
+
var shape = getShape(data.shape);
|
|
3188
|
+
var isSelected = this.selection.getIsSelectedDelegate(store);
|
|
3189
|
+
return (
|
|
3190
|
+
isArray(data.data) &&
|
|
3191
|
+
data.data.map(function (p, i) {
|
|
3192
|
+
var _CSS$element;
|
|
3193
|
+
var classes = CSS.element(
|
|
3194
|
+
_this3.baseClass,
|
|
3195
|
+
"shape",
|
|
3196
|
+
((_CSS$element = {
|
|
3197
|
+
selected: isSelected(p, i),
|
|
3198
|
+
selectable: !_this3.selection.isDummy,
|
|
3199
|
+
}),
|
|
3200
|
+
(_CSS$element["color-" + data.colorIndex] = data.colorIndex != null),
|
|
3201
|
+
_CSS$element)
|
|
3202
|
+
);
|
|
3203
|
+
var cx = xAxis.map(p[_this3.xField]),
|
|
3204
|
+
cy = yAxis.map(p[_this3.yField]),
|
|
3205
|
+
size = _this3.sizeField ? p[_this3.sizeField] : data.size;
|
|
3206
|
+
return shape(cx, cy, size, {
|
|
3207
|
+
key: i,
|
|
3208
|
+
className: classes,
|
|
3209
|
+
style: p.style || data.style,
|
|
3210
|
+
onClick: function onClick(e) {
|
|
3211
|
+
_this3.handleItemClick(e, instance, i);
|
|
3212
|
+
},
|
|
3213
|
+
});
|
|
3214
|
+
})
|
|
3215
|
+
);
|
|
3216
|
+
};
|
|
3217
|
+
_proto.handleItemClick = function handleItemClick(e, _ref, index) {
|
|
3218
|
+
var data = _ref.data,
|
|
3219
|
+
store = _ref.store;
|
|
3220
|
+
var bubble = data.data[index];
|
|
3221
|
+
this.selection.select(store, bubble, index, {
|
|
3222
|
+
toggle: e.ctrlKey,
|
|
3223
|
+
});
|
|
3224
|
+
};
|
|
3225
|
+
return ScatterGraph;
|
|
3226
|
+
})(Widget);
|
|
3227
|
+
ScatterGraph.prototype.baseClass = "scattergraph";
|
|
3228
|
+
ScatterGraph.prototype.xAxis = "x";
|
|
3229
|
+
ScatterGraph.prototype.yAxis = "y";
|
|
3230
|
+
ScatterGraph.prototype.xField = "x";
|
|
3231
|
+
ScatterGraph.prototype.yField = "y";
|
|
3232
|
+
ScatterGraph.prototype.sizeField = false;
|
|
3233
|
+
ScatterGraph.prototype.shape = "circle";
|
|
3234
|
+
ScatterGraph.prototype.size = 10;
|
|
3235
|
+
ScatterGraph.prototype.legend = "legend";
|
|
3236
|
+
ScatterGraph.prototype.legendAction = "auto";
|
|
3237
|
+
ScatterGraph.prototype.styled = true;
|
|
3238
|
+
Widget.alias("scatter-graph", ScatterGraph);
|
|
3239
|
+
|
|
3240
|
+
var BubbleGraph = /*#__PURE__*/ (function (_Widget) {
|
|
3241
|
+
_inheritsLoose(BubbleGraph, _Widget);
|
|
3242
|
+
function BubbleGraph() {
|
|
3243
|
+
return _Widget.apply(this, arguments) || this;
|
|
3244
|
+
}
|
|
3245
|
+
var _proto = BubbleGraph.prototype;
|
|
3246
|
+
_proto.declareData = function declareData() {
|
|
3247
|
+
var _Widget$prototype$dec;
|
|
3248
|
+
var selection = this.selection.configureWidget(this);
|
|
3249
|
+
(_Widget$prototype$dec = _Widget.prototype.declareData).call.apply(
|
|
3250
|
+
_Widget$prototype$dec,
|
|
3251
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
3252
|
+
{
|
|
3253
|
+
data: undefined,
|
|
3254
|
+
bubbleRadius: undefined,
|
|
3255
|
+
bubbleStyle: {
|
|
3256
|
+
structured: true,
|
|
3257
|
+
},
|
|
3258
|
+
},
|
|
3259
|
+
selection,
|
|
3260
|
+
])
|
|
3261
|
+
);
|
|
3262
|
+
};
|
|
3263
|
+
_proto.init = function init() {
|
|
3264
|
+
this.selection = Selection.create(this.selection, {
|
|
3265
|
+
records: this.data,
|
|
3266
|
+
});
|
|
3267
|
+
_Widget.prototype.init.call(this);
|
|
3268
|
+
};
|
|
3269
|
+
_proto.explore = function explore(context, instance) {
|
|
3270
|
+
var _this = this;
|
|
3271
|
+
instance.axes = context.axes;
|
|
3272
|
+
_Widget.prototype.explore.call(this, context, instance);
|
|
3273
|
+
var data = instance.data;
|
|
3274
|
+
if (isArray(data.data)) {
|
|
3275
|
+
data.data.forEach(function (p) {
|
|
3276
|
+
instance.axes[_this.xAxis].acknowledge(p[_this.xField]);
|
|
3277
|
+
instance.axes[_this.yAxis].acknowledge(p[_this.yField]);
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
};
|
|
3281
|
+
_proto.prepare = function prepare(context, instance) {
|
|
3282
|
+
_Widget.prototype.prepare.call(this, context, instance);
|
|
3283
|
+
if (instance.axes[this.xAxis].shouldUpdate || instance.axes[this.yAxis].shouldUpdate)
|
|
3284
|
+
instance.markShouldUpdate(context);
|
|
3285
|
+
};
|
|
3286
|
+
_proto.render = function render(context, instance, key) {
|
|
3287
|
+
var data = instance.data;
|
|
3288
|
+
return /*#__PURE__*/ jsx(
|
|
3289
|
+
"g",
|
|
3290
|
+
{
|
|
3291
|
+
className: data.classNames,
|
|
3292
|
+
children: this.renderData(context, instance),
|
|
3293
|
+
},
|
|
3294
|
+
key
|
|
3295
|
+
);
|
|
3296
|
+
};
|
|
3297
|
+
_proto.renderData = function renderData(context, instance) {
|
|
3298
|
+
var _this2 = this;
|
|
3299
|
+
var data = instance.data,
|
|
3300
|
+
axes = instance.axes,
|
|
3301
|
+
store = instance.store;
|
|
3302
|
+
var xAxis = axes[this.xAxis];
|
|
3303
|
+
var yAxis = axes[this.yAxis];
|
|
3304
|
+
return (
|
|
3305
|
+
isArray(data.data) &&
|
|
3306
|
+
data.data.map(function (p, i) {
|
|
3307
|
+
var selected = _this2.selection && _this2.selection.isSelected(store, p, i);
|
|
3308
|
+
var classes = CSS.element(_this2.baseClass, "bubble", {
|
|
3309
|
+
selected: selected,
|
|
3310
|
+
});
|
|
3311
|
+
return /*#__PURE__*/ jsx(
|
|
3312
|
+
"circle",
|
|
3313
|
+
{
|
|
3314
|
+
className: classes,
|
|
3315
|
+
cx: xAxis.map(p[_this2.xField]),
|
|
3316
|
+
cy: yAxis.map(p[_this2.yField]),
|
|
3317
|
+
r: p[_this2.rField] || data.bubbleRadius,
|
|
3318
|
+
style: p.style || data.bubbleStyle,
|
|
3319
|
+
onClick: function onClick(e) {
|
|
3320
|
+
_this2.onBubbleClick(e, instance, i);
|
|
3321
|
+
},
|
|
3322
|
+
},
|
|
3323
|
+
i
|
|
3324
|
+
);
|
|
3325
|
+
})
|
|
3326
|
+
);
|
|
3327
|
+
};
|
|
3328
|
+
_proto.onBubbleClick = function onBubbleClick(e, _ref, index) {
|
|
3329
|
+
var data = _ref.data,
|
|
3330
|
+
store = _ref.store;
|
|
3331
|
+
var bubble = data.data[index];
|
|
3332
|
+
this.selection.select(store, bubble, index, {
|
|
3333
|
+
toggle: e.ctrlKey,
|
|
3334
|
+
});
|
|
3335
|
+
};
|
|
3336
|
+
return BubbleGraph;
|
|
3337
|
+
})(Widget);
|
|
3338
|
+
BubbleGraph.prototype.baseClass = "bubblegraph";
|
|
3339
|
+
BubbleGraph.prototype.xAxis = "x";
|
|
3340
|
+
BubbleGraph.prototype.yAxis = "y";
|
|
3341
|
+
BubbleGraph.prototype.xField = "x";
|
|
3342
|
+
BubbleGraph.prototype.yField = "y";
|
|
3343
|
+
BubbleGraph.prototype.rField = "r";
|
|
3344
|
+
BubbleGraph.prototype.bubbleRadius = 10;
|
|
3345
|
+
Widget.alias("bubble-graph", BubbleGraph);
|
|
3346
|
+
|
|
3347
|
+
var MouseTracker = /*#__PURE__*/ (function (_BoundedObject) {
|
|
3348
|
+
_inheritsLoose(MouseTracker, _BoundedObject);
|
|
3349
|
+
function MouseTracker() {
|
|
3350
|
+
return _BoundedObject.apply(this, arguments) || this;
|
|
3351
|
+
}
|
|
3352
|
+
var _proto = MouseTracker.prototype;
|
|
3353
|
+
_proto.declareData = function declareData() {
|
|
3354
|
+
var _BoundedObject$protot;
|
|
3355
|
+
return (_BoundedObject$protot = _BoundedObject.prototype.declareData).call.apply(
|
|
3356
|
+
_BoundedObject$protot,
|
|
3357
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
3358
|
+
{
|
|
3359
|
+
x: undefined,
|
|
3360
|
+
y: undefined,
|
|
3361
|
+
},
|
|
3362
|
+
])
|
|
3363
|
+
);
|
|
3364
|
+
};
|
|
3365
|
+
_proto.explore = function explore(context, instance) {
|
|
3366
|
+
instance.xAxis = context.axes[this.xAxis];
|
|
3367
|
+
instance.yAxis = context.axes[this.yAxis];
|
|
3368
|
+
_BoundedObject.prototype.explore.call(this, context, instance);
|
|
3369
|
+
};
|
|
3370
|
+
_proto.render = function render(context, instance, key) {
|
|
3371
|
+
var _this = this;
|
|
3372
|
+
var data = instance.data;
|
|
3373
|
+
var bounds = data.bounds;
|
|
3374
|
+
if (!bounds.valid()) return null;
|
|
3375
|
+
return /*#__PURE__*/ jsxs(
|
|
3376
|
+
"g",
|
|
3377
|
+
{
|
|
3378
|
+
className: data.classNames,
|
|
3379
|
+
onMouseMove: function onMouseMove(e) {
|
|
3380
|
+
_this.handleMouseMove(e, instance);
|
|
3381
|
+
},
|
|
3382
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
3383
|
+
_this.handleMouseLeave(e, instance);
|
|
3384
|
+
},
|
|
3385
|
+
children: [
|
|
3386
|
+
/*#__PURE__*/ jsx("rect", {
|
|
3387
|
+
x: bounds.l,
|
|
3388
|
+
y: bounds.t,
|
|
3389
|
+
width: bounds.width(),
|
|
3390
|
+
height: bounds.height(),
|
|
3391
|
+
fill: "transparent",
|
|
3392
|
+
strokeWidth: "0",
|
|
3393
|
+
}),
|
|
3394
|
+
this.renderChildren(context, instance),
|
|
3395
|
+
],
|
|
3396
|
+
},
|
|
3397
|
+
key
|
|
3398
|
+
);
|
|
3399
|
+
};
|
|
3400
|
+
_proto.handleMouseMove = function handleMouseMove(e, instance) {
|
|
3401
|
+
var xAxis = instance.xAxis,
|
|
3402
|
+
yAxis = instance.yAxis;
|
|
3403
|
+
var svgEl = closest(e.target, function (el) {
|
|
3404
|
+
return el.tagName == "svg";
|
|
3405
|
+
});
|
|
3406
|
+
var bounds = getTopLevelBoundingClientRect(svgEl);
|
|
3407
|
+
if (xAxis) instance.set("x", xAxis.trackValue(e.clientX - bounds.left));
|
|
3408
|
+
if (yAxis) instance.set("y", yAxis.trackValue(e.clientY - bounds.top));
|
|
3409
|
+
tooltipMouseMove(e, instance, instance.widget.tooltip);
|
|
3410
|
+
};
|
|
3411
|
+
_proto.handleMouseLeave = function handleMouseLeave(e, instance) {
|
|
3412
|
+
var xAxis = instance.xAxis,
|
|
3413
|
+
yAxis = instance.yAxis;
|
|
3414
|
+
tooltipMouseLeave(e, instance, instance.widget.tooltip);
|
|
3415
|
+
if (xAxis) instance.set("x", null);
|
|
3416
|
+
if (yAxis) instance.set("y", null);
|
|
3417
|
+
};
|
|
3418
|
+
return MouseTracker;
|
|
3419
|
+
})(BoundedObject);
|
|
3420
|
+
MouseTracker.prototype.xAxis = "x";
|
|
3421
|
+
MouseTracker.prototype.yAxis = "y";
|
|
3422
|
+
MouseTracker.prototype.anchors = "0 1 1 0";
|
|
3423
|
+
MouseTracker.prototype.baseClass = "mousetracker";
|
|
3424
|
+
|
|
3425
|
+
var Stack = /*#__PURE__*/ (function () {
|
|
3426
|
+
function Stack() {
|
|
3427
|
+
this.reset();
|
|
3428
|
+
}
|
|
3429
|
+
var _proto = Stack.prototype;
|
|
3430
|
+
_proto.reset = function reset() {
|
|
3431
|
+
this.totals = {};
|
|
3432
|
+
this.values = {};
|
|
3433
|
+
this.normalized = false;
|
|
3434
|
+
this.invalid = {};
|
|
3435
|
+
};
|
|
3436
|
+
_proto.acknowledge = function acknowledge(ordinal, value) {
|
|
3437
|
+
if (value != null) {
|
|
3438
|
+
var v = this.totals[ordinal] || 0;
|
|
3439
|
+
this.totals[ordinal] = v + value;
|
|
3440
|
+
} else {
|
|
3441
|
+
this.invalid[ordinal] = true;
|
|
3442
|
+
}
|
|
3443
|
+
};
|
|
3444
|
+
_proto.measure = function measure(normalized) {
|
|
3445
|
+
if (normalized) {
|
|
3446
|
+
this.normalized = true;
|
|
3447
|
+
return [0, 1];
|
|
3448
|
+
}
|
|
3449
|
+
var max = 0,
|
|
3450
|
+
min = 0;
|
|
3451
|
+
for (var key in this.totals) {
|
|
3452
|
+
if (this.totals[key] > max) max = this.totals[key];
|
|
3453
|
+
if (this.totals[key] < min) min = this.totals[key];
|
|
3454
|
+
}
|
|
3455
|
+
return [min, max];
|
|
3456
|
+
};
|
|
3457
|
+
_proto.stack = function stack(ordinal, value) {
|
|
3458
|
+
if (value == null || this.invalid[ordinal]) return null;
|
|
3459
|
+
var base = this.values[ordinal] || 0;
|
|
3460
|
+
var result = (this.values[ordinal] = base + value);
|
|
3461
|
+
if (!this.normalized) return result;
|
|
3462
|
+
var total = this.totals[ordinal];
|
|
3463
|
+
if (total > 0) return result / total;
|
|
3464
|
+
return null;
|
|
3465
|
+
};
|
|
3466
|
+
return Stack;
|
|
3467
|
+
})();
|
|
3468
|
+
|
|
3469
|
+
var NumericAxis = /*#__PURE__*/ (function (_Axis) {
|
|
3470
|
+
_inheritsLoose(NumericAxis, _Axis);
|
|
3471
|
+
function NumericAxis() {
|
|
3472
|
+
return _Axis.apply(this, arguments) || this;
|
|
3473
|
+
}
|
|
3474
|
+
var _proto = NumericAxis.prototype;
|
|
3475
|
+
_proto.init = function init() {
|
|
3476
|
+
if (this.deadZone) {
|
|
3477
|
+
this.lowerDeadZone = this.deadZone;
|
|
3478
|
+
this.upperDeadZone = this.deadZone;
|
|
3479
|
+
}
|
|
3480
|
+
_Axis.prototype.init.call(this);
|
|
3481
|
+
};
|
|
3482
|
+
_proto.declareData = function declareData() {
|
|
3483
|
+
var _Axis$prototype$decla;
|
|
3484
|
+
(_Axis$prototype$decla = _Axis.prototype.declareData).call.apply(
|
|
3485
|
+
_Axis$prototype$decla,
|
|
3486
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
3487
|
+
{
|
|
3488
|
+
min: undefined,
|
|
3489
|
+
max: undefined,
|
|
3490
|
+
normalized: undefined,
|
|
3491
|
+
inverted: undefined,
|
|
3492
|
+
labelDivisor: undefined,
|
|
3493
|
+
format: undefined,
|
|
3494
|
+
lowerDeadZone: undefined,
|
|
3495
|
+
upperDeadZone: undefined,
|
|
3496
|
+
},
|
|
3497
|
+
])
|
|
3498
|
+
);
|
|
3499
|
+
};
|
|
3500
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
3501
|
+
instance.calculator = new NumericScale();
|
|
3502
|
+
};
|
|
3503
|
+
_proto.explore = function explore(context, instance) {
|
|
3504
|
+
_Axis.prototype.explore.call(this, context, instance);
|
|
3505
|
+
var _instance$data = instance.data,
|
|
3506
|
+
min = _instance$data.min,
|
|
3507
|
+
max = _instance$data.max,
|
|
3508
|
+
normalized = _instance$data.normalized,
|
|
3509
|
+
inverted = _instance$data.inverted,
|
|
3510
|
+
lowerDeadZone = _instance$data.lowerDeadZone,
|
|
3511
|
+
upperDeadZone = _instance$data.upperDeadZone;
|
|
3512
|
+
instance.calculator.reset(
|
|
3513
|
+
min,
|
|
3514
|
+
max,
|
|
3515
|
+
this.snapToTicks,
|
|
3516
|
+
this.tickDivisions,
|
|
3517
|
+
this.minTickDistance,
|
|
3518
|
+
this.minTickStep,
|
|
3519
|
+
this.minLabelDistance,
|
|
3520
|
+
this.minLabelTickSize,
|
|
3521
|
+
normalized,
|
|
3522
|
+
inverted,
|
|
3523
|
+
lowerDeadZone,
|
|
3524
|
+
upperDeadZone
|
|
3525
|
+
);
|
|
3526
|
+
};
|
|
3527
|
+
_proto.render = function render(context, instance, key) {
|
|
3528
|
+
var data = instance.data;
|
|
3529
|
+
if (!data.bounds.valid()) return null;
|
|
3530
|
+
var baseFormatter = Format.parse(data.format);
|
|
3531
|
+
var formatter =
|
|
3532
|
+
data.labelDivisor != 1
|
|
3533
|
+
? function (v) {
|
|
3534
|
+
return baseFormatter(v / data.labelDivisor);
|
|
3535
|
+
}
|
|
3536
|
+
: baseFormatter;
|
|
3537
|
+
return /*#__PURE__*/ jsx(
|
|
3538
|
+
"g",
|
|
3539
|
+
{
|
|
3540
|
+
className: data.classNames,
|
|
3541
|
+
style: data.style,
|
|
3542
|
+
children: this.renderTicksAndLabels(context, instance, formatter),
|
|
3543
|
+
},
|
|
3544
|
+
key
|
|
3545
|
+
);
|
|
3546
|
+
};
|
|
3547
|
+
NumericAxis.XY = function XY() {
|
|
3548
|
+
return {
|
|
3549
|
+
x: {
|
|
3550
|
+
type: NumericAxis,
|
|
3551
|
+
},
|
|
3552
|
+
y: {
|
|
3553
|
+
type: NumericAxis,
|
|
3554
|
+
vertical: true,
|
|
3555
|
+
},
|
|
3556
|
+
};
|
|
3557
|
+
};
|
|
3558
|
+
return NumericAxis;
|
|
3559
|
+
})(Axis);
|
|
3560
|
+
NumericAxis.prototype.baseClass = "numericaxis";
|
|
3561
|
+
NumericAxis.prototype.tickDivisions = [
|
|
3562
|
+
[1, 2, 10, 20, 100],
|
|
3563
|
+
[1, 5, 10, 20, 100],
|
|
3564
|
+
];
|
|
3565
|
+
NumericAxis.prototype.snapToTicks = 1;
|
|
3566
|
+
NumericAxis.prototype.normalized = false;
|
|
3567
|
+
NumericAxis.prototype.format = "n";
|
|
3568
|
+
NumericAxis.prototype.labelDivisor = 1;
|
|
3569
|
+
NumericAxis.prototype.minLabelTickSize = 0;
|
|
3570
|
+
NumericAxis.prototype.minTickStep = 0;
|
|
3571
|
+
Axis.alias("numeric", NumericAxis);
|
|
3572
|
+
var NumericScale = /*#__PURE__*/ (function () {
|
|
3573
|
+
function NumericScale() {}
|
|
3574
|
+
var _proto2 = NumericScale.prototype;
|
|
3575
|
+
_proto2.reset = function reset(
|
|
3576
|
+
min,
|
|
3577
|
+
max,
|
|
3578
|
+
snapToTicks,
|
|
3579
|
+
tickDivisions,
|
|
3580
|
+
minTickDistance,
|
|
3581
|
+
minTickStep,
|
|
3582
|
+
minLabelDistance,
|
|
3583
|
+
minLabelTickSize,
|
|
3584
|
+
normalized,
|
|
3585
|
+
inverted,
|
|
3586
|
+
lowerDeadZone,
|
|
3587
|
+
upperDeadZone
|
|
3588
|
+
) {
|
|
3589
|
+
this.min = min;
|
|
3590
|
+
this.max = max;
|
|
3591
|
+
this.snapToTicks = snapToTicks;
|
|
3592
|
+
this.tickDivisions = tickDivisions;
|
|
3593
|
+
this.minLabelDistance = minLabelDistance;
|
|
3594
|
+
this.minLabelTickSize = minLabelTickSize;
|
|
3595
|
+
this.minTickDistance = minTickDistance;
|
|
3596
|
+
this.minTickStep = minTickStep;
|
|
3597
|
+
this.tickSizes = [];
|
|
3598
|
+
this.normalized = normalized;
|
|
3599
|
+
this.inverted = inverted;
|
|
3600
|
+
delete this.minValue;
|
|
3601
|
+
delete this.maxValue;
|
|
3602
|
+
this.stacks = {};
|
|
3603
|
+
this.lowerDeadZone = lowerDeadZone || 0;
|
|
3604
|
+
this.upperDeadZone = upperDeadZone || 0;
|
|
3605
|
+
};
|
|
3606
|
+
_proto2.map = function map(v, offset) {
|
|
3607
|
+
if (offset === void 0) {
|
|
3608
|
+
offset = 0;
|
|
3609
|
+
}
|
|
3610
|
+
return this.origin + (v + offset - this.scale.min + this.scale.minPadding) * this.scale.factor;
|
|
3611
|
+
};
|
|
3612
|
+
_proto2.decodeValue = function decodeValue(n) {
|
|
3613
|
+
return n;
|
|
3614
|
+
};
|
|
3615
|
+
_proto2.encodeValue = function encodeValue(v) {
|
|
3616
|
+
return v;
|
|
3617
|
+
};
|
|
3618
|
+
_proto2.constrainValue = function constrainValue(v) {
|
|
3619
|
+
return Math.max(this.scale.min, Math.min(this.scale.max, v));
|
|
3620
|
+
};
|
|
3621
|
+
_proto2.trackValue = function trackValue(v, offset, constrain) {
|
|
3622
|
+
if (offset === void 0) {
|
|
3623
|
+
offset = 0;
|
|
3624
|
+
}
|
|
3625
|
+
if (constrain === void 0) {
|
|
3626
|
+
constrain = false;
|
|
3627
|
+
}
|
|
3628
|
+
var value = (v - this.origin) / this.scale.factor - offset + this.scale.min - this.scale.minPadding;
|
|
3629
|
+
if (constrain) value = this.constrainValue(v);
|
|
3630
|
+
return value;
|
|
3631
|
+
};
|
|
3632
|
+
_proto2.hash = function hash() {
|
|
3633
|
+
var _this = this;
|
|
3634
|
+
var r = {
|
|
3635
|
+
origin: this.origin,
|
|
3636
|
+
factor: this.scale.factor,
|
|
3637
|
+
min: this.scale.min,
|
|
3638
|
+
max: this.scale.max,
|
|
3639
|
+
minPadding: this.scale.minPadding,
|
|
3640
|
+
maxPadding: this.scale.maxPadding,
|
|
3641
|
+
};
|
|
3642
|
+
r.stacks = Object.keys(this.stacks)
|
|
3643
|
+
.map(function (s) {
|
|
3644
|
+
return _this.stacks[s].info.join(",");
|
|
3645
|
+
})
|
|
3646
|
+
.join(":");
|
|
3647
|
+
return r;
|
|
3648
|
+
};
|
|
3649
|
+
_proto2.isSame = function isSame(x) {
|
|
3650
|
+
var hash = this.hash();
|
|
3651
|
+
var same =
|
|
3652
|
+
x &&
|
|
3653
|
+
!Object.keys(hash).some(function (k) {
|
|
3654
|
+
return x[k] !== hash[k];
|
|
3655
|
+
});
|
|
3656
|
+
this.shouldUpdate = !same;
|
|
3657
|
+
return same;
|
|
3658
|
+
};
|
|
3659
|
+
_proto2.measure = function measure(a, b) {
|
|
3660
|
+
this.a = a;
|
|
3661
|
+
this.b = b;
|
|
3662
|
+
if (this.minValue != null && this.min == null) this.min = this.minValue;
|
|
3663
|
+
if (this.maxValue != null && this.max == null) this.max = this.maxValue;
|
|
3664
|
+
for (var s in this.stacks) {
|
|
3665
|
+
var info = this.stacks[s].measure(this.normalized);
|
|
3666
|
+
var min = info[0],
|
|
3667
|
+
max = info[1];
|
|
3668
|
+
info[2];
|
|
3669
|
+
if (this.min == null || min < this.min) this.min = min;
|
|
3670
|
+
if (this.max == null || max > this.max) this.max = max;
|
|
3671
|
+
this.stacks[s].info = info;
|
|
3672
|
+
}
|
|
3673
|
+
if (this.min == null) this.min = 0;
|
|
3674
|
+
if (this.max == null) this.max = this.normalized ? 1 : 100;
|
|
3675
|
+
if (this.min == this.max) {
|
|
3676
|
+
if (this.min == 0) {
|
|
3677
|
+
this.min = -1;
|
|
3678
|
+
this.max = 1;
|
|
3679
|
+
} else {
|
|
3680
|
+
var delta = Math.abs(this.min) * 0.1;
|
|
3681
|
+
this.min -= delta;
|
|
3682
|
+
this.max += delta;
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
this.origin = this.inverted ? this.b : this.a;
|
|
3686
|
+
this.scale = this.getScale();
|
|
3687
|
+
this.calculateTicks();
|
|
3688
|
+
};
|
|
3689
|
+
_proto2.getScale = function getScale(tickSizes) {
|
|
3690
|
+
var min = this.min,
|
|
3691
|
+
max = this.max;
|
|
3692
|
+
var smin = min;
|
|
3693
|
+
var smax = max;
|
|
3694
|
+
var tickSize;
|
|
3695
|
+
if (tickSizes && isNumber(this.snapToTicks) && tickSizes.length > 0) {
|
|
3696
|
+
tickSize = tickSizes[Math.min(tickSizes.length - 1, this.snapToTicks)];
|
|
3697
|
+
smin = Math.floor(smin / tickSize) * tickSize;
|
|
3698
|
+
smax = Math.ceil(smax / tickSize) * tickSize;
|
|
3699
|
+
} else {
|
|
3700
|
+
if (this.minValue === min) smin = this.minValuePadded;
|
|
3701
|
+
if (this.maxValue === max) smax = this.maxValuePadded;
|
|
3702
|
+
}
|
|
3703
|
+
var minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
|
|
3704
|
+
var maxPadding = this.maxValue === max ? Math.max(0, this.maxValuePadded - smax) : 0;
|
|
3705
|
+
var sign = this.b > this.a ? 1 : -1;
|
|
3706
|
+
var factor =
|
|
3707
|
+
smin < smax
|
|
3708
|
+
? (Math.abs(this.b - this.a) - this.lowerDeadZone - this.upperDeadZone) /
|
|
3709
|
+
(smax - smin + minPadding + maxPadding)
|
|
3710
|
+
: 0;
|
|
3711
|
+
if (factor < 0) factor = 0;
|
|
3712
|
+
if (factor > 0 && (this.lowerDeadZone > 0 || this.upperDeadZone > 0)) {
|
|
3713
|
+
while (factor * (min - smin) < this.lowerDeadZone) smin -= this.lowerDeadZone / factor;
|
|
3714
|
+
while (factor * (smax - max) < this.upperDeadZone) smax += this.upperDeadZone / factor;
|
|
3715
|
+
if (tickSize > 0 && isNumber(this.snapToTicks)) {
|
|
3716
|
+
smin = Math.floor(smin / tickSize) * tickSize;
|
|
3717
|
+
smax = Math.ceil(smax / tickSize) * tickSize;
|
|
3718
|
+
minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
|
|
3719
|
+
maxPadding = this.maxValue === max ? Math.max(0, this.maxValuePadded - smax) : 0;
|
|
3720
|
+
}
|
|
3721
|
+
factor = smin < smax ? Math.abs(this.b - this.a) / (smax - smin + minPadding + maxPadding) : 0;
|
|
3722
|
+
}
|
|
3723
|
+
return {
|
|
3724
|
+
factor: sign * (this.inverted ? -factor : factor),
|
|
3725
|
+
min: smin,
|
|
3726
|
+
max: smax,
|
|
3727
|
+
minPadding: minPadding,
|
|
3728
|
+
maxPadding: maxPadding,
|
|
3729
|
+
};
|
|
3730
|
+
};
|
|
3731
|
+
_proto2.acknowledge = function acknowledge(value, width, offset) {
|
|
3732
|
+
if (width === void 0) {
|
|
3733
|
+
width = 0;
|
|
3734
|
+
}
|
|
3735
|
+
if (offset === void 0) {
|
|
3736
|
+
offset = 0;
|
|
3737
|
+
}
|
|
3738
|
+
if (value == null) return;
|
|
3739
|
+
if (this.minValue == null || value < this.minValue) {
|
|
3740
|
+
this.minValue = value;
|
|
3741
|
+
this.minValuePadded = value + offset - width / 2;
|
|
3742
|
+
}
|
|
3743
|
+
if (this.maxValue == null || value > this.maxValue) {
|
|
3744
|
+
this.maxValue = value;
|
|
3745
|
+
this.maxValuePadded = value + offset + width / 2;
|
|
3746
|
+
}
|
|
3747
|
+
};
|
|
3748
|
+
_proto2.getStack = function getStack(name) {
|
|
3749
|
+
var s = this.stacks[name];
|
|
3750
|
+
if (!s) s = this.stacks[name] = new Stack();
|
|
3751
|
+
return s;
|
|
3752
|
+
};
|
|
3753
|
+
_proto2.stacknowledge = function stacknowledge(name, ordinal, value) {
|
|
3754
|
+
return this.getStack(name).acknowledge(ordinal, value);
|
|
3755
|
+
};
|
|
3756
|
+
_proto2.stack = function stack(name, ordinal, value) {
|
|
3757
|
+
var v = this.getStack(name).stack(ordinal, value);
|
|
3758
|
+
return v != null ? this.map(v) : null;
|
|
3759
|
+
};
|
|
3760
|
+
_proto2.findTickSize = function findTickSize(minPxDist) {
|
|
3761
|
+
var _this2 = this;
|
|
3762
|
+
return this.tickSizes.find(function (a) {
|
|
3763
|
+
return a >= _this2.minLabelTickSize && a * Math.abs(_this2.scale.factor) >= minPxDist;
|
|
3764
|
+
});
|
|
3765
|
+
};
|
|
3766
|
+
_proto2.getTickSizes = function getTickSizes() {
|
|
3767
|
+
return this.tickSizes;
|
|
3768
|
+
};
|
|
3769
|
+
_proto2.calculateTicks = function calculateTicks() {
|
|
3770
|
+
var _this3 = this;
|
|
3771
|
+
var dist = this.minLabelDistance / Math.abs(this.scale.factor);
|
|
3772
|
+
var unit = Math.pow(10, Math.floor(Math.log10(dist)));
|
|
3773
|
+
var bestLabelDistance = Infinity;
|
|
3774
|
+
var bestTicks = [];
|
|
3775
|
+
var bestScale = this.scale;
|
|
3776
|
+
var _loop = function _loop() {
|
|
3777
|
+
var divs = _this3.tickDivisions[i];
|
|
3778
|
+
var tickSizes = divs
|
|
3779
|
+
.filter(function (ts) {
|
|
3780
|
+
return ts >= _this3.minTickStep;
|
|
3781
|
+
})
|
|
3782
|
+
.map(function (ts) {
|
|
3783
|
+
return ts * unit;
|
|
3784
|
+
});
|
|
3785
|
+
var scale = _this3.getScale(tickSizes);
|
|
3786
|
+
tickSizes.forEach(function (size, level) {
|
|
3787
|
+
var labelDistance = size * Math.abs(scale.factor);
|
|
3788
|
+
if (labelDistance >= _this3.minLabelDistance && labelDistance < bestLabelDistance) {
|
|
3789
|
+
bestScale = scale;
|
|
3790
|
+
bestTicks = tickSizes;
|
|
3791
|
+
bestLabelDistance = labelDistance;
|
|
3792
|
+
}
|
|
3793
|
+
});
|
|
3794
|
+
};
|
|
3795
|
+
for (var i = 0; i < this.tickDivisions.length; i++) {
|
|
3796
|
+
_loop();
|
|
3797
|
+
}
|
|
3798
|
+
this.scale = bestScale;
|
|
3799
|
+
this.tickSizes = bestTicks.filter(function (ts) {
|
|
3800
|
+
return ts >= _this3.minTickStep && ts * Math.abs(bestScale.factor) >= _this3.minTickDistance;
|
|
3801
|
+
});
|
|
3802
|
+
if (this.tickSizes.length > 0) {
|
|
3803
|
+
var max = this.tickSizes[this.tickSizes.length - 1];
|
|
3804
|
+
this.tickSizes.push(2 * max);
|
|
3805
|
+
this.tickSizes.push(5 * max);
|
|
3806
|
+
this.tickSizes.push(10 * max);
|
|
3807
|
+
var min = this.tickSizes[0];
|
|
3808
|
+
var _dist = min * Math.abs(bestScale.factor) >= this.minTickDistance;
|
|
3809
|
+
if (min / 10 >= this.minTickStep && _dist / 10 >= this.minTickDistance) this.tickSizes.splice(0, 0, min / 10);
|
|
3810
|
+
else if (min / 5 >= this.minTickStep && _dist / 5 >= this.minTickDistance) this.tickSizes.splice(0, 0, min / 5);
|
|
3811
|
+
else if (min / 2 >= this.minTickStep && _dist / 2 >= this.minTickDistance) this.tickSizes.splice(0, 0, min / 2);
|
|
3812
|
+
}
|
|
3813
|
+
};
|
|
3814
|
+
_proto2.getTicks = function getTicks(tickSizes) {
|
|
3815
|
+
var _this4 = this;
|
|
3816
|
+
return tickSizes.map(function (size) {
|
|
3817
|
+
var start = Math.ceil((_this4.scale.min - _this4.scale.minPadding) / size);
|
|
3818
|
+
var end = Math.floor((_this4.scale.max + _this4.scale.maxPadding) / size);
|
|
3819
|
+
var result = [];
|
|
3820
|
+
for (var i = start; i <= end; i++) result.push(i * size + 0);
|
|
3821
|
+
return result;
|
|
3822
|
+
});
|
|
3823
|
+
};
|
|
3824
|
+
_proto2.mapGridlines = function mapGridlines() {
|
|
3825
|
+
var size = this.tickSizes[0];
|
|
3826
|
+
var start = Math.ceil((this.scale.min - this.scale.minPadding) / size);
|
|
3827
|
+
var end = Math.floor((this.scale.max + this.scale.maxPadding) / size);
|
|
3828
|
+
var result = [];
|
|
3829
|
+
for (var i = start; i <= end; i++) result.push(this.map(i * size));
|
|
3830
|
+
return result;
|
|
3831
|
+
};
|
|
3832
|
+
return NumericScale;
|
|
3833
|
+
})();
|
|
3834
|
+
|
|
3835
|
+
var CategoryAxis = /*#__PURE__*/ (function (_Axis) {
|
|
3836
|
+
_inheritsLoose(CategoryAxis, _Axis);
|
|
3837
|
+
function CategoryAxis() {
|
|
3838
|
+
return _Axis.apply(this, arguments) || this;
|
|
3839
|
+
}
|
|
3840
|
+
var _proto = CategoryAxis.prototype;
|
|
3841
|
+
_proto.declareData = function declareData() {
|
|
3842
|
+
var _Axis$prototype$decla;
|
|
3843
|
+
(_Axis$prototype$decla = _Axis.prototype.declareData).call.apply(
|
|
3844
|
+
_Axis$prototype$decla,
|
|
3845
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
3846
|
+
{
|
|
3847
|
+
inverted: undefined,
|
|
3848
|
+
uniform: undefined,
|
|
3849
|
+
names: undefined,
|
|
3850
|
+
values: undefined,
|
|
3851
|
+
minSize: undefined,
|
|
3852
|
+
},
|
|
3853
|
+
])
|
|
3854
|
+
);
|
|
3855
|
+
};
|
|
3856
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
3857
|
+
instance.calculator = new CategoryScale();
|
|
3858
|
+
};
|
|
3859
|
+
_proto.explore = function explore(context, instance) {
|
|
3860
|
+
_Axis.prototype.explore.call(this, context, instance);
|
|
3861
|
+
var _instance$data = instance.data,
|
|
3862
|
+
values = _instance$data.values,
|
|
3863
|
+
names = _instance$data.names,
|
|
3864
|
+
inverted = _instance$data.inverted,
|
|
3865
|
+
uniform = _instance$data.uniform,
|
|
3866
|
+
minSize = _instance$data.minSize;
|
|
3867
|
+
instance.calculator.reset(inverted, uniform, values, names, minSize);
|
|
3868
|
+
};
|
|
3869
|
+
_proto.render = function render(context, instance, key) {
|
|
3870
|
+
var data = instance.data,
|
|
3871
|
+
calculator = instance.calculator;
|
|
3872
|
+
if (!data.bounds.valid()) return null;
|
|
3873
|
+
var formatter = function formatter(v) {
|
|
3874
|
+
return calculator.names[v] || v;
|
|
3875
|
+
};
|
|
3876
|
+
return /*#__PURE__*/ jsx(
|
|
3877
|
+
"g",
|
|
3878
|
+
{
|
|
3879
|
+
className: data.classNames,
|
|
3880
|
+
style: data.style,
|
|
3881
|
+
children: this.renderTicksAndLabels(context, instance, formatter),
|
|
3882
|
+
},
|
|
3883
|
+
key
|
|
3884
|
+
);
|
|
3885
|
+
};
|
|
3886
|
+
return CategoryAxis;
|
|
3887
|
+
})(Axis);
|
|
3888
|
+
CategoryAxis.prototype.baseClass = "categoryaxis";
|
|
3889
|
+
CategoryAxis.prototype.anchors = "0 1 1 0";
|
|
3890
|
+
CategoryAxis.prototype.vertical = false;
|
|
3891
|
+
CategoryAxis.prototype.inverted = false;
|
|
3892
|
+
CategoryAxis.prototype.uniform = false;
|
|
3893
|
+
CategoryAxis.prototype.labelOffset = 10;
|
|
3894
|
+
CategoryAxis.prototype.labelRotation = 0;
|
|
3895
|
+
CategoryAxis.prototype.labelAnchor = "auto";
|
|
3896
|
+
CategoryAxis.prototype.labelDx = "auto";
|
|
3897
|
+
CategoryAxis.prototype.labelDy = "auto";
|
|
3898
|
+
CategoryAxis.prototype.minSize = 1;
|
|
3899
|
+
Axis.alias("category", CategoryAxis);
|
|
3900
|
+
var CategoryScale = /*#__PURE__*/ (function () {
|
|
3901
|
+
function CategoryScale() {}
|
|
3902
|
+
var _proto2 = CategoryScale.prototype;
|
|
3903
|
+
_proto2.reset = function reset(inverted, uniform, values, names, minSize) {
|
|
3904
|
+
var _this = this;
|
|
3905
|
+
this.padding = 0.5;
|
|
3906
|
+
delete this.min;
|
|
3907
|
+
delete this.max;
|
|
3908
|
+
delete this.minValue;
|
|
3909
|
+
delete this.maxValue;
|
|
3910
|
+
this.minSize = minSize;
|
|
3911
|
+
this.valuesMap = {};
|
|
3912
|
+
this.valueList = [];
|
|
3913
|
+
this.inverted = inverted;
|
|
3914
|
+
this.uniform = uniform;
|
|
3915
|
+
this.valueStacks = {};
|
|
3916
|
+
this.names = {};
|
|
3917
|
+
if (values) {
|
|
3918
|
+
if (isArray(values))
|
|
3919
|
+
values.forEach(function (v) {
|
|
3920
|
+
return _this.acknowledge(v);
|
|
3921
|
+
});
|
|
3922
|
+
else if (typeof values == "object")
|
|
3923
|
+
for (var k in values) {
|
|
3924
|
+
this.acknowledge(k);
|
|
3925
|
+
this.names[k] = values[k];
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
if (names) {
|
|
3929
|
+
if (isArray(names)) {
|
|
3930
|
+
values = values || [];
|
|
3931
|
+
names.forEach(function (name, index) {
|
|
3932
|
+
var value = values[index];
|
|
3933
|
+
_this.names[value != null ? value : index] = name;
|
|
3934
|
+
});
|
|
3935
|
+
} else this.names = names;
|
|
3936
|
+
}
|
|
3937
|
+
};
|
|
3938
|
+
_proto2.decodeValue = function decodeValue(n) {
|
|
3939
|
+
return n;
|
|
3940
|
+
};
|
|
3941
|
+
_proto2.encodeValue = function encodeValue(v) {
|
|
3942
|
+
return v;
|
|
3943
|
+
};
|
|
3944
|
+
_proto2.map = function map(v, offset) {
|
|
3945
|
+
if (offset === void 0) {
|
|
3946
|
+
offset = 0;
|
|
3947
|
+
}
|
|
3948
|
+
var index = this.valuesMap[v] || 0;
|
|
3949
|
+
return this.origin + (index + offset - this.min + this.padding) * this.factor;
|
|
3950
|
+
};
|
|
3951
|
+
_proto2.measure = function measure(a, b) {
|
|
3952
|
+
this.a = a;
|
|
3953
|
+
this.b = b;
|
|
3954
|
+
if (this.min == null) this.min = this.minValue || 0;
|
|
3955
|
+
if (this.max == null) this.max = !isNaN(this.maxValue) ? this.maxValue : 100;
|
|
3956
|
+
var sign = this.inverted ? -1 : 1;
|
|
3957
|
+
if (this.max - this.min + 1 < this.minSize) {
|
|
3958
|
+
this.factor = (sign * (this.b - this.a)) / this.minSize;
|
|
3959
|
+
this.origin = (this.b + this.a) * 0.5 - (this.factor * (this.max - this.min + 1)) / 2;
|
|
3960
|
+
} else {
|
|
3961
|
+
this.factor = (sign * (this.b - this.a)) / (this.max - this.min + 2 * this.padding);
|
|
3962
|
+
this.origin = (this.a * (1 + sign)) / 2 + (this.b * (1 - sign)) / 2; //a || b
|
|
3963
|
+
}
|
|
3964
|
+
};
|
|
3965
|
+
_proto2.hash = function hash() {
|
|
3966
|
+
return {
|
|
3967
|
+
origin: this.origin,
|
|
3968
|
+
factor: this.factor,
|
|
3969
|
+
min: this.min,
|
|
3970
|
+
minSize: this.minSize,
|
|
3971
|
+
padding: this.padding,
|
|
3972
|
+
values: this.valueList.join(":"),
|
|
3973
|
+
names: JSON.stringify(this.names),
|
|
3974
|
+
};
|
|
3975
|
+
};
|
|
3976
|
+
_proto2.isSame = function isSame(x) {
|
|
3977
|
+
var h = this.hash();
|
|
3978
|
+
var same =
|
|
3979
|
+
x &&
|
|
3980
|
+
!Object.keys(h).some(function (k) {
|
|
3981
|
+
return x[k] !== h[k];
|
|
3982
|
+
});
|
|
3983
|
+
this.shouldUpdate = !same;
|
|
3984
|
+
return same;
|
|
3985
|
+
};
|
|
3986
|
+
_proto2.acknowledge = function acknowledge(value, width, offset) {
|
|
3987
|
+
if (width === void 0) {
|
|
3988
|
+
width = 0;
|
|
3989
|
+
}
|
|
3990
|
+
if (offset === void 0) {
|
|
3991
|
+
offset = 0;
|
|
3992
|
+
}
|
|
3993
|
+
var index = this.valuesMap[value];
|
|
3994
|
+
if (isUndefined(index)) {
|
|
3995
|
+
index = this.valueList.length;
|
|
3996
|
+
this.valueList.push(value);
|
|
3997
|
+
this.valuesMap[value] = index;
|
|
3998
|
+
}
|
|
3999
|
+
if (this.minValue == null || index < this.minValue) {
|
|
4000
|
+
this.minValue = index;
|
|
4001
|
+
this.padding = Math.max(this.padding, Math.abs(offset - width / 2));
|
|
4002
|
+
}
|
|
4003
|
+
if (this.maxValue == null || index > this.maxValue) {
|
|
4004
|
+
this.maxValue = index;
|
|
4005
|
+
this.padding = Math.max(this.padding, Math.abs(offset + width / 2));
|
|
4006
|
+
}
|
|
4007
|
+
};
|
|
4008
|
+
_proto2.book = function book(value, name) {
|
|
4009
|
+
if (this.uniform) value = 0;
|
|
4010
|
+
var stack = this.valueStacks[value];
|
|
4011
|
+
if (!stack)
|
|
4012
|
+
stack = this.valueStacks[value] = {
|
|
4013
|
+
index: {},
|
|
4014
|
+
count: 0,
|
|
4015
|
+
};
|
|
4016
|
+
if (!stack.index.hasOwnProperty(name)) stack.index[name] = stack.count++;
|
|
4017
|
+
};
|
|
4018
|
+
_proto2.locate = function locate(value, name) {
|
|
4019
|
+
if (this.uniform) value = 0;
|
|
4020
|
+
var stack = this.valueStacks[value];
|
|
4021
|
+
if (!stack) return [0, 1];
|
|
4022
|
+
return [stack.index[name], stack.count];
|
|
4023
|
+
};
|
|
4024
|
+
_proto2.trackValue = function trackValue(v, offset, constrain) {
|
|
4025
|
+
if (offset === void 0) {
|
|
4026
|
+
offset = 0;
|
|
4027
|
+
}
|
|
4028
|
+
var index = Math.round((v - this.origin) / this.factor - offset + this.min - this.padding);
|
|
4029
|
+
if (index < this.min) index = this.min;
|
|
4030
|
+
if (index > this.max) index = this.max;
|
|
4031
|
+
return this.valueList[index];
|
|
4032
|
+
};
|
|
4033
|
+
_proto2.findTickSize = function findTickSize(minPxDist) {
|
|
4034
|
+
return 1;
|
|
4035
|
+
};
|
|
4036
|
+
_proto2.getTickSizes = function getTickSizes() {
|
|
4037
|
+
return [1];
|
|
4038
|
+
};
|
|
4039
|
+
_proto2.getTicks = function getTicks(tickSizes) {
|
|
4040
|
+
var _this2 = this;
|
|
4041
|
+
return tickSizes.map(function (size) {
|
|
4042
|
+
return _this2.valueList;
|
|
4043
|
+
});
|
|
4044
|
+
};
|
|
4045
|
+
_proto2.mapGridlines = function mapGridlines() {
|
|
4046
|
+
var _this3 = this;
|
|
4047
|
+
return Array.from({
|
|
4048
|
+
length: this.valueList.length + 1,
|
|
4049
|
+
}).map(function (_, index) {
|
|
4050
|
+
return _this3.origin + (index - 0.5 - _this3.min + _this3.padding) * _this3.factor;
|
|
4051
|
+
});
|
|
4052
|
+
};
|
|
4053
|
+
return CategoryScale;
|
|
4054
|
+
})();
|
|
4055
|
+
|
|
4056
|
+
Format$1.registerFactory("yearOrMonth", function (format) {
|
|
4057
|
+
var year = Format$1.parse("datetime;yyyy");
|
|
4058
|
+
var month = Format$1.parse("datetime;MMM");
|
|
4059
|
+
return function (date) {
|
|
4060
|
+
var d = new Date(date);
|
|
4061
|
+
if (d.getMonth() == 0) return year(d);
|
|
4062
|
+
else return month(d);
|
|
4063
|
+
};
|
|
4064
|
+
});
|
|
4065
|
+
Format$1.registerFactory("monthOrDay", function (format) {
|
|
4066
|
+
var month = Format$1.parse("datetime;MMM");
|
|
4067
|
+
var day = Format$1.parse("datetime;dd");
|
|
4068
|
+
return function (date) {
|
|
4069
|
+
var d = new Date(date);
|
|
4070
|
+
if (d.getDate() == 1) return month(d);
|
|
4071
|
+
else return day(d);
|
|
4072
|
+
};
|
|
4073
|
+
});
|
|
4074
|
+
var TimeAxis = /*#__PURE__*/ (function (_Axis) {
|
|
4075
|
+
_inheritsLoose(TimeAxis, _Axis);
|
|
4076
|
+
function TimeAxis() {
|
|
4077
|
+
return _Axis.apply(this, arguments) || this;
|
|
4078
|
+
}
|
|
4079
|
+
var _proto = TimeAxis.prototype;
|
|
4080
|
+
_proto.init = function init() {
|
|
4081
|
+
if (this.labelAnchor == "auto") this.labelAnchor = this.vertical ? (this.secondary ? "start" : "end") : "start";
|
|
4082
|
+
if (this.labelDx == "auto") this.labelDx = this.vertical ? 0 : "5px";
|
|
4083
|
+
if (this.deadZone) {
|
|
4084
|
+
this.lowerDeadZone = this.deadZone;
|
|
4085
|
+
this.upperDeadZone = this.deadZone;
|
|
4086
|
+
}
|
|
4087
|
+
_Axis.prototype.init.call(this);
|
|
4088
|
+
};
|
|
4089
|
+
_proto.declareData = function declareData() {
|
|
4090
|
+
var _Axis$prototype$decla;
|
|
4091
|
+
(_Axis$prototype$decla = _Axis.prototype.declareData).call.apply(
|
|
4092
|
+
_Axis$prototype$decla,
|
|
4093
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
4094
|
+
{
|
|
4095
|
+
anchors: undefined,
|
|
4096
|
+
min: undefined,
|
|
4097
|
+
max: undefined,
|
|
4098
|
+
inverted: undefined,
|
|
4099
|
+
lowerDeadZone: undefined,
|
|
4100
|
+
upperDeadZone: undefined,
|
|
4101
|
+
},
|
|
4102
|
+
])
|
|
4103
|
+
);
|
|
4104
|
+
};
|
|
4105
|
+
_proto.initInstance = function initInstance(context, instance) {
|
|
4106
|
+
instance.calculator = new TimeScale();
|
|
4107
|
+
};
|
|
4108
|
+
_proto.explore = function explore(context, instance) {
|
|
4109
|
+
_Axis.prototype.explore.call(this, context, instance);
|
|
4110
|
+
var _instance$data = instance.data,
|
|
4111
|
+
min = _instance$data.min,
|
|
4112
|
+
max = _instance$data.max,
|
|
4113
|
+
normalized = _instance$data.normalized,
|
|
4114
|
+
inverted = _instance$data.inverted,
|
|
4115
|
+
lowerDeadZone = _instance$data.lowerDeadZone,
|
|
4116
|
+
upperDeadZone = _instance$data.upperDeadZone;
|
|
4117
|
+
instance.calculator.reset(
|
|
4118
|
+
min,
|
|
4119
|
+
max,
|
|
4120
|
+
this.snapToTicks,
|
|
4121
|
+
this.tickDivisions,
|
|
4122
|
+
this.minTickDistance,
|
|
4123
|
+
this.minLabelDistance,
|
|
4124
|
+
normalized,
|
|
4125
|
+
inverted,
|
|
4126
|
+
this.minTickUnit,
|
|
4127
|
+
lowerDeadZone,
|
|
4128
|
+
upperDeadZone,
|
|
4129
|
+
this.decode
|
|
4130
|
+
);
|
|
4131
|
+
};
|
|
4132
|
+
_proto.render = function render(context, instance, key) {
|
|
4133
|
+
var data = instance.data,
|
|
4134
|
+
cached = instance.cached,
|
|
4135
|
+
calculator = instance.calculator;
|
|
4136
|
+
cached.axis = calculator.hash();
|
|
4137
|
+
if (!data.bounds.valid()) return null;
|
|
4138
|
+
var format = this.format || calculator.getFormat();
|
|
4139
|
+
var formatter = Format$1.parse(format);
|
|
4140
|
+
return /*#__PURE__*/ jsx(
|
|
4141
|
+
"g",
|
|
4142
|
+
{
|
|
4143
|
+
className: data.classNames,
|
|
4144
|
+
style: data.style,
|
|
4145
|
+
children: this.renderTicksAndLabels(context, instance, formatter),
|
|
4146
|
+
},
|
|
4147
|
+
key
|
|
4148
|
+
);
|
|
4149
|
+
};
|
|
4150
|
+
return TimeAxis;
|
|
4151
|
+
})(Axis);
|
|
4152
|
+
Axis.alias("time", TimeAxis);
|
|
4153
|
+
TimeAxis.prototype.baseClass = "timeaxis";
|
|
4154
|
+
TimeAxis.prototype.tickDivisions = {
|
|
4155
|
+
second: [[1, 5, 15, 30]],
|
|
4156
|
+
minute: [[1, 5, 15, 30]],
|
|
4157
|
+
hour: [
|
|
4158
|
+
[1, 2, 4, 8],
|
|
4159
|
+
[1, 3, 6, 12],
|
|
4160
|
+
],
|
|
4161
|
+
day: [[1]],
|
|
4162
|
+
week: [[1]],
|
|
4163
|
+
month: [[1, 3, 6]],
|
|
4164
|
+
year: [
|
|
4165
|
+
[1, 2, 10],
|
|
4166
|
+
[1, 5, 10],
|
|
4167
|
+
[5, 10, 50],
|
|
4168
|
+
[10, 50, 100],
|
|
4169
|
+
],
|
|
4170
|
+
};
|
|
4171
|
+
TimeAxis.prototype.snapToTicks = 0;
|
|
4172
|
+
TimeAxis.prototype.tickSize = 15;
|
|
4173
|
+
TimeAxis.prototype.minLabelDistance = 60;
|
|
4174
|
+
TimeAxis.prototype.minTickDistance = 60;
|
|
4175
|
+
TimeAxis.prototype.minTickUnit = "second";
|
|
4176
|
+
function monthNumber(date) {
|
|
4177
|
+
return date.getFullYear() * 12 + date.getMonth() + (date.getDate() - 1) / 31;
|
|
4178
|
+
}
|
|
4179
|
+
function yearNumber(date) {
|
|
4180
|
+
return monthNumber(date) / 12;
|
|
4181
|
+
}
|
|
4182
|
+
var miliSeconds = {
|
|
4183
|
+
second: 1000,
|
|
4184
|
+
minute: 60 * 1000,
|
|
4185
|
+
hour: 3600 * 1000,
|
|
4186
|
+
day: 3600 * 24 * 1000,
|
|
4187
|
+
week: 3600 * 24 * 7 * 1000,
|
|
4188
|
+
month: 3600 * 24 * 30 * 1000,
|
|
4189
|
+
year: 3600 * 24 * 365 * 1000,
|
|
4190
|
+
};
|
|
4191
|
+
var TimeScale = /*#__PURE__*/ (function () {
|
|
4192
|
+
function TimeScale() {}
|
|
4193
|
+
var _proto2 = TimeScale.prototype;
|
|
4194
|
+
_proto2.reset = function reset(
|
|
4195
|
+
min,
|
|
4196
|
+
max,
|
|
4197
|
+
snapToTicks,
|
|
4198
|
+
tickDivisions,
|
|
4199
|
+
minTickDistance,
|
|
4200
|
+
minLabelDistance,
|
|
4201
|
+
normalized,
|
|
4202
|
+
inverted,
|
|
4203
|
+
minTickUnit,
|
|
4204
|
+
lowerDeadZone,
|
|
4205
|
+
upperDeadZone,
|
|
4206
|
+
decode
|
|
4207
|
+
) {
|
|
4208
|
+
this.dateCache = {};
|
|
4209
|
+
this.min = min != null ? this.decodeValue(min) : null;
|
|
4210
|
+
this.max = max != null ? this.decodeValue(max) : null;
|
|
4211
|
+
this.snapToTicks = snapToTicks;
|
|
4212
|
+
this.tickDivisions = tickDivisions;
|
|
4213
|
+
this.minLabelDistance = minLabelDistance;
|
|
4214
|
+
this.minTickDistance = minTickDistance;
|
|
4215
|
+
this.tickSizes = [];
|
|
4216
|
+
this.normalized = normalized;
|
|
4217
|
+
this.minTickUnit = minTickUnit;
|
|
4218
|
+
this.inverted = inverted;
|
|
4219
|
+
this.lowerDeadZone = lowerDeadZone || 0;
|
|
4220
|
+
this.upperDeadZone = upperDeadZone || 0;
|
|
4221
|
+
delete this.minValue;
|
|
4222
|
+
delete this.maxValue;
|
|
4223
|
+
delete this.minValuePadded;
|
|
4224
|
+
delete this.maxValuePadded;
|
|
4225
|
+
this.stacks = {};
|
|
4226
|
+
this.decode = decode;
|
|
4227
|
+
};
|
|
4228
|
+
_proto2.decodeValue = function decodeValue(date) {
|
|
4229
|
+
if (date instanceof Date) return date.getTime();
|
|
4230
|
+
switch (typeof date) {
|
|
4231
|
+
case "string":
|
|
4232
|
+
var v = this.dateCache[date];
|
|
4233
|
+
if (!v) {
|
|
4234
|
+
if (this.decode) date = this.decode(date);
|
|
4235
|
+
v = this.dateCache[date] = Date.parse(date);
|
|
4236
|
+
}
|
|
4237
|
+
return v;
|
|
4238
|
+
case "number":
|
|
4239
|
+
return date;
|
|
4240
|
+
}
|
|
4241
|
+
};
|
|
4242
|
+
_proto2.encodeValue = function encodeValue(v) {
|
|
4243
|
+
return new Date(v).toISOString();
|
|
4244
|
+
};
|
|
4245
|
+
_proto2.getFormat = function getFormat() {
|
|
4246
|
+
switch (this.tickMeasure) {
|
|
4247
|
+
case "year":
|
|
4248
|
+
return "datetime;yyyy";
|
|
4249
|
+
case "month":
|
|
4250
|
+
if (new Date(this.scale.min).getFullYear() != new Date(this.scale.max).getFullYear()) return "yearOrMonth";
|
|
4251
|
+
return "datetime;yyyy MMM";
|
|
4252
|
+
case "week":
|
|
4253
|
+
return "datetime;MMMdd";
|
|
4254
|
+
case "day":
|
|
4255
|
+
if (
|
|
4256
|
+
new Date(this.scale.min).getFullYear() != new Date(this.scale.max).getFullYear() ||
|
|
4257
|
+
new Date(this.scale.min).getMonth() != new Date(this.scale.max).getMonth()
|
|
4258
|
+
)
|
|
4259
|
+
return "monthOrDay";
|
|
4260
|
+
return "datetime;yyyy MMM dd";
|
|
4261
|
+
case "hour":
|
|
4262
|
+
return "datetime;HH mm n";
|
|
4263
|
+
case "minute":
|
|
4264
|
+
return "datetime;HH mm n";
|
|
4265
|
+
case "second":
|
|
4266
|
+
return "datetime;mm ss";
|
|
4267
|
+
default:
|
|
4268
|
+
return "datetime;yyyy MMM dd HH mm ss n";
|
|
4269
|
+
}
|
|
4270
|
+
};
|
|
4271
|
+
_proto2.map = function map(v, offset) {
|
|
4272
|
+
if (offset === void 0) {
|
|
4273
|
+
offset = 0;
|
|
4274
|
+
}
|
|
4275
|
+
return this.origin + (this.decodeValue(v) + offset - this.scale.min + this.scale.minPadding) * this.scale.factor;
|
|
4276
|
+
};
|
|
4277
|
+
_proto2.constrainValue = function constrainValue(v) {
|
|
4278
|
+
return Math.max(this.scale.min, Math.min(this.scale.max, v));
|
|
4279
|
+
};
|
|
4280
|
+
_proto2.trackValue = function trackValue(v, offset, constrain) {
|
|
4281
|
+
if (offset === void 0) {
|
|
4282
|
+
offset = 0;
|
|
4283
|
+
}
|
|
4284
|
+
if (constrain === void 0) {
|
|
4285
|
+
constrain = false;
|
|
4286
|
+
}
|
|
4287
|
+
var value = (v - this.origin) / this.scale.factor - offset + this.scale.min - this.scale.minPadding;
|
|
4288
|
+
if (constrain) value = this.constrainValue(value);
|
|
4289
|
+
return value;
|
|
4290
|
+
};
|
|
4291
|
+
_proto2.hash = function hash() {
|
|
4292
|
+
var _this = this;
|
|
4293
|
+
var r = {
|
|
4294
|
+
origin: this.origin,
|
|
4295
|
+
factor: this.scale.factor,
|
|
4296
|
+
min: this.scale.min,
|
|
4297
|
+
max: this.scale.max,
|
|
4298
|
+
minPadding: this.scale.minPadding,
|
|
4299
|
+
maxPadding: this.scale.maxPadding,
|
|
4300
|
+
};
|
|
4301
|
+
r.stacks = Object.keys(this.stacks)
|
|
4302
|
+
.map(function (s) {
|
|
4303
|
+
return _this.stacks[s].info.join(",");
|
|
4304
|
+
})
|
|
4305
|
+
.join(":");
|
|
4306
|
+
return r;
|
|
4307
|
+
};
|
|
4308
|
+
_proto2.isSame = function isSame(x) {
|
|
4309
|
+
var hash = this.hash();
|
|
4310
|
+
var same =
|
|
4311
|
+
x &&
|
|
4312
|
+
!Object.keys(hash).some(function (k) {
|
|
4313
|
+
return x[k] !== hash[k];
|
|
4314
|
+
});
|
|
4315
|
+
this.shouldUpdate = !same;
|
|
4316
|
+
return same;
|
|
4317
|
+
};
|
|
4318
|
+
_proto2.measure = function measure(a, b) {
|
|
4319
|
+
this.a = a;
|
|
4320
|
+
this.b = b;
|
|
4321
|
+
for (var s in this.stacks) {
|
|
4322
|
+
var info = this.stacks[s].measure(this.normalized);
|
|
4323
|
+
var min = info[0],
|
|
4324
|
+
max = info[1];
|
|
4325
|
+
info[2];
|
|
4326
|
+
if (this.minValue == null || min < this.minValue) this.minValue = min;
|
|
4327
|
+
if (this.max == null || max > this.maxValue) this.maxValue = max;
|
|
4328
|
+
this.stacks[s].info = info;
|
|
4329
|
+
}
|
|
4330
|
+
if (this.min == null) {
|
|
4331
|
+
if (this.minValue != null) this.min = this.minValue;
|
|
4332
|
+
else this.min = 0;
|
|
4333
|
+
}
|
|
4334
|
+
if (this.max == null) {
|
|
4335
|
+
if (this.maxValue != null) this.max = this.maxValue;
|
|
4336
|
+
else this.max = this.normalized ? 1 : 100;
|
|
4337
|
+
}
|
|
4338
|
+
this.origin = this.inverted ? this.b : this.a;
|
|
4339
|
+
this.scale = this.getScale();
|
|
4340
|
+
this.calculateTicks();
|
|
4341
|
+
};
|
|
4342
|
+
_proto2.getTimezoneOffset = function getTimezoneOffset(date) {
|
|
4343
|
+
return date.getTimezoneOffset() * 60 * 1000;
|
|
4344
|
+
};
|
|
4345
|
+
_proto2.getScale = function getScale(tickSizes, measure) {
|
|
4346
|
+
var min = this.min,
|
|
4347
|
+
max = this.max,
|
|
4348
|
+
upperDeadZone = this.upperDeadZone,
|
|
4349
|
+
lowerDeadZone = this.lowerDeadZone;
|
|
4350
|
+
var smin = min;
|
|
4351
|
+
var smax = max;
|
|
4352
|
+
if (isNumber(this.snapToTicks) && measure && tickSizes && 0 <= this.snapToTicks && tickSizes.length > 0) {
|
|
4353
|
+
var tickSize = tickSizes[Math.min(tickSizes.length - 1, this.snapToTicks)];
|
|
4354
|
+
var minDate = new Date(min);
|
|
4355
|
+
var maxDate = new Date(max);
|
|
4356
|
+
switch (measure) {
|
|
4357
|
+
case "second":
|
|
4358
|
+
case "minute":
|
|
4359
|
+
case "hours":
|
|
4360
|
+
case "day":
|
|
4361
|
+
default:
|
|
4362
|
+
var minOffset = this.getTimezoneOffset(minDate);
|
|
4363
|
+
var maxOffset = this.getTimezoneOffset(maxDate);
|
|
4364
|
+
var mondayOffset = 4 * miliSeconds.day; //new Date(0).getDay() => 4
|
|
4365
|
+
smin = Math.floor((smin - minOffset - mondayOffset) / tickSize) * tickSize + minOffset + mondayOffset;
|
|
4366
|
+
smax = Math.ceil((smax - maxOffset - mondayOffset) / tickSize) * tickSize + maxOffset + mondayOffset;
|
|
4367
|
+
break;
|
|
4368
|
+
case "month":
|
|
4369
|
+
tickSize /= miliSeconds.month;
|
|
4370
|
+
var minMonth = monthNumber(minDate);
|
|
4371
|
+
var maxMonth = monthNumber(maxDate);
|
|
4372
|
+
minMonth = Math.floor(minMonth / tickSize) * tickSize;
|
|
4373
|
+
maxMonth = Math.ceil(maxMonth / tickSize) * tickSize;
|
|
4374
|
+
smin = new Date(Math.floor(minMonth / 12), minMonth % 12, 1).getTime();
|
|
4375
|
+
smax = new Date(Math.floor(maxMonth / 12), maxMonth % 12, 1).getTime();
|
|
4376
|
+
break;
|
|
4377
|
+
case "year":
|
|
4378
|
+
tickSize /= miliSeconds.year;
|
|
4379
|
+
var minYear = yearNumber(minDate);
|
|
4380
|
+
var maxYear = yearNumber(maxDate);
|
|
4381
|
+
minYear = Math.floor(minYear / tickSize) * tickSize;
|
|
4382
|
+
maxYear = Math.ceil(maxYear / tickSize) * tickSize;
|
|
4383
|
+
smin = new Date(minYear, 0, 1).getTime();
|
|
4384
|
+
smax = new Date(maxYear, 0, 1).getTime();
|
|
4385
|
+
break;
|
|
4386
|
+
}
|
|
4387
|
+
} else {
|
|
4388
|
+
if (this.minValue == min) smin = this.minValuePadded;
|
|
4389
|
+
if (this.maxValue == max) smax = this.maxValuePadded;
|
|
4390
|
+
}
|
|
4391
|
+
|
|
4392
|
+
//padding should be activated only if using min/max obtained from the data
|
|
4393
|
+
var minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
|
|
4394
|
+
var maxPadding = this.maxValue === max ? Math.max(0, this.maxValuePadded - smax) : 0;
|
|
4395
|
+
var factor = smin < smax ? Math.abs(this.b - this.a) / (smax - smin + minPadding + maxPadding) : 0;
|
|
4396
|
+
if (factor > 0 && (upperDeadZone > 0 || lowerDeadZone > 0)) {
|
|
4397
|
+
smin -= lowerDeadZone / factor;
|
|
4398
|
+
smax += upperDeadZone / factor;
|
|
4399
|
+
minPadding = this.minValuePadded != null ? Math.max(0, smin - this.minValuePadded) : 0;
|
|
4400
|
+
maxPadding = this.maxValuePadded != null ? Math.max(0, this.maxValuePadded - smax) : 0;
|
|
4401
|
+
factor = smin < smax ? Math.abs(this.b - this.a) / (smax - smin + minPadding + maxPadding) : 0;
|
|
4402
|
+
}
|
|
4403
|
+
var sign = this.b > this.a ? 1 : -1;
|
|
4404
|
+
return {
|
|
4405
|
+
factor: sign * (this.inverted ? -factor : factor),
|
|
4406
|
+
min: smin,
|
|
4407
|
+
max: smax,
|
|
4408
|
+
minPadding: minPadding,
|
|
4409
|
+
maxPadding: maxPadding,
|
|
4410
|
+
};
|
|
4411
|
+
};
|
|
4412
|
+
_proto2.acknowledge = function acknowledge(value, width, offset) {
|
|
4413
|
+
if (width === void 0) {
|
|
4414
|
+
width = 0;
|
|
4415
|
+
}
|
|
4416
|
+
if (offset === void 0) {
|
|
4417
|
+
offset = 0;
|
|
4418
|
+
}
|
|
4419
|
+
value = this.decodeValue(value);
|
|
4420
|
+
if (this.minValue == null || value + offset - width / 2 < this.minValuePadded) {
|
|
4421
|
+
this.minValue = value;
|
|
4422
|
+
this.minValuePadded = value + offset - width / 2;
|
|
4423
|
+
}
|
|
4424
|
+
if (this.maxValue == null || value + offset + width / 2 > this.maxValuePadded) {
|
|
4425
|
+
this.maxValue = value;
|
|
4426
|
+
this.maxValuePadded = value + offset + width / 2;
|
|
4427
|
+
}
|
|
4428
|
+
};
|
|
4429
|
+
_proto2.getStack = function getStack(name) {
|
|
4430
|
+
var s = this.stacks[name];
|
|
4431
|
+
if (!s) s = this.stacks[name] = new Stack();
|
|
4432
|
+
return s;
|
|
4433
|
+
};
|
|
4434
|
+
_proto2.stacknowledge = function stacknowledge(name, ordinal, value) {
|
|
4435
|
+
return this.getStack(name).acknowledge(ordinal, value);
|
|
4436
|
+
};
|
|
4437
|
+
_proto2.stack = function stack(name, ordinal, value) {
|
|
4438
|
+
var v = this.getStack(name).stack(ordinal, value);
|
|
4439
|
+
return v != null ? this.map(v) : null;
|
|
4440
|
+
};
|
|
4441
|
+
_proto2.findTickSize = function findTickSize(minPxDist) {
|
|
4442
|
+
var _this2 = this;
|
|
4443
|
+
return this.tickSizes.find(function (a) {
|
|
4444
|
+
return a * Math.abs(_this2.scale.factor) >= minPxDist;
|
|
4445
|
+
});
|
|
4446
|
+
};
|
|
4447
|
+
_proto2.getTickSizes = function getTickSizes() {
|
|
4448
|
+
return this.tickSizes;
|
|
4449
|
+
};
|
|
4450
|
+
_proto2.calculateTicks = function calculateTicks() {
|
|
4451
|
+
var _this3 = this;
|
|
4452
|
+
var minReached = false;
|
|
4453
|
+
var _loop = function _loop() {
|
|
4454
|
+
if (!minReached) {
|
|
4455
|
+
if (unit == _this3.minTickUnit) minReached = true;
|
|
4456
|
+
else return "continue";
|
|
4457
|
+
}
|
|
4458
|
+
var unitSize = miliSeconds[unit];
|
|
4459
|
+
var divisions = _this3.tickDivisions[unit];
|
|
4460
|
+
if (_this3.tickSizes.length > 0) {
|
|
4461
|
+
var _this3$tickSizes;
|
|
4462
|
+
//add ticks from higher levels
|
|
4463
|
+
(_this3$tickSizes = _this3.tickSizes).push.apply(
|
|
4464
|
+
_this3$tickSizes,
|
|
4465
|
+
divisions[0].map(function (s) {
|
|
4466
|
+
return s * unitSize;
|
|
4467
|
+
})
|
|
4468
|
+
);
|
|
4469
|
+
return "continue";
|
|
4470
|
+
}
|
|
4471
|
+
var bestLabelDistance = Infinity;
|
|
4472
|
+
var bestTicks = [];
|
|
4473
|
+
var bestScale = _this3.scale;
|
|
4474
|
+
_this3.tickMeasure = unit;
|
|
4475
|
+
var _loop2 = function _loop2() {
|
|
4476
|
+
var divs = divisions[i];
|
|
4477
|
+
var tickSizes = divs.map(function (s) {
|
|
4478
|
+
return s * unitSize;
|
|
4479
|
+
});
|
|
4480
|
+
var scale = _this3.getScale(tickSizes, unit);
|
|
4481
|
+
tickSizes.forEach(function (size, level) {
|
|
4482
|
+
var tickDistance = size * Math.abs(scale.factor);
|
|
4483
|
+
if (tickDistance >= _this3.minTickDistance && tickDistance < bestLabelDistance) {
|
|
4484
|
+
bestScale = scale;
|
|
4485
|
+
bestTicks = tickSizes;
|
|
4486
|
+
bestLabelDistance = tickDistance;
|
|
4487
|
+
}
|
|
4488
|
+
});
|
|
4489
|
+
};
|
|
4490
|
+
for (var i = 0; i < divisions.length; i++) {
|
|
4491
|
+
_loop2();
|
|
4492
|
+
}
|
|
4493
|
+
_this3.scale = bestScale;
|
|
4494
|
+
_this3.tickSizes = bestTicks.filter(function (ts) {
|
|
4495
|
+
return ts * Math.abs(bestScale.factor) >= _this3.minTickDistance;
|
|
4496
|
+
});
|
|
4497
|
+
};
|
|
4498
|
+
for (var unit in miliSeconds) {
|
|
4499
|
+
var _ret = _loop();
|
|
4500
|
+
if (_ret === "continue") continue;
|
|
4501
|
+
}
|
|
4502
|
+
};
|
|
4503
|
+
_proto2.getTicks = function getTicks(tickSizes) {
|
|
4504
|
+
var _this4 = this;
|
|
4505
|
+
return tickSizes.map(function (size) {
|
|
4506
|
+
var result = [],
|
|
4507
|
+
start,
|
|
4508
|
+
end,
|
|
4509
|
+
minDate,
|
|
4510
|
+
maxDate;
|
|
4511
|
+
if (_this4.tickMeasure == "year") {
|
|
4512
|
+
size /= miliSeconds.year;
|
|
4513
|
+
minDate = new Date(_this4.scale.min - _this4.scale.minPadding);
|
|
4514
|
+
maxDate = new Date(_this4.scale.max + _this4.scale.maxPadding);
|
|
4515
|
+
start = Math.ceil(yearNumber(minDate) / size) * size;
|
|
4516
|
+
end = Math.floor(yearNumber(maxDate) / size) * size;
|
|
4517
|
+
for (var i = start; i <= end; i += size) result.push(new Date(i, 0, 1).getTime());
|
|
4518
|
+
} else if (_this4.tickMeasure == "month") {
|
|
4519
|
+
size /= miliSeconds.month;
|
|
4520
|
+
minDate = new Date(_this4.scale.min - _this4.scale.minPadding);
|
|
4521
|
+
maxDate = new Date(_this4.scale.max + _this4.scale.maxPadding);
|
|
4522
|
+
start = Math.ceil(monthNumber(minDate) / size) * size;
|
|
4523
|
+
end = Math.floor(monthNumber(maxDate) / size) * size;
|
|
4524
|
+
for (var _i = start; _i <= end; _i += size) result.push(new Date(Math.floor(_i / 12), _i % 12, 1).getTime());
|
|
4525
|
+
} else if (_this4.tickMeasure == "day" || _this4.tickMeasure == "week") {
|
|
4526
|
+
var multiplier = _this4.tickMeasure == "week" ? 7 : 1;
|
|
4527
|
+
size /= miliSeconds.day;
|
|
4528
|
+
minDate = new Date(_this4.scale.min - _this4.scale.minPadding);
|
|
4529
|
+
maxDate = new Date(_this4.scale.max + _this4.scale.maxPadding);
|
|
4530
|
+
var date = zeroTime(minDate);
|
|
4531
|
+
if (_this4.tickMeasure == "week") {
|
|
4532
|
+
//start on monday
|
|
4533
|
+
while (date.getDay() != 1) {
|
|
4534
|
+
date.setDate(date.getDate() + 1);
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
while (date.getTime() <= maxDate.getTime()) {
|
|
4538
|
+
result.push(date);
|
|
4539
|
+
date = new Date(date);
|
|
4540
|
+
date.setDate(date.getDate() + multiplier);
|
|
4541
|
+
}
|
|
4542
|
+
} else {
|
|
4543
|
+
var minOffset = _this4.getTimezoneOffset(new Date(_this4.scale.min - _this4.scale.minPadding));
|
|
4544
|
+
var mondayOffset = 4 * miliSeconds.day;
|
|
4545
|
+
var _date =
|
|
4546
|
+
Math.ceil((_this4.scale.min - _this4.scale.minPadding - minOffset - mondayOffset) / size) * size +
|
|
4547
|
+
minOffset +
|
|
4548
|
+
mondayOffset;
|
|
4549
|
+
while (_date <= _this4.scale.max + _this4.scale.maxPadding) {
|
|
4550
|
+
result.push(_date);
|
|
4551
|
+
_date += size;
|
|
4552
|
+
}
|
|
4553
|
+
}
|
|
4554
|
+
return result;
|
|
4555
|
+
});
|
|
4556
|
+
};
|
|
4557
|
+
_proto2.mapGridlines = function mapGridlines() {
|
|
4558
|
+
var _this5 = this;
|
|
4559
|
+
if (this.tickSizes.length == 0) return [];
|
|
4560
|
+
return this.getTicks([this.tickSizes[0]])[0].map(function (x) {
|
|
4561
|
+
return _this5.map(x);
|
|
4562
|
+
});
|
|
4563
|
+
};
|
|
4564
|
+
return TimeScale;
|
|
4565
|
+
})();
|
|
4566
|
+
|
|
4567
|
+
var PointReducer = /*#__PURE__*/ (function (_PureContainer) {
|
|
4568
|
+
_inheritsLoose(PointReducer, _PureContainer);
|
|
4569
|
+
function PointReducer() {
|
|
4570
|
+
return _PureContainer.apply(this, arguments) || this;
|
|
4571
|
+
}
|
|
4572
|
+
var _proto = PointReducer.prototype;
|
|
4573
|
+
_proto.explore = function explore(context, instance) {
|
|
4574
|
+
var _this = this;
|
|
4575
|
+
var pointReducer = context.pointReducer;
|
|
4576
|
+
instance.parentPointTracker = pointReducer;
|
|
4577
|
+
if (!instance.pointReducer) {
|
|
4578
|
+
var onMap = this.onMap && instance.getCallback("onMap");
|
|
4579
|
+
var accumulator = {};
|
|
4580
|
+
instance.resetAccumulator = function () {
|
|
4581
|
+
accumulator = {};
|
|
4582
|
+
if (_this.onInitAccumulator) instance.invoke("onInitAccumulator", accumulator, instance);
|
|
4583
|
+
};
|
|
4584
|
+
instance.pointReducer = function (x, y, name, data, array, index) {
|
|
4585
|
+
onMap(accumulator, x, y, name, data, array, index);
|
|
4586
|
+
if (pointReducer) pointReducer(x, y, name, data, array, index);
|
|
4587
|
+
};
|
|
4588
|
+
instance.write = function () {
|
|
4589
|
+
if (_this.onReduce) instance.invoke("onReduce", accumulator, instance);
|
|
4590
|
+
};
|
|
4591
|
+
}
|
|
4592
|
+
instance.resetAccumulator();
|
|
4593
|
+
context.push("pointReducer", instance.pointReducer);
|
|
4594
|
+
_PureContainer.prototype.explore.call(this, context, instance);
|
|
4595
|
+
};
|
|
4596
|
+
_proto.exploreCleanup = function exploreCleanup(context, instance) {
|
|
4597
|
+
instance.write();
|
|
4598
|
+
context.pop("pointReducer");
|
|
4599
|
+
};
|
|
4600
|
+
return PointReducer;
|
|
4601
|
+
})(PureContainer);
|
|
4602
|
+
|
|
4603
|
+
var MinMaxFinder = /*#__PURE__*/ (function (_PointReducer) {
|
|
4604
|
+
_inheritsLoose(MinMaxFinder, _PointReducer);
|
|
4605
|
+
function MinMaxFinder() {
|
|
4606
|
+
return _PointReducer.apply(this, arguments) || this;
|
|
4607
|
+
}
|
|
4608
|
+
var _proto = MinMaxFinder.prototype;
|
|
4609
|
+
_proto.declareData = function declareData() {
|
|
4610
|
+
var _PointReducer$prototy;
|
|
4611
|
+
return (_PointReducer$prototy = _PointReducer.prototype.declareData).call.apply(
|
|
4612
|
+
_PointReducer$prototy,
|
|
4613
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
4614
|
+
{
|
|
4615
|
+
minX: undefined,
|
|
4616
|
+
minY: undefined,
|
|
4617
|
+
maxX: undefined,
|
|
4618
|
+
maxY: undefined,
|
|
4619
|
+
params: {
|
|
4620
|
+
structured: true,
|
|
4621
|
+
},
|
|
4622
|
+
},
|
|
4623
|
+
])
|
|
4624
|
+
);
|
|
4625
|
+
};
|
|
4626
|
+
_proto.onInitAccumulator = function onInitAccumulator(acc, _ref) {
|
|
4627
|
+
var data = _ref.data;
|
|
4628
|
+
acc.params = data.params;
|
|
4629
|
+
acc.min = {
|
|
4630
|
+
x: null,
|
|
4631
|
+
y: null,
|
|
4632
|
+
};
|
|
4633
|
+
acc.max = {
|
|
4634
|
+
x: null,
|
|
4635
|
+
y: null,
|
|
4636
|
+
};
|
|
4637
|
+
};
|
|
4638
|
+
_proto.onMap = function onMap(acc, x, y, name, p) {
|
|
4639
|
+
if (y != null && (acc.max.y == null || acc.max.y < y))
|
|
4640
|
+
acc.max = {
|
|
4641
|
+
x: x,
|
|
4642
|
+
y: y,
|
|
4643
|
+
p: p,
|
|
4644
|
+
};
|
|
4645
|
+
if (y != null && (acc.min.y == null || acc.min.y > y))
|
|
4646
|
+
acc.min = {
|
|
4647
|
+
x: x,
|
|
4648
|
+
y: y,
|
|
4649
|
+
p: p,
|
|
4650
|
+
};
|
|
4651
|
+
};
|
|
4652
|
+
_proto.onReduce = function onReduce(acc, instance) {
|
|
4653
|
+
instance.set("minX", acc.min.x);
|
|
4654
|
+
instance.set("minY", acc.min.y);
|
|
4655
|
+
instance.set("minRecord", acc.min.p);
|
|
4656
|
+
instance.set("maxX", acc.max.x);
|
|
4657
|
+
instance.set("maxY", acc.max.y);
|
|
4658
|
+
instance.set("maxRecord", acc.max.p);
|
|
4659
|
+
};
|
|
4660
|
+
return MinMaxFinder;
|
|
4661
|
+
})(PointReducer);
|
|
4662
|
+
|
|
4663
|
+
var SnapPointFinder = /*#__PURE__*/ (function (_PointReducer) {
|
|
4664
|
+
_inheritsLoose(SnapPointFinder, _PointReducer);
|
|
4665
|
+
function SnapPointFinder() {
|
|
4666
|
+
return _PointReducer.apply(this, arguments) || this;
|
|
4667
|
+
}
|
|
4668
|
+
var _proto = SnapPointFinder.prototype;
|
|
4669
|
+
_proto.declareData = function declareData() {
|
|
4670
|
+
var _PointReducer$prototy;
|
|
4671
|
+
return (_PointReducer$prototy = _PointReducer.prototype.declareData).call.apply(
|
|
4672
|
+
_PointReducer$prototy,
|
|
4673
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
4674
|
+
{
|
|
4675
|
+
cursorX: undefined,
|
|
4676
|
+
cursorY: undefined,
|
|
4677
|
+
snapX: undefined,
|
|
4678
|
+
snapY: undefined,
|
|
4679
|
+
snapRecord: undefined,
|
|
4680
|
+
maxDistance: undefined,
|
|
4681
|
+
},
|
|
4682
|
+
])
|
|
4683
|
+
);
|
|
4684
|
+
};
|
|
4685
|
+
_proto.onInitAccumulator = function onInitAccumulator(acc, _ref) {
|
|
4686
|
+
var data = _ref.data;
|
|
4687
|
+
acc.cursorX = data.cursorX;
|
|
4688
|
+
acc.cursorY = data.cursorY;
|
|
4689
|
+
acc.dist = data.maxDistance > 0 ? Math.pow(data.maxDistance, 2) : Number.POSITIVE_INFINITY;
|
|
4690
|
+
acc.snapX = null;
|
|
4691
|
+
acc.snapY = null;
|
|
4692
|
+
};
|
|
4693
|
+
_proto.onMap = function onMap(acc, x, y, name, p) {
|
|
4694
|
+
var d = null;
|
|
4695
|
+
if (acc.cursorX != null && x != null) d = (d || 0) + Math.pow(Math.abs(x - acc.cursorX), 2);
|
|
4696
|
+
if (acc.cursorY != null && y != null) d = (d || 0) + Math.pow(Math.abs(y - acc.cursorY), 2);
|
|
4697
|
+
if (d != null && d < acc.dist) {
|
|
4698
|
+
acc.dist = d;
|
|
4699
|
+
acc.snapX = x;
|
|
4700
|
+
acc.snapY = y;
|
|
4701
|
+
acc.snapRecord = p;
|
|
4702
|
+
}
|
|
4703
|
+
};
|
|
4704
|
+
_proto.onReduce = function onReduce(acc, instance) {
|
|
4705
|
+
instance.set("snapX", acc.snapX);
|
|
4706
|
+
instance.set("snapY", acc.snapY);
|
|
4707
|
+
instance.set("snapRecord", acc.snapRecord);
|
|
4708
|
+
};
|
|
4709
|
+
return SnapPointFinder;
|
|
4710
|
+
})(PointReducer);
|
|
4711
|
+
SnapPointFinder.prototype.maxDistance = 50;
|
|
4712
|
+
|
|
4713
|
+
var ValueAtFinder = /*#__PURE__*/ (function (_PointReducer) {
|
|
4714
|
+
_inheritsLoose(ValueAtFinder, _PointReducer);
|
|
4715
|
+
function ValueAtFinder() {
|
|
4716
|
+
return _PointReducer.apply(this, arguments) || this;
|
|
4717
|
+
}
|
|
4718
|
+
var _proto = ValueAtFinder.prototype;
|
|
4719
|
+
_proto.declareData = function declareData() {
|
|
4720
|
+
var _PointReducer$prototy;
|
|
4721
|
+
return (_PointReducer$prototy = _PointReducer.prototype.declareData).call.apply(
|
|
4722
|
+
_PointReducer$prototy,
|
|
4723
|
+
[this].concat(Array.prototype.slice.call(arguments), [
|
|
4724
|
+
{
|
|
4725
|
+
at: undefined,
|
|
4726
|
+
value: undefined,
|
|
4727
|
+
},
|
|
4728
|
+
])
|
|
4729
|
+
);
|
|
4730
|
+
};
|
|
4731
|
+
_proto.onInitAccumulator = function onInitAccumulator(acc, _ref) {
|
|
4732
|
+
var data = _ref.data;
|
|
4733
|
+
acc.at = this.convert(data.at);
|
|
4734
|
+
};
|
|
4735
|
+
_proto.onMap = function onMap(acc, x, y, name) {
|
|
4736
|
+
var d = this.convert(x) - acc.at;
|
|
4737
|
+
if (d <= 0 && (!acc.left || acc.left.d < d)) {
|
|
4738
|
+
acc.left = {
|
|
4739
|
+
x: x,
|
|
4740
|
+
y: y,
|
|
4741
|
+
d: d,
|
|
4742
|
+
};
|
|
4743
|
+
}
|
|
4744
|
+
if (d >= 0 && (!acc.right || acc.right.d > d)) {
|
|
4745
|
+
acc.right = {
|
|
4746
|
+
x: x,
|
|
4747
|
+
y: y,
|
|
4748
|
+
d: d,
|
|
4749
|
+
};
|
|
4750
|
+
}
|
|
4751
|
+
};
|
|
4752
|
+
_proto.onReduce = function onReduce(acc, instance) {
|
|
4753
|
+
var y = null;
|
|
4754
|
+
if (acc.left && acc.right) {
|
|
4755
|
+
if (acc.left.x == acc.right.x) y = acc.left.y;
|
|
4756
|
+
else if (acc.left.y != null && acc.right.y != null) {
|
|
4757
|
+
y = acc.left.y + ((acc.right.y - acc.left.y) * (acc.at - acc.left.x)) / (acc.right.x - acc.left.x);
|
|
4758
|
+
}
|
|
4759
|
+
}
|
|
4760
|
+
instance.set("value", y);
|
|
4761
|
+
};
|
|
4762
|
+
return ValueAtFinder;
|
|
4763
|
+
})(PointReducer);
|
|
4764
|
+
ValueAtFinder.prototype.convert = function (x) {
|
|
4765
|
+
return x;
|
|
4766
|
+
};
|
|
4767
|
+
|
|
4768
|
+
export {
|
|
4769
|
+
Axis,
|
|
4770
|
+
Bar,
|
|
4771
|
+
BarGraph,
|
|
4772
|
+
BubbleGraph,
|
|
4773
|
+
CategoryAxis,
|
|
4774
|
+
Chart,
|
|
4775
|
+
ColorIndex,
|
|
4776
|
+
ColorMap,
|
|
4777
|
+
ColorMapScope,
|
|
4778
|
+
Column,
|
|
4779
|
+
ColumnGraph,
|
|
4780
|
+
Gridlines,
|
|
4781
|
+
Legend,
|
|
4782
|
+
LegendEntry,
|
|
4783
|
+
LegendScope,
|
|
4784
|
+
LineGraph,
|
|
4785
|
+
Marker,
|
|
4786
|
+
MarkerLine,
|
|
4787
|
+
MinMaxFinder,
|
|
4788
|
+
MouseTracker,
|
|
4789
|
+
NumericAxis,
|
|
4790
|
+
Pie,
|
|
4791
|
+
PieChart,
|
|
4792
|
+
PieLabel,
|
|
4793
|
+
PieLabelsContainer,
|
|
4794
|
+
PieSlice,
|
|
4795
|
+
PointReducer,
|
|
4796
|
+
Range,
|
|
4797
|
+
ScatterGraph,
|
|
4798
|
+
SnapPointFinder,
|
|
4799
|
+
TimeAxis,
|
|
4800
|
+
ValueAtFinder,
|
|
4801
|
+
bar,
|
|
4802
|
+
circle,
|
|
4803
|
+
column,
|
|
4804
|
+
getAvailableShapes,
|
|
4805
|
+
getShape,
|
|
4806
|
+
line,
|
|
4807
|
+
registerShape,
|
|
4808
|
+
square,
|
|
4809
|
+
triangle,
|
|
4810
|
+
vline,
|
|
4811
|
+
};
|