billboard.js 3.11.2 → 3.12.0-next.1
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/README.md +2 -6
- package/dist/billboard.css +5 -1
- package/dist/billboard.js +19431 -24292
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +26 -3
- package/dist/billboard.pkgd.js +22301 -29057
- package/dist/billboard.pkgd.min.js +33 -3
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
- package/dist/plugin/billboardjs-plugin-sparkline.js +423 -1134
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +660 -1524
- package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
- package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
- package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
- package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +339 -1324
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1701 -3424
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2385 -4462
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1783 -3467
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2031 -3979
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
- package/dist/theme/dark.css +5 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +5 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +5 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +5 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +5 -1
- package/dist/theme/modern.min.css +3 -4
- package/dist-esm/billboard.js +9051 -8666
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +19 -25
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +149 -148
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +295 -286
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +235 -234
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +40 -41
- package/package.json +26 -46
- package/src/Chart/api/axis.ts +6 -13
- package/src/Chart/api/chart.ts +12 -11
- package/src/Chart/api/data.ts +8 -7
- package/src/Chart/api/export.ts +28 -21
- package/src/Chart/api/flow.ts +4 -2
- package/src/Chart/api/grid.ts +1 -5
- package/src/Chart/api/load.ts +2 -2
- package/src/Chart/api/regions.ts +29 -5
- package/src/Chart/api/selection.ts +2 -2
- package/src/Chart/api/show.ts +2 -3
- package/src/Chart/api/subchart.ts +2 -2
- package/src/Chart/api/tooltip.ts +5 -7
- package/src/Chart/api/x.ts +2 -2
- package/src/Chart/api/zoom.ts +2 -2
- package/src/ChartInternal/Axis/Axis.ts +119 -44
- package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
- package/src/ChartInternal/ChartInternal.ts +79 -51
- package/src/ChartInternal/data/IData.ts +22 -29
- package/src/ChartInternal/data/convert.helper.ts +66 -68
- package/src/ChartInternal/data/convert.ts +11 -11
- package/src/ChartInternal/data/data.ts +40 -23
- package/src/ChartInternal/data/load.ts +7 -6
- package/src/ChartInternal/interactions/drag.ts +2 -1
- package/src/ChartInternal/interactions/eventrect.ts +54 -25
- package/src/ChartInternal/interactions/flow.ts +14 -4
- package/src/ChartInternal/interactions/interaction.ts +34 -12
- package/src/ChartInternal/interactions/subchart.ts +27 -25
- package/src/ChartInternal/interactions/zoom.ts +29 -18
- package/src/ChartInternal/internals/category.ts +1 -1
- package/src/ChartInternal/internals/class.ts +5 -5
- package/src/ChartInternal/internals/clip.ts +9 -10
- package/src/ChartInternal/internals/color.ts +70 -42
- package/src/ChartInternal/internals/domain.ts +59 -28
- package/src/ChartInternal/internals/format.ts +5 -5
- package/src/ChartInternal/internals/grid.ts +130 -47
- package/src/ChartInternal/internals/legend.ts +99 -66
- package/src/ChartInternal/internals/redraw.ts +3 -2
- package/src/ChartInternal/internals/region.ts +5 -3
- package/src/ChartInternal/internals/scale.ts +28 -15
- package/src/ChartInternal/internals/selection.ts +14 -13
- package/src/ChartInternal/internals/size.axis.ts +18 -10
- package/src/ChartInternal/internals/size.ts +97 -66
- package/src/ChartInternal/internals/style.ts +21 -19
- package/src/ChartInternal/internals/text.ts +64 -39
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +83 -34
- package/src/ChartInternal/internals/transform.ts +2 -2
- package/src/ChartInternal/internals/type.ts +12 -12
- package/src/ChartInternal/shape/arc.ts +78 -44
- package/src/ChartInternal/shape/area.ts +19 -22
- package/src/ChartInternal/shape/bar.ts +41 -31
- package/src/ChartInternal/shape/bubble.ts +5 -5
- package/src/ChartInternal/shape/candlestick.ts +15 -13
- package/src/ChartInternal/shape/gauge.ts +16 -9
- package/src/ChartInternal/shape/line.ts +62 -46
- package/src/ChartInternal/shape/point.common.ts +1 -4
- package/src/ChartInternal/shape/point.ts +52 -32
- package/src/ChartInternal/shape/polar.ts +4 -2
- package/src/ChartInternal/shape/radar.ts +40 -22
- package/src/ChartInternal/shape/shape.ts +84 -58
- package/src/ChartInternal/shape/treemap.ts +29 -20
- package/src/Plugin/bubblecompare/index.ts +1 -3
- package/src/Plugin/sparkline/index.ts +3 -4
- package/src/Plugin/stanford/ColorScale.ts +3 -2
- package/src/Plugin/stanford/Elements.ts +15 -6
- package/src/Plugin/stanford/Options.ts +5 -5
- package/src/Plugin/stanford/index.ts +13 -9
- package/src/Plugin/tableview/Options.ts +1 -1
- package/src/Plugin/tableview/const.ts +1 -4
- package/src/Plugin/tableview/index.ts +11 -9
- package/src/Plugin/textoverlap/index.ts +4 -6
- package/src/config/Options/Options.ts +3 -3
- package/src/config/Options/axis/axis.ts +36 -0
- package/src/config/Options/axis/x.ts +12 -13
- package/src/config/Options/axis/y.ts +13 -13
- package/src/config/Options/axis/y2.ts +23 -10
- package/src/config/Options/common/color.ts +4 -4
- package/src/config/Options/common/grid.ts +4 -4
- package/src/config/Options/common/legend.ts +13 -14
- package/src/config/Options/common/main.ts +23 -23
- package/src/config/Options/common/point.ts +17 -18
- package/src/config/Options/common/title.ts +2 -2
- package/src/config/Options/common/tooltip.ts +13 -11
- package/src/config/Options/data/axis.ts +2 -2
- package/src/config/Options/data/data.ts +45 -45
- package/src/config/Options/interaction/interaction.ts +1 -1
- package/src/config/Options/interaction/subchart.ts +2 -2
- package/src/config/Options/interaction/zoom.ts +9 -9
- package/src/config/Options/shape/arc.ts +10 -13
- package/src/config/Options/shape/area.ts +5 -7
- package/src/config/Options/shape/bar.ts +8 -10
- package/src/config/Options/shape/bubble.ts +1 -1
- package/src/config/Options/shape/candlestick.ts +2 -2
- package/src/config/Options/shape/donut.ts +4 -4
- package/src/config/Options/shape/gauge.ts +6 -6
- package/src/config/Options/shape/line.ts +3 -3
- package/src/config/Options/shape/pie.ts +5 -5
- package/src/config/Options/shape/polar.ts +3 -3
- package/src/config/Options/shape/radar.ts +2 -2
- package/src/config/Options/shape/scatter.ts +1 -1
- package/src/config/Options/shape/treemap.ts +1 -1
- package/src/config/Store/Element.ts +8 -5
- package/src/config/Store/State.ts +19 -13
- package/src/config/classes.ts +6 -4
- package/src/config/config.ts +1 -1
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/interaction.ts +3 -7
- package/src/config/resolver/shape.ts +11 -12
- package/src/core.ts +2 -3
- package/src/index.esm.ts +2 -6
- package/src/index.ts +2 -2
- package/src/module/Cache.ts +2 -3
- package/src/module/browser.ts +15 -10
- package/src/module/error.ts +9 -8
- package/src/module/generator.ts +3 -5
- package/src/module/util.ts +60 -37
- package/src/module/worker.ts +14 -11
- package/src/scss/billboard.scss +6 -0
- package/src/scss/theme/dark.scss +6 -0
- package/src/scss/theme/datalab.scss +6 -0
- package/src/scss/theme/graph.scss +6 -0
- package/src/scss/theme/insight.scss +6 -0
- package/src/scss/theme/modern.scss +6 -0
- package/types/axis.d.ts +7 -0
- package/types/options.d.ts +7 -0
- package/types/options.shape.d.ts +7 -0
|
@@ -3,22 +3,34 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
6
|
+
import {select as d3Select} from "d3-selection";
|
|
6
7
|
import {
|
|
7
|
-
timeParse as d3TimeParse,
|
|
8
8
|
timeFormat as d3TimeFormat,
|
|
9
|
-
|
|
10
|
-
utcFormat as d3UtcFormat
|
|
9
|
+
timeParse as d3TimeParse,
|
|
10
|
+
utcFormat as d3UtcFormat,
|
|
11
|
+
utcParse as d3UtcParse
|
|
11
12
|
} from "d3-time-format";
|
|
12
|
-
import {select as d3Select} from "d3-selection";
|
|
13
13
|
import type {d3Selection} from "../../types/types";
|
|
14
|
-
import {
|
|
15
|
-
import {$COMMON, $CIRCLE, $TEXT} from "../config/classes";
|
|
16
|
-
import Store from "../config/Store/Store";
|
|
14
|
+
import {$CIRCLE, $COMMON, $TEXT} from "../config/classes";
|
|
17
15
|
import Options from "../config/Options/Options";
|
|
16
|
+
import Store from "../config/Store/Store";
|
|
18
17
|
import {document, window} from "../module/browser";
|
|
19
18
|
import Cache from "../module/Cache";
|
|
19
|
+
import {checkModuleImport} from "../module/error";
|
|
20
20
|
import {generateResize} from "../module/generator";
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
callFn,
|
|
23
|
+
capitalize,
|
|
24
|
+
convertInputType,
|
|
25
|
+
extend,
|
|
26
|
+
getOption,
|
|
27
|
+
getRandom,
|
|
28
|
+
isFunction,
|
|
29
|
+
isObject,
|
|
30
|
+
isString,
|
|
31
|
+
notEmpty,
|
|
32
|
+
sortValue
|
|
33
|
+
} from "../module/util";
|
|
22
34
|
|
|
23
35
|
// data
|
|
24
36
|
import dataConvert from "./data/convert";
|
|
@@ -29,15 +41,14 @@ import dataLoad from "./data/load";
|
|
|
29
41
|
import interaction from "./interactions/interaction";
|
|
30
42
|
|
|
31
43
|
// internals
|
|
32
|
-
import classModule from "./internals/class";
|
|
33
44
|
import category from "./internals/category"; // used to retrieve radar Axis name
|
|
45
|
+
import classModule from "./internals/class";
|
|
34
46
|
import color from "./internals/color";
|
|
35
47
|
import domain from "./internals/domain";
|
|
36
48
|
import format from "./internals/format";
|
|
37
49
|
import legend from "./internals/legend";
|
|
38
50
|
import redraw from "./internals/redraw";
|
|
39
51
|
import scale from "./internals/scale";
|
|
40
|
-
import shape from "./shape/shape";
|
|
41
52
|
import size from "./internals/size";
|
|
42
53
|
import style from "./internals/style";
|
|
43
54
|
import text from "./internals/text";
|
|
@@ -45,6 +56,7 @@ import title from "./internals/title";
|
|
|
45
56
|
import tooltip from "./internals/tooltip";
|
|
46
57
|
import transform from "./internals/transform";
|
|
47
58
|
import typeInternals from "./internals/type";
|
|
59
|
+
import shape from "./shape/shape";
|
|
48
60
|
|
|
49
61
|
/**
|
|
50
62
|
* Internal chart class.
|
|
@@ -54,7 +66,7 @@ import typeInternals from "./internals/type";
|
|
|
54
66
|
* @private
|
|
55
67
|
*/
|
|
56
68
|
export default class ChartInternal {
|
|
57
|
-
public api;
|
|
69
|
+
public api; // API interface
|
|
58
70
|
public config; // config object
|
|
59
71
|
public cache; // cache instance
|
|
60
72
|
public $el; // elements
|
|
@@ -174,7 +186,7 @@ export default class ChartInternal {
|
|
|
174
186
|
}
|
|
175
187
|
|
|
176
188
|
init(): void {
|
|
177
|
-
const $$ = <any>
|
|
189
|
+
const $$ = <any>this;
|
|
178
190
|
const {config, state, $el} = $$;
|
|
179
191
|
const useCssRule = config.boost_useCssRule;
|
|
180
192
|
|
|
@@ -216,7 +228,8 @@ export default class ChartInternal {
|
|
|
216
228
|
|
|
217
229
|
// select bind element
|
|
218
230
|
$el.chart = isFunction(bindto.element.node) ?
|
|
219
|
-
config.bindto.element :
|
|
231
|
+
config.bindto.element :
|
|
232
|
+
d3Select(bindto.element || []);
|
|
220
233
|
|
|
221
234
|
if ($el.chart.empty()) {
|
|
222
235
|
$el.chart = d3Select(document.body.appendChild(document.createElement("div")));
|
|
@@ -237,9 +250,10 @@ export default class ChartInternal {
|
|
|
237
250
|
* @private
|
|
238
251
|
*/
|
|
239
252
|
initToRender(forced?: boolean): void {
|
|
240
|
-
const $$ = <any>
|
|
253
|
+
const $$ = <any>this;
|
|
241
254
|
const {config, state, $el: {chart}} = $$;
|
|
242
|
-
const isHidden = () =>
|
|
255
|
+
const isHidden = () =>
|
|
256
|
+
chart.style("display") === "none" || chart.style("visibility") === "hidden";
|
|
243
257
|
|
|
244
258
|
const isLazy = config.render.lazy || isHidden();
|
|
245
259
|
const MutationObserver = window.MutationObserver;
|
|
@@ -265,7 +279,7 @@ export default class ChartInternal {
|
|
|
265
279
|
}
|
|
266
280
|
|
|
267
281
|
initParams(): void {
|
|
268
|
-
const $$ = <any>
|
|
282
|
+
const $$ = <any>this;
|
|
269
283
|
const {config, format, state} = $$;
|
|
270
284
|
const isRotated = config.axis_rotated;
|
|
271
285
|
|
|
@@ -296,7 +310,8 @@ export default class ChartInternal {
|
|
|
296
310
|
|
|
297
311
|
format.defaultAxisTime = d => {
|
|
298
312
|
const {x, zoom} = $$.scale;
|
|
299
|
-
const isZoomed = isDragZoom ?
|
|
313
|
+
const isZoomed = isDragZoom ?
|
|
314
|
+
zoom :
|
|
300
315
|
zoom && x.orgDomain().toString() !== zoom.domain().toString();
|
|
301
316
|
|
|
302
317
|
const specifier: string = (d.getMilliseconds() && ".%L") ||
|
|
@@ -304,7 +319,7 @@ export default class ChartInternal {
|
|
|
304
319
|
(d.getMinutes() && "%I:%M") ||
|
|
305
320
|
(d.getHours() && "%I %p") ||
|
|
306
321
|
(d.getDate() !== 1 && "%b %d") ||
|
|
307
|
-
(isZoomed && d.getDate() === 1 && "%b
|
|
322
|
+
(isZoomed && d.getDate() === 1 && "%b'%y") ||
|
|
308
323
|
(d.getMonth() && "%-m/%-d") || "%Y";
|
|
309
324
|
|
|
310
325
|
return format.axisTime(specifier)(d);
|
|
@@ -330,11 +345,12 @@ export default class ChartInternal {
|
|
|
330
345
|
}
|
|
331
346
|
|
|
332
347
|
initWithData(data): void {
|
|
333
|
-
const $$ = <any>
|
|
348
|
+
const $$ = <any>this;
|
|
334
349
|
const {config, scale, state, $el, org} = $$;
|
|
335
350
|
const {hasAxis, hasTreemap} = state;
|
|
336
351
|
const hasInteraction = config.interaction_enabled;
|
|
337
352
|
const hasPolar = $$.hasType("polar");
|
|
353
|
+
const labelsBGColor = config.data_labels_backgroundColors;
|
|
338
354
|
|
|
339
355
|
// for arc type, set axes to not be shown
|
|
340
356
|
// $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
|
|
@@ -355,15 +371,13 @@ export default class ChartInternal {
|
|
|
355
371
|
// Set targets to hide if needed
|
|
356
372
|
if (config.data_hide) {
|
|
357
373
|
$$.addHiddenTargetIds(
|
|
358
|
-
config.data_hide === true ?
|
|
359
|
-
$$.mapToIds($$.data.targets) : config.data_hide
|
|
374
|
+
config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide
|
|
360
375
|
);
|
|
361
376
|
}
|
|
362
377
|
|
|
363
378
|
if (config.legend_hide) {
|
|
364
379
|
$$.addHiddenLegendIds(
|
|
365
|
-
config.legend_hide === true ?
|
|
366
|
-
$$.mapToIds($$.data.targets) : config.legend_hide
|
|
380
|
+
config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide
|
|
367
381
|
);
|
|
368
382
|
}
|
|
369
383
|
|
|
@@ -413,20 +427,22 @@ export default class ChartInternal {
|
|
|
413
427
|
config.svg_classname && $el.svg.attr("class", config.svg_classname);
|
|
414
428
|
|
|
415
429
|
// Define defs
|
|
416
|
-
const hasColorPatterns =
|
|
430
|
+
const hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
|
|
417
431
|
|
|
418
|
-
if (
|
|
419
|
-
|
|
432
|
+
if (
|
|
433
|
+
hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
|
|
434
|
+
labelsBGColor || $$.hasLegendDefsPoint?.()
|
|
435
|
+
) {
|
|
420
436
|
$el.defs = $el.svg.append("defs");
|
|
421
437
|
|
|
422
438
|
if (hasAxis) {
|
|
423
|
-
["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
|
|
439
|
+
["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(v => {
|
|
424
440
|
$$.appendClip($el.defs, state.clip[v]);
|
|
425
441
|
});
|
|
426
442
|
}
|
|
427
443
|
|
|
428
444
|
// Append data background color filter definition
|
|
429
|
-
$$.
|
|
445
|
+
$$.generateTextBGColorFilter(labelsBGColor);
|
|
430
446
|
|
|
431
447
|
// set color patterns
|
|
432
448
|
if (hasColorPatterns) {
|
|
@@ -530,7 +546,7 @@ export default class ChartInternal {
|
|
|
530
546
|
* @private
|
|
531
547
|
*/
|
|
532
548
|
initChartElements(): void {
|
|
533
|
-
const $$ = <any>
|
|
549
|
+
const $$ = <any>this;
|
|
534
550
|
const {hasAxis, hasRadar, hasTreemap} = $$.state;
|
|
535
551
|
const types: string[] = [];
|
|
536
552
|
|
|
@@ -579,16 +595,26 @@ export default class ChartInternal {
|
|
|
579
595
|
*/
|
|
580
596
|
setChartElements(): void {
|
|
581
597
|
const $$ = this;
|
|
582
|
-
const {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
598
|
+
const {
|
|
599
|
+
$el: {
|
|
600
|
+
chart,
|
|
601
|
+
svg,
|
|
602
|
+
defs,
|
|
603
|
+
main,
|
|
604
|
+
tooltip,
|
|
605
|
+
legend,
|
|
606
|
+
title,
|
|
607
|
+
grid,
|
|
608
|
+
needle,
|
|
609
|
+
arcs: arc,
|
|
610
|
+
circle: circles,
|
|
611
|
+
bar: bars,
|
|
612
|
+
candlestick,
|
|
613
|
+
line: lines,
|
|
614
|
+
area: areas,
|
|
615
|
+
text: texts
|
|
616
|
+
}
|
|
617
|
+
} = $$;
|
|
592
618
|
|
|
593
619
|
// public
|
|
594
620
|
$$.api.$ = {
|
|
@@ -643,11 +669,12 @@ export default class ChartInternal {
|
|
|
643
669
|
* @private
|
|
644
670
|
*/
|
|
645
671
|
updateTargets(targets): void {
|
|
646
|
-
const $$ = <any>
|
|
672
|
+
const $$ = <any>this;
|
|
647
673
|
const {hasAxis, hasRadar, hasTreemap} = $$.state;
|
|
648
|
-
const helper = type =>
|
|
649
|
-
|
|
650
|
-
|
|
674
|
+
const helper = type =>
|
|
675
|
+
$$[`updateTargetsFor${type}`](
|
|
676
|
+
targets.filter($$[`is${type}Type`].bind($$))
|
|
677
|
+
);
|
|
651
678
|
|
|
652
679
|
// Text
|
|
653
680
|
$$.updateTargetsForText(targets);
|
|
@@ -665,7 +692,7 @@ export default class ChartInternal {
|
|
|
665
692
|
$$.updateTargetsForSubchart &&
|
|
666
693
|
$$.updateTargetsForSubchart(targets);
|
|
667
694
|
|
|
668
|
-
|
|
695
|
+
// Arc, Polar, Radar
|
|
669
696
|
} else if ($$.hasArcType(targets)) {
|
|
670
697
|
let type = "Arc";
|
|
671
698
|
|
|
@@ -676,7 +703,7 @@ export default class ChartInternal {
|
|
|
676
703
|
}
|
|
677
704
|
|
|
678
705
|
helper(type);
|
|
679
|
-
|
|
706
|
+
// Arc, Polar, Radar
|
|
680
707
|
} else if (hasTreemap) {
|
|
681
708
|
helper("Treemap");
|
|
682
709
|
}
|
|
@@ -698,7 +725,7 @@ export default class ChartInternal {
|
|
|
698
725
|
* @private
|
|
699
726
|
*/
|
|
700
727
|
filterTargetsToShowAtInit(hasPointType: boolean = false): void {
|
|
701
|
-
const $$ = <any>
|
|
728
|
+
const $$ = <any>this;
|
|
702
729
|
const {$el: {svg}, $T} = $$;
|
|
703
730
|
let selector = `.${$COMMON.target}`;
|
|
704
731
|
|
|
@@ -707,8 +734,7 @@ export default class ChartInternal {
|
|
|
707
734
|
}
|
|
708
735
|
|
|
709
736
|
$T(svg.selectAll(selector)
|
|
710
|
-
.filter(d => $$.isTargetToShow(d.id))
|
|
711
|
-
).style("opacity", null);
|
|
737
|
+
.filter(d => $$.isTargetToShow(d.id))).style("opacity", null);
|
|
712
738
|
}
|
|
713
739
|
|
|
714
740
|
getWithOption(options) {
|
|
@@ -742,17 +768,19 @@ export default class ChartInternal {
|
|
|
742
768
|
}
|
|
743
769
|
|
|
744
770
|
initialOpacity(d): null | "0" {
|
|
745
|
-
const $$ = <any>
|
|
771
|
+
const $$ = <any>this;
|
|
746
772
|
const {withoutFadeIn} = $$.state;
|
|
747
773
|
|
|
748
774
|
const r = $$.getBaseValue(d) !== null &&
|
|
749
|
-
|
|
775
|
+
withoutFadeIn[d.id] ?
|
|
776
|
+
null :
|
|
777
|
+
"0";
|
|
750
778
|
|
|
751
779
|
return r;
|
|
752
780
|
}
|
|
753
781
|
|
|
754
782
|
bindResize(): void {
|
|
755
|
-
const $$ = <any>
|
|
783
|
+
const $$ = <any>this;
|
|
756
784
|
const {config, state} = $$;
|
|
757
785
|
const resizeFunction = generateResize(config.resize_timer);
|
|
758
786
|
const list: Function[] = [];
|
|
@@ -3,62 +3,55 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
6
|
-
type TDataRow = {
|
|
7
|
-
value: number | null;
|
|
8
|
-
id: string;
|
|
9
|
-
index: number;
|
|
10
|
-
name?: string;
|
|
11
|
-
};
|
|
6
|
+
type TDataRow = {value: number | null, id: string, index: number, name?: string};
|
|
12
7
|
|
|
13
8
|
export type TDomain = Date | number;
|
|
14
9
|
export type TDomainRange = [TDomain, TDomain];
|
|
15
10
|
|
|
16
11
|
export interface ITreemapData {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
name: string;
|
|
13
|
+
id?: string; // for compatibility
|
|
14
|
+
value?: number;
|
|
15
|
+
ratio?: number;
|
|
16
|
+
children?: ITreemapData[];
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
export interface IDataRow extends TDataRow {
|
|
25
|
-
|
|
20
|
+
x: TDomain & string;
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
export interface IDataPoint extends IDataRow {
|
|
29
|
-
|
|
24
|
+
r: number;
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
export interface IArcDataRow extends TDataRow {
|
|
33
|
-
|
|
28
|
+
ratio: number;
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
export interface IData {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
id: string;
|
|
33
|
+
id_org: string;
|
|
34
|
+
values: IDataRow[];
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
export interface IArcData {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
data: IData;
|
|
39
|
+
index: number;
|
|
40
|
+
padAngle: number;
|
|
41
|
+
startAngle: number;
|
|
42
|
+
endAngle: number;
|
|
43
|
+
value: number | null;
|
|
49
44
|
}
|
|
50
45
|
|
|
51
46
|
export interface IGridData {
|
|
52
|
-
|
|
47
|
+
axis?: string;
|
|
53
48
|
text: string;
|
|
54
49
|
value: number;
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
export interface IDataIndice {
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
[key: string]: number;
|
|
54
|
+
__max__: number;
|
|
60
55
|
}
|
|
61
56
|
|
|
62
|
-
export type TIndices = {} | {
|
|
63
|
-
[key:string]: IDataIndice
|
|
64
|
-
};
|
|
57
|
+
export type TIndices = {} | {[key: string]: IDataIndice};
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
/* eslint-disable */
|
|
7
7
|
import {
|
|
8
8
|
csvParse as d3CsvParse,
|
|
9
|
-
tsvParse as d3TsvParse,
|
|
10
9
|
csvParseRows as d3CsvParseRows,
|
|
11
|
-
|
|
10
|
+
tsvParse as d3TsvParse,
|
|
11
|
+
tsvParseRows as d3TsvParseRows
|
|
12
12
|
} from "d3-dsv";
|
|
13
13
|
|
|
14
|
-
export {columns, json, rows,
|
|
14
|
+
export {columns, csv, json, rows, tsv, url};
|
|
15
15
|
|
|
16
16
|
/***** Functions to be executed on Web Worker *****
|
|
17
17
|
* NOTE: Don't allowed to use
|
|
@@ -84,66 +84,65 @@ function rows(rows) {
|
|
|
84
84
|
* @private
|
|
85
85
|
*/
|
|
86
86
|
function json(json, keysParam) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const newRows: string[][] = [];
|
|
88
|
+
let targetKeys: string[];
|
|
89
|
+
let data;
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
if (Array.isArray(json)) {
|
|
92
92
|
const findValueInJson = function(object, path) {
|
|
93
93
|
if (object[path] !== undefined) {
|
|
94
94
|
return object[path];
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
const convertedPath = path.replace(/\[(\w+)\]/g, ".$1"); // convert indexes to properties (replace [] with .)
|
|
98
98
|
const pathArray = convertedPath.replace(/^\./, "").split("."); // strip a leading dot
|
|
99
99
|
let target = object;
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
pathArray.some(function(k) {
|
|
102
102
|
return !(
|
|
103
|
-
target = target && k in target ?
|
|
104
|
-
target[k] : undefined
|
|
103
|
+
target = target && k in target ? target[k] : undefined
|
|
105
104
|
);
|
|
106
105
|
});
|
|
107
|
-
|
|
106
|
+
|
|
108
107
|
return target;
|
|
109
108
|
};
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
if (keysParam.x) {
|
|
111
|
+
targetKeys = keysParam.value.concat(keysParam.x);
|
|
112
|
+
} else {
|
|
113
|
+
targetKeys = keysParam.value;
|
|
114
|
+
}
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
newRows.push(targetKeys);
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
json.forEach(function(o) {
|
|
119
|
+
const newRow = targetKeys.map(function(key) {
|
|
120
|
+
// convert undefined to null because undefined data will be removed in convertDataToTargets()
|
|
121
|
+
let v = findValueInJson(o, key);
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
if (typeof v === "undefined") {
|
|
124
|
+
v = null;
|
|
125
|
+
}
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
return v;
|
|
128
|
+
});
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
newRows.push(newRow);
|
|
131
|
+
});
|
|
133
132
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
data = rows(newRows);
|
|
134
|
+
} else {
|
|
135
|
+
Object.keys(json).forEach(function(key) {
|
|
136
|
+
const tmp = json[key].concat();
|
|
138
137
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
tmp.unshift?.(key);
|
|
139
|
+
newRows.push(tmp);
|
|
140
|
+
});
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
data = columns(newRows);
|
|
143
|
+
}
|
|
145
144
|
|
|
146
|
-
|
|
145
|
+
return data;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
/***** Functions can't be executed on Web Worker *****/
|
|
@@ -157,34 +156,33 @@ function json(json, keysParam) {
|
|
|
157
156
|
* @private
|
|
158
157
|
*/
|
|
159
158
|
function url(url: string, mimeType = "csv", headers: object, keys: object, done: Function): void {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
response && done.call(this,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
req.send();
|
|
159
|
+
const req = new XMLHttpRequest();
|
|
160
|
+
const converter = {csv, tsv, json};
|
|
161
|
+
|
|
162
|
+
req.open("GET", url);
|
|
163
|
+
|
|
164
|
+
if (headers) {
|
|
165
|
+
Object.keys(headers).forEach(function(key) {
|
|
166
|
+
req.setRequestHeader(key, headers[key]);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
req.onreadystatechange = function() {
|
|
171
|
+
if (req.readyState === 4) {
|
|
172
|
+
if (req.status === 200) {
|
|
173
|
+
const response = req.responseText;
|
|
174
|
+
|
|
175
|
+
response && done.call(this, converter[mimeType](
|
|
176
|
+
mimeType === "json" ? JSON.parse(response) : response,
|
|
177
|
+
keys
|
|
178
|
+
));
|
|
179
|
+
} else {
|
|
180
|
+
throw new Error(`${url}: Something went wrong loading!`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
req.send();
|
|
188
186
|
}
|
|
189
187
|
|
|
190
188
|
/**
|
|
@@ -194,7 +192,7 @@ function url(url: string, mimeType = "csv", headers: object, keys: object, done:
|
|
|
194
192
|
* @returns {object}
|
|
195
193
|
* @private
|
|
196
194
|
*/
|
|
197
|
-
|
|
195
|
+
function convertCsvTsvToData(parser, xsv) {
|
|
198
196
|
const rows = parser.rows(xsv);
|
|
199
197
|
let d;
|
|
200
198
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import {isArray, isDefined, isObject, isUndefined, isValue, notEmpty} from "../../module/util";
|
|
6
6
|
import {runWorker} from "../../module/worker";
|
|
7
|
-
import {columns, json, rows, url} from "./convert.helper";
|
|
8
7
|
import type {IData} from "../data/IData";
|
|
8
|
+
import {columns, json, rows, url} from "./convert.helper";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Get data key for JSON
|
|
@@ -55,10 +55,8 @@ export default {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (data.url && callback) {
|
|
58
|
-
url(data.url, data.mimeType, data.headers,
|
|
59
|
-
|
|
60
|
-
callback
|
|
61
|
-
);
|
|
58
|
+
url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config),
|
|
59
|
+
callback);
|
|
62
60
|
} else if (data.json) {
|
|
63
61
|
runWorker(useWorker, json, callback, [columns, rows])(
|
|
64
62
|
data.json,
|
|
@@ -73,7 +71,7 @@ export default {
|
|
|
73
71
|
}
|
|
74
72
|
},
|
|
75
73
|
|
|
76
|
-
convertDataToTargets(data: {[key:string]: number|null}[], appendXs: boolean): IData[] {
|
|
74
|
+
convertDataToTargets(data: {[key: string]: number | null}[], appendXs: boolean): IData[] {
|
|
77
75
|
const $$ = this;
|
|
78
76
|
const {axis, config, state} = $$;
|
|
79
77
|
const chartType = config.data_type;
|
|
@@ -139,8 +137,7 @@ export default {
|
|
|
139
137
|
// when .load() with 'append' option is used for indexed axis
|
|
140
138
|
// @ts-ignore
|
|
141
139
|
const isDataAppend = data.__append__;
|
|
142
|
-
const xIndex = xKey === null && isDataAppend ?
|
|
143
|
-
$$.api.data.values(id).length : 0;
|
|
140
|
+
const xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
|
|
144
141
|
|
|
145
142
|
return {
|
|
146
143
|
id: convertedId,
|
|
@@ -151,7 +148,8 @@ export default {
|
|
|
151
148
|
let x;
|
|
152
149
|
|
|
153
150
|
value = value !== null && !isNaN(value) && !isObject(value) ?
|
|
154
|
-
+value :
|
|
151
|
+
+value :
|
|
152
|
+
(isArray(value) || isObject(value) ? value : null);
|
|
155
153
|
|
|
156
154
|
// use x as categories if custom x and categorized
|
|
157
155
|
if ((isCategory || state.hasRadar) && index === 0 && !isUndefined(rawX)) {
|
|
@@ -210,7 +208,9 @@ export default {
|
|
|
210
208
|
// set target types
|
|
211
209
|
if (chartType && $$.isValidChartType(chartType)) {
|
|
212
210
|
const targetIds = $$.mapToIds(targets)
|
|
213
|
-
.filter(id =>
|
|
211
|
+
.filter(id =>
|
|
212
|
+
!(id in config.data_types) || !$$.isValidChartType(config.data_types[id])
|
|
213
|
+
);
|
|
214
214
|
|
|
215
215
|
$$.setTargetType(targetIds, chartType);
|
|
216
216
|
}
|