billboard.js 3.11.3 → 3.12.0-next.2
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 +1 -5
- package/dist/billboard.css +13 -1
- package/dist/billboard.js +19672 -24210
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +26 -3
- package/dist/billboard.pkgd.js +24515 -30430
- 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 +429 -1134
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +666 -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 +1387 -1854
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2760 -3959
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3504 -5057
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2906 -4072
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3076 -4506
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
- package/dist/theme/dark.css +12 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +12 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +12 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +12 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +12 -1
- package/dist/theme/modern.min.css +3 -4
- package/dist-esm/billboard.js +9297 -8527
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +20 -27
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +155 -149
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +302 -289
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +236 -236
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +41 -43
- package/package.json +29 -49
- 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 +8 -9
- 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 +87 -55
- package/src/ChartInternal/data/IData.ts +31 -31
- package/src/ChartInternal/data/convert.helper.ts +66 -68
- package/src/ChartInternal/data/convert.ts +11 -11
- package/src/ChartInternal/data/data.ts +51 -27
- package/src/ChartInternal/data/load.ts +7 -6
- package/src/ChartInternal/interactions/drag.ts +2 -1
- package/src/ChartInternal/interactions/eventrect.ts +84 -32
- package/src/ChartInternal/interactions/flow.ts +14 -4
- package/src/ChartInternal/interactions/interaction.ts +51 -22
- 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 +6 -6
- package/src/ChartInternal/internals/clip.ts +8 -4
- 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 +131 -47
- package/src/ChartInternal/internals/legend.ts +93 -61
- package/src/ChartInternal/internals/redraw.ts +6 -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 +98 -67
- package/src/ChartInternal/internals/style.ts +21 -19
- package/src/ChartInternal/internals/text.ts +79 -43
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +78 -32
- package/src/ChartInternal/internals/transform.ts +4 -4
- package/src/ChartInternal/internals/type.ts +17 -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/funnel.ts +317 -0
- 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 +54 -34
- 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 +31 -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 +34 -14
- 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 +12 -13
- 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 +48 -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/funnel.ts +38 -0
- 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 +20 -13
- package/src/config/classes.ts +14 -4
- package/src/config/config.ts +1 -1
- package/src/config/const.ts +2 -0
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/interaction.ts +3 -7
- package/src/config/resolver/shape.ts +17 -12
- package/src/core.ts +2 -3
- package/src/index.esm.ts +3 -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 +62 -39
- package/src/module/worker.ts +14 -11
- package/src/scss/billboard.scss +18 -0
- package/src/scss/theme/dark.scss +17 -0
- package/src/scss/theme/datalab.scss +17 -0
- package/src/scss/theme/graph.scss +17 -0
- package/src/scss/theme/insight.scss +17 -0
- package/src/scss/theme/modern.scss +17 -0
- package/types/axis.d.ts +17 -0
- package/types/bb.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/options.d.ts +9 -0
- package/types/options.shape.d.ts +26 -1
- package/types/types.d.ts +1 -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,15 +186,16 @@ 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
|
|
|
181
193
|
checkModuleImport($$);
|
|
182
194
|
|
|
183
195
|
state.hasRadar = !state.hasAxis && $$.hasType("radar");
|
|
196
|
+
state.hasFunnel = !state.hasAxis && $$.hasType("funnel");
|
|
184
197
|
state.hasTreemap = !state.hasAxis && $$.hasType("treemap");
|
|
185
|
-
state.hasAxis = !$$.hasArcType() && !state.hasTreemap;
|
|
198
|
+
state.hasAxis = !$$.hasArcType() && !state.hasFunnel && !state.hasTreemap;
|
|
186
199
|
|
|
187
200
|
// datetime to be used for uniqueness
|
|
188
201
|
state.datetimeId = `bb-${+new Date() * (getRandom() as number)}`;
|
|
@@ -216,7 +229,8 @@ export default class ChartInternal {
|
|
|
216
229
|
|
|
217
230
|
// select bind element
|
|
218
231
|
$el.chart = isFunction(bindto.element.node) ?
|
|
219
|
-
config.bindto.element :
|
|
232
|
+
config.bindto.element :
|
|
233
|
+
d3Select(bindto.element || []);
|
|
220
234
|
|
|
221
235
|
if ($el.chart.empty()) {
|
|
222
236
|
$el.chart = d3Select(document.body.appendChild(document.createElement("div")));
|
|
@@ -237,9 +251,10 @@ export default class ChartInternal {
|
|
|
237
251
|
* @private
|
|
238
252
|
*/
|
|
239
253
|
initToRender(forced?: boolean): void {
|
|
240
|
-
const $$ = <any>
|
|
254
|
+
const $$ = <any>this;
|
|
241
255
|
const {config, state, $el: {chart}} = $$;
|
|
242
|
-
const isHidden = () =>
|
|
256
|
+
const isHidden = () =>
|
|
257
|
+
chart.style("display") === "none" || chart.style("visibility") === "hidden";
|
|
243
258
|
|
|
244
259
|
const isLazy = config.render.lazy || isHidden();
|
|
245
260
|
const MutationObserver = window.MutationObserver;
|
|
@@ -265,7 +280,7 @@ export default class ChartInternal {
|
|
|
265
280
|
}
|
|
266
281
|
|
|
267
282
|
initParams(): void {
|
|
268
|
-
const $$ = <any>
|
|
283
|
+
const $$ = <any>this;
|
|
269
284
|
const {config, format, state} = $$;
|
|
270
285
|
const isRotated = config.axis_rotated;
|
|
271
286
|
|
|
@@ -296,7 +311,8 @@ export default class ChartInternal {
|
|
|
296
311
|
|
|
297
312
|
format.defaultAxisTime = d => {
|
|
298
313
|
const {x, zoom} = $$.scale;
|
|
299
|
-
const isZoomed = isDragZoom ?
|
|
314
|
+
const isZoomed = isDragZoom ?
|
|
315
|
+
zoom :
|
|
300
316
|
zoom && x.orgDomain().toString() !== zoom.domain().toString();
|
|
301
317
|
|
|
302
318
|
const specifier: string = (d.getMilliseconds() && ".%L") ||
|
|
@@ -304,7 +320,7 @@ export default class ChartInternal {
|
|
|
304
320
|
(d.getMinutes() && "%I:%M") ||
|
|
305
321
|
(d.getHours() && "%I %p") ||
|
|
306
322
|
(d.getDate() !== 1 && "%b %d") ||
|
|
307
|
-
(isZoomed && d.getDate() === 1 && "%b
|
|
323
|
+
(isZoomed && d.getDate() === 1 && "%b'%y") ||
|
|
308
324
|
(d.getMonth() && "%-m/%-d") || "%Y";
|
|
309
325
|
|
|
310
326
|
return format.axisTime(specifier)(d);
|
|
@@ -330,11 +346,12 @@ export default class ChartInternal {
|
|
|
330
346
|
}
|
|
331
347
|
|
|
332
348
|
initWithData(data): void {
|
|
333
|
-
const $$ = <any>
|
|
349
|
+
const $$ = <any>this;
|
|
334
350
|
const {config, scale, state, $el, org} = $$;
|
|
335
|
-
const {hasAxis, hasTreemap} = state;
|
|
351
|
+
const {hasAxis, hasFunnel, hasTreemap} = state;
|
|
336
352
|
const hasInteraction = config.interaction_enabled;
|
|
337
353
|
const hasPolar = $$.hasType("polar");
|
|
354
|
+
const labelsBGColor = config.data_labels_backgroundColors;
|
|
338
355
|
|
|
339
356
|
// for arc type, set axes to not be shown
|
|
340
357
|
// $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
|
|
@@ -355,15 +372,13 @@ export default class ChartInternal {
|
|
|
355
372
|
// Set targets to hide if needed
|
|
356
373
|
if (config.data_hide) {
|
|
357
374
|
$$.addHiddenTargetIds(
|
|
358
|
-
config.data_hide === true ?
|
|
359
|
-
$$.mapToIds($$.data.targets) : config.data_hide
|
|
375
|
+
config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide
|
|
360
376
|
);
|
|
361
377
|
}
|
|
362
378
|
|
|
363
379
|
if (config.legend_hide) {
|
|
364
380
|
$$.addHiddenLegendIds(
|
|
365
|
-
config.legend_hide === true ?
|
|
366
|
-
$$.mapToIds($$.data.targets) : config.legend_hide
|
|
381
|
+
config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide
|
|
367
382
|
);
|
|
368
383
|
}
|
|
369
384
|
|
|
@@ -413,20 +428,22 @@ export default class ChartInternal {
|
|
|
413
428
|
config.svg_classname && $el.svg.attr("class", config.svg_classname);
|
|
414
429
|
|
|
415
430
|
// Define defs
|
|
416
|
-
const hasColorPatterns =
|
|
431
|
+
const hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
|
|
417
432
|
|
|
418
|
-
if (
|
|
419
|
-
|
|
433
|
+
if (
|
|
434
|
+
hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
|
|
435
|
+
labelsBGColor || $$.hasLegendDefsPoint?.()
|
|
436
|
+
) {
|
|
420
437
|
$el.defs = $el.svg.append("defs");
|
|
421
438
|
|
|
422
439
|
if (hasAxis) {
|
|
423
|
-
["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
|
|
440
|
+
["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(v => {
|
|
424
441
|
$$.appendClip($el.defs, state.clip[v]);
|
|
425
442
|
});
|
|
426
443
|
}
|
|
427
444
|
|
|
428
445
|
// Append data background color filter definition
|
|
429
|
-
$$.
|
|
446
|
+
$$.generateTextBGColorFilter(labelsBGColor);
|
|
430
447
|
|
|
431
448
|
// set color patterns
|
|
432
449
|
if (hasColorPatterns) {
|
|
@@ -442,7 +459,7 @@ export default class ChartInternal {
|
|
|
442
459
|
// Define regions
|
|
443
460
|
const main = $el.svg.append("g")
|
|
444
461
|
.classed($COMMON.main, true)
|
|
445
|
-
.attr("transform", hasTreemap ? null : $$.getTranslate("main"));
|
|
462
|
+
.attr("transform", hasFunnel || hasTreemap ? null : $$.getTranslate("main"));
|
|
446
463
|
|
|
447
464
|
$el.main = main;
|
|
448
465
|
|
|
@@ -530,7 +547,7 @@ export default class ChartInternal {
|
|
|
530
547
|
* @private
|
|
531
548
|
*/
|
|
532
549
|
initChartElements(): void {
|
|
533
|
-
const $$ = <any>
|
|
550
|
+
const $$ = <any>this;
|
|
534
551
|
const {hasAxis, hasRadar, hasTreemap} = $$.state;
|
|
535
552
|
const types: string[] = [];
|
|
536
553
|
|
|
@@ -550,6 +567,8 @@ export default class ChartInternal {
|
|
|
550
567
|
});
|
|
551
568
|
} else if (hasTreemap) {
|
|
552
569
|
types.push("Treemap");
|
|
570
|
+
} else if ($$.hasType("funnel")) {
|
|
571
|
+
types.push("Funnel");
|
|
553
572
|
} else {
|
|
554
573
|
const hasPolar = $$.hasType("polar");
|
|
555
574
|
|
|
@@ -579,16 +598,26 @@ export default class ChartInternal {
|
|
|
579
598
|
*/
|
|
580
599
|
setChartElements(): void {
|
|
581
600
|
const $$ = this;
|
|
582
|
-
const {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
601
|
+
const {
|
|
602
|
+
$el: {
|
|
603
|
+
chart,
|
|
604
|
+
svg,
|
|
605
|
+
defs,
|
|
606
|
+
main,
|
|
607
|
+
tooltip,
|
|
608
|
+
legend,
|
|
609
|
+
title,
|
|
610
|
+
grid,
|
|
611
|
+
needle,
|
|
612
|
+
arcs: arc,
|
|
613
|
+
circle: circles,
|
|
614
|
+
bar: bars,
|
|
615
|
+
candlestick,
|
|
616
|
+
line: lines,
|
|
617
|
+
area: areas,
|
|
618
|
+
text: texts
|
|
619
|
+
}
|
|
620
|
+
} = $$;
|
|
592
621
|
|
|
593
622
|
// public
|
|
594
623
|
$$.api.$ = {
|
|
@@ -643,11 +672,12 @@ export default class ChartInternal {
|
|
|
643
672
|
* @private
|
|
644
673
|
*/
|
|
645
674
|
updateTargets(targets): void {
|
|
646
|
-
const $$ = <any>
|
|
647
|
-
const {hasAxis, hasRadar, hasTreemap} = $$.state;
|
|
648
|
-
const helper = type =>
|
|
649
|
-
|
|
650
|
-
|
|
675
|
+
const $$ = <any>this;
|
|
676
|
+
const {hasAxis, hasFunnel, hasRadar, hasTreemap} = $$.state;
|
|
677
|
+
const helper = type =>
|
|
678
|
+
$$[`updateTargetsFor${type}`](
|
|
679
|
+
targets.filter($$[`is${type}Type`].bind($$))
|
|
680
|
+
);
|
|
651
681
|
|
|
652
682
|
// Text
|
|
653
683
|
$$.updateTargetsForText(targets);
|
|
@@ -665,7 +695,7 @@ export default class ChartInternal {
|
|
|
665
695
|
$$.updateTargetsForSubchart &&
|
|
666
696
|
$$.updateTargetsForSubchart(targets);
|
|
667
697
|
|
|
668
|
-
|
|
698
|
+
// Arc, Polar, Radar
|
|
669
699
|
} else if ($$.hasArcType(targets)) {
|
|
670
700
|
let type = "Arc";
|
|
671
701
|
|
|
@@ -676,7 +706,8 @@ export default class ChartInternal {
|
|
|
676
706
|
}
|
|
677
707
|
|
|
678
708
|
helper(type);
|
|
679
|
-
|
|
709
|
+
} else if (hasFunnel) {
|
|
710
|
+
helper("Funnel");
|
|
680
711
|
} else if (hasTreemap) {
|
|
681
712
|
helper("Treemap");
|
|
682
713
|
}
|
|
@@ -698,7 +729,7 @@ export default class ChartInternal {
|
|
|
698
729
|
* @private
|
|
699
730
|
*/
|
|
700
731
|
filterTargetsToShowAtInit(hasPointType: boolean = false): void {
|
|
701
|
-
const $$ = <any>
|
|
732
|
+
const $$ = <any>this;
|
|
702
733
|
const {$el: {svg}, $T} = $$;
|
|
703
734
|
let selector = `.${$COMMON.target}`;
|
|
704
735
|
|
|
@@ -707,8 +738,7 @@ export default class ChartInternal {
|
|
|
707
738
|
}
|
|
708
739
|
|
|
709
740
|
$T(svg.selectAll(selector)
|
|
710
|
-
.filter(d => $$.isTargetToShow(d.id))
|
|
711
|
-
).style("opacity", null);
|
|
741
|
+
.filter(d => $$.isTargetToShow(d.id))).style("opacity", null);
|
|
712
742
|
}
|
|
713
743
|
|
|
714
744
|
getWithOption(options) {
|
|
@@ -742,17 +772,19 @@ export default class ChartInternal {
|
|
|
742
772
|
}
|
|
743
773
|
|
|
744
774
|
initialOpacity(d): null | "0" {
|
|
745
|
-
const $$ = <any>
|
|
775
|
+
const $$ = <any>this;
|
|
746
776
|
const {withoutFadeIn} = $$.state;
|
|
747
777
|
|
|
748
778
|
const r = $$.getBaseValue(d) !== null &&
|
|
749
|
-
|
|
779
|
+
withoutFadeIn[d.id] ?
|
|
780
|
+
null :
|
|
781
|
+
"0";
|
|
750
782
|
|
|
751
783
|
return r;
|
|
752
784
|
}
|
|
753
785
|
|
|
754
786
|
bindResize(): void {
|
|
755
|
-
const $$ = <any>
|
|
787
|
+
const $$ = <any>this;
|
|
756
788
|
const {config, state} = $$;
|
|
757
789
|
const resizeFunction = generateResize(config.resize_timer);
|
|
758
790
|
const list: Function[] = [];
|
|
@@ -3,62 +3,62 @@
|
|
|
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
|
|
|
11
|
+
export interface IFunnelData {
|
|
12
|
+
id: string; // for compatibility
|
|
13
|
+
value: number;
|
|
14
|
+
ratio?: number;
|
|
15
|
+
coords?: number[][];
|
|
16
|
+
}
|
|
17
|
+
|
|
16
18
|
export interface ITreemapData {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
name: string;
|
|
20
|
+
id?: string; // for compatibility
|
|
21
|
+
value?: number;
|
|
22
|
+
ratio?: number;
|
|
23
|
+
children?: ITreemapData[];
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export interface IDataRow extends TDataRow {
|
|
25
|
-
|
|
27
|
+
x: TDomain & string;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export interface IDataPoint extends IDataRow {
|
|
29
|
-
|
|
31
|
+
r: number;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export interface IArcDataRow extends TDataRow {
|
|
33
|
-
|
|
35
|
+
ratio: number;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export interface IData {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
id: string;
|
|
40
|
+
id_org: string;
|
|
41
|
+
values: IDataRow[];
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
export interface IArcData {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
data: IData;
|
|
46
|
+
index: number;
|
|
47
|
+
padAngle: number;
|
|
48
|
+
startAngle: number;
|
|
49
|
+
endAngle: number;
|
|
50
|
+
value: number | null;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export interface IGridData {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
axis?: string;
|
|
55
|
+
text: string;
|
|
56
|
+
value: number;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export interface IDataIndice {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
[key: string]: number;
|
|
61
|
+
__max__: number;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
export type TIndices = {} | {
|
|
63
|
-
[key:string]: IDataIndice
|
|
64
|
-
};
|
|
64
|
+
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
|
}
|