billboard.js 3.11.0 → 3.11.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/dist/billboard.css +1 -1
- package/dist/billboard.js +230 -134
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +226 -128
- package/dist/billboard.pkgd.min.js +4 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +189 -122
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +16 -14
- package/src/ChartInternal/Axis/AxisRenderer.ts +2 -1
- package/src/ChartInternal/ChartInternal.ts +2 -2
- package/src/ChartInternal/data/data.ts +1 -1
- package/src/ChartInternal/data/load.ts +7 -1
- package/src/ChartInternal/interactions/zoom.ts +9 -3
- package/src/ChartInternal/internals/redraw.ts +2 -1
- package/src/ChartInternal/internals/title.ts +2 -2
- package/src/ChartInternal/internals/tooltip.ts +1 -1
- package/src/ChartInternal/shape/point.common.ts +134 -0
- package/src/ChartInternal/shape/point.ts +3 -95
- package/src/ChartInternal/shape/shape.ts +18 -6
- package/src/config/Store/State.ts +1 -1
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/shape.ts +22 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.2",
|
|
4
4
|
"description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
|
|
5
5
|
"homepage": "https://naver.github.io/billboard.js/",
|
|
6
6
|
"main": "dist/billboard.js",
|
|
@@ -84,6 +84,8 @@
|
|
|
84
84
|
"license": "MIT",
|
|
85
85
|
"readmeFilename": "README.md",
|
|
86
86
|
"dependencies": {
|
|
87
|
+
"@types/d3-selection": "^3.0.0",
|
|
88
|
+
"@types/d3-transition": "^3.0.0",
|
|
87
89
|
"d3-axis": "^3.0.0",
|
|
88
90
|
"d3-brush": "^3.0.0",
|
|
89
91
|
"d3-drag": "^3.0.0",
|
|
@@ -107,8 +109,8 @@
|
|
|
107
109
|
"@babel/preset-env": "^7.23.9",
|
|
108
110
|
"@babel/preset-typescript": "^7.23.3",
|
|
109
111
|
"@babel/runtime": "^7.23.9",
|
|
110
|
-
"@commitlint/cli": "18.6.
|
|
111
|
-
"@commitlint/config-conventional": "^18.6.
|
|
112
|
+
"@commitlint/cli": "18.6.1",
|
|
113
|
+
"@commitlint/config-conventional": "^18.6.2",
|
|
112
114
|
"@rollup/plugin-babel": "^6.0.4",
|
|
113
115
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
114
116
|
"@rollup/plugin-replace": "^5.0.5",
|
|
@@ -123,8 +125,8 @@
|
|
|
123
125
|
"@types/d3": "^7.4.3",
|
|
124
126
|
"@types/mocha": "^10.0.6",
|
|
125
127
|
"@types/sinon": "^17.0.3",
|
|
126
|
-
"@typescript-eslint/eslint-plugin": "^7.0.
|
|
127
|
-
"@typescript-eslint/parser": "^7.0.
|
|
128
|
+
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
|
129
|
+
"@typescript-eslint/parser": "^7.0.2",
|
|
128
130
|
"babel-helper-modules": "^6.0.0",
|
|
129
131
|
"babel-loader": "^9.1.3",
|
|
130
132
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
@@ -140,7 +142,7 @@
|
|
|
140
142
|
"chai": "^4.3.10",
|
|
141
143
|
"clean-webpack-plugin": "^4.0.0",
|
|
142
144
|
"cloc": "^2.11.0",
|
|
143
|
-
"core-js": "^3.
|
|
145
|
+
"core-js": "^3.36.0",
|
|
144
146
|
"coveralls": "^3.1.1",
|
|
145
147
|
"cross-env": "^7.0.3",
|
|
146
148
|
"css-loader": "^6.10.0",
|
|
@@ -153,13 +155,13 @@
|
|
|
153
155
|
"eslint": "^8.56.0",
|
|
154
156
|
"eslint-config-naver": "^2.1.0",
|
|
155
157
|
"eslint-plugin-import": "^2.29.1",
|
|
156
|
-
"eslint-plugin-jsdoc": "^48.0
|
|
158
|
+
"eslint-plugin-jsdoc": "^48.1.0",
|
|
157
159
|
"eslint-webpack-plugin": "^4.0.1",
|
|
158
160
|
"exports-loader": "^5.0.0",
|
|
159
161
|
"hammer-simulator": "0.0.1",
|
|
160
|
-
"husky": "^9.0.
|
|
162
|
+
"husky": "^9.0.11",
|
|
161
163
|
"istanbul-instrumenter-loader": "^3.0.1",
|
|
162
|
-
"istanbul-lib-instrument": "^6.0.
|
|
164
|
+
"istanbul-lib-instrument": "^6.0.2",
|
|
163
165
|
"jsdoc": "^4.0.2",
|
|
164
166
|
"karma": "^6.4.2",
|
|
165
167
|
"karma-chai": "^0.1.0",
|
|
@@ -177,9 +179,9 @@
|
|
|
177
179
|
"mocha": "^10.3.0",
|
|
178
180
|
"node-sass": "^9.0.0",
|
|
179
181
|
"regenerator-runtime": "^0.14.1",
|
|
180
|
-
"rollup": "^4.
|
|
182
|
+
"rollup": "^4.12.0",
|
|
181
183
|
"rollup-plugin-delete": "^2.0.0",
|
|
182
|
-
"sass-loader": "^14.1.
|
|
184
|
+
"sass-loader": "^14.1.1",
|
|
183
185
|
"semantic-release": "^23.0.2",
|
|
184
186
|
"simulant": "^0.2.2",
|
|
185
187
|
"sinon": "^17.0.1",
|
|
@@ -189,14 +191,14 @@
|
|
|
189
191
|
"terser-webpack-plugin": "^5.3.10",
|
|
190
192
|
"tslib": "^2.6.2",
|
|
191
193
|
"typescript": "5.3.3",
|
|
192
|
-
"webpack": "^5.90.
|
|
194
|
+
"webpack": "^5.90.3",
|
|
193
195
|
"webpack-bundle-analyzer": "^4.10.1",
|
|
194
196
|
"webpack-clean": "^1.2.5",
|
|
195
197
|
"webpack-cli": "^5.1.4",
|
|
196
198
|
"webpack-common-shake": "^2.1.0",
|
|
197
|
-
"webpack-dev-server": "^5.0.
|
|
199
|
+
"webpack-dev-server": "^5.0.2",
|
|
198
200
|
"webpack-merge": "^5.10.0",
|
|
199
|
-
"webpackbar": "^6.0.
|
|
201
|
+
"webpackbar": "^6.0.1",
|
|
200
202
|
"write-file-webpack-plugin": "^4.5.1"
|
|
201
203
|
}
|
|
202
204
|
}
|
|
@@ -505,6 +505,7 @@ export default class AxisRenderer {
|
|
|
505
505
|
if (this.params.isCategory) {
|
|
506
506
|
interval = tickOffset * 2;
|
|
507
507
|
} else {
|
|
508
|
+
const scale = this.params.owner.scale.zoom ?? this.helper.scale;
|
|
508
509
|
const length = this.g.select("path.domain")
|
|
509
510
|
.node()
|
|
510
511
|
.getTotalLength() - outerTickSize * 2;
|
|
@@ -517,7 +518,7 @@ export default class AxisRenderer {
|
|
|
517
518
|
const next = i + 1;
|
|
518
519
|
|
|
519
520
|
return next < arr.length ?
|
|
520
|
-
|
|
521
|
+
scale(arr[next]) - scale(v) : null;
|
|
521
522
|
}).filter(Boolean) : [];
|
|
522
523
|
|
|
523
524
|
interval = Math.min(...intervalByValue, interval);
|
|
@@ -281,7 +281,7 @@ export default class ChartInternal {
|
|
|
281
281
|
config.subchart_show = false;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
if ($$.hasPointType()) {
|
|
284
|
+
if ($$.hasPointType() || $$.hasLegendDefsPoint?.()) {
|
|
285
285
|
$$.point = $$.generatePoint();
|
|
286
286
|
}
|
|
287
287
|
|
|
@@ -416,7 +416,7 @@ export default class ChartInternal {
|
|
|
416
416
|
const hasColorPatterns = (isFunction(config.color_tiles) && $$.patterns);
|
|
417
417
|
|
|
418
418
|
if (hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
|
|
419
|
-
config.data_labels_backgroundColors) {
|
|
419
|
+
config.data_labels_backgroundColors || $$.hasLegendDefsPoint?.()) {
|
|
420
420
|
$el.defs = $el.svg.append("defs");
|
|
421
421
|
|
|
422
422
|
if (hasAxis) {
|
|
@@ -451,7 +451,7 @@ export default {
|
|
|
451
451
|
return this.state.hiddenLegendIds.indexOf(targetId) < 0;
|
|
452
452
|
},
|
|
453
453
|
|
|
454
|
-
filterTargetsToShow(targets) {
|
|
454
|
+
filterTargetsToShow(targets?) {
|
|
455
455
|
const $$ = this;
|
|
456
456
|
|
|
457
457
|
return (targets || $$.data.targets).filter(t => $$.isTargetToShow(t.id));
|
|
@@ -131,6 +131,7 @@ export default {
|
|
|
131
131
|
unload(rawTargetIds, customDoneCb): void {
|
|
132
132
|
const $$ = this;
|
|
133
133
|
const {state, $el, $T} = $$;
|
|
134
|
+
const hasLegendDefsPoint = !!$$.hasLegendDefsPoint?.();
|
|
134
135
|
let done = customDoneCb;
|
|
135
136
|
let targetIds = rawTargetIds;
|
|
136
137
|
|
|
@@ -158,16 +159,21 @@ export default {
|
|
|
158
159
|
.call(endall, done);
|
|
159
160
|
|
|
160
161
|
targetIds.forEach(id => {
|
|
162
|
+
const suffixId = $$.getTargetSelectorSuffix(id);
|
|
163
|
+
|
|
161
164
|
// Reset fadein for future load
|
|
162
165
|
state.withoutFadeIn[id] = false;
|
|
163
166
|
|
|
164
167
|
// Remove target's elements
|
|
165
168
|
if ($el.legend) {
|
|
166
|
-
$el.legend.selectAll(`.${$LEGEND.legendItem}${
|
|
169
|
+
$el.legend.selectAll(`.${$LEGEND.legendItem}${suffixId}`).remove();
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
// Remove target
|
|
170
173
|
$$.data.targets = $$.data.targets.filter(t => t.id !== id);
|
|
174
|
+
|
|
175
|
+
// Remove custom point def element
|
|
176
|
+
hasLegendDefsPoint && $el.defs?.select(`#${$$.getDefsPointId(suffixId)}`).remove();
|
|
171
177
|
});
|
|
172
178
|
|
|
173
179
|
// since treemap uses different data types, it needs to be transformed
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {drag as d3Drag} from "d3-drag";
|
|
6
|
-
import {zoomIdentity as d3ZoomIdentity, zoom as d3Zoom,
|
|
6
|
+
import {zoomIdentity as d3ZoomIdentity, zoom as d3Zoom, zoomTransform as d3ZoomTransform} from "d3-zoom";
|
|
7
7
|
import {$COMMON, $ZOOM} from "../../config/classes";
|
|
8
8
|
import {callFn, diffDomain, getPointer, isFunction} from "../../module/util";
|
|
9
9
|
|
|
@@ -242,11 +242,10 @@ export default {
|
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
state.zooming = false;
|
|
245
246
|
$$.redrawEventRect();
|
|
246
247
|
$$.updateZoom();
|
|
247
248
|
|
|
248
|
-
state.zooming = false;
|
|
249
|
-
|
|
250
249
|
// do not call event cb when is .unzoom() is called
|
|
251
250
|
!isUnZoom && (e || state.dragging) && callFn(
|
|
252
251
|
config.zoom_onzoomend,
|
|
@@ -425,5 +424,12 @@ export default {
|
|
|
425
424
|
$el.zoomResetBtn.style("display", null);
|
|
426
425
|
}
|
|
427
426
|
}
|
|
427
|
+
},
|
|
428
|
+
|
|
429
|
+
getZoomTransform() {
|
|
430
|
+
const $$ = this;
|
|
431
|
+
const {$el: {eventRect}} = $$;
|
|
432
|
+
|
|
433
|
+
return eventRect?.node() ? d3ZoomTransform(eventRect.node()) : {k: 1};
|
|
428
434
|
}
|
|
429
435
|
};
|
|
@@ -86,9 +86,10 @@ export default {
|
|
|
86
86
|
treemap && $$.updateTreemap(durationForExit);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// @TODO: Axis & Radar type
|
|
90
89
|
if (!state.resizing && !treemap && ($$.hasPointType() || state.hasRadar)) {
|
|
91
90
|
$$.updateCircle();
|
|
91
|
+
} else if ($$.hasLegendDefsPoint?.()) {
|
|
92
|
+
$$.data.targets.forEach($$.point("create", this));
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
// text
|
|
@@ -72,10 +72,10 @@ export default {
|
|
|
72
72
|
*/
|
|
73
73
|
getTitlePadding(): number {
|
|
74
74
|
const $$ = this;
|
|
75
|
-
const {$el, config} = $$;
|
|
75
|
+
const {$el: {title}, config} = $$;
|
|
76
76
|
|
|
77
77
|
return (config.title_padding.top || 0) +
|
|
78
|
-
$$.getTextRect(
|
|
78
|
+
(title ? $$.getTextRect(title, $TEXT.title).height : 0) +
|
|
79
79
|
(config.title_padding.bottom || 0);
|
|
80
80
|
},
|
|
81
81
|
};
|
|
@@ -346,7 +346,7 @@ export default {
|
|
|
346
346
|
|
|
347
347
|
if (!raw) {
|
|
348
348
|
x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
|
|
349
|
-
y += hasGauge ? height : (height / 2) + tHeight;
|
|
349
|
+
y += (hasGauge ? height : (height / 2) + tHeight) + ($$.getTitlePadding?.() ?? 0);
|
|
350
350
|
}
|
|
351
351
|
} else if (hasTreemap) {
|
|
352
352
|
y += tHeight;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
namespaces as d3Namespaces,
|
|
7
|
+
select as d3Select
|
|
8
|
+
} from "d3-selection";
|
|
9
|
+
import {document} from "../../module/browser";
|
|
10
|
+
import {isFunction, isObjectType, notEmpty, toArray} from "../../module/util";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if point draw methods are valid
|
|
14
|
+
* @param {string} point point type
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
function hasValidPointDrawMethods(point: string): boolean {
|
|
19
|
+
return isObjectType(point) &&
|
|
20
|
+
isFunction(point.create) && isFunction(point.update);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Insert point info defs element
|
|
25
|
+
* @param {string} point Point element
|
|
26
|
+
* @param {string} id Point id
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
function insertPointInfoDefs(point: string, id: string): void {
|
|
30
|
+
const $$ = this;
|
|
31
|
+
const copyAttr = (from, target) => {
|
|
32
|
+
const attribs = from.attributes;
|
|
33
|
+
|
|
34
|
+
for (let i = 0, name; (name = attribs[i]); i++) {
|
|
35
|
+
name = name.name;
|
|
36
|
+
target.setAttribute(name, from.getAttribute(name));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const doc = new DOMParser().parseFromString(point, "image/svg+xml");
|
|
41
|
+
const node = doc.documentElement;
|
|
42
|
+
const clone = document.createElementNS(d3Namespaces.svg, node.nodeName.toLowerCase());
|
|
43
|
+
|
|
44
|
+
clone.id = id;
|
|
45
|
+
clone.style.fill = "inherit";
|
|
46
|
+
clone.style.stroke = "inherit";
|
|
47
|
+
|
|
48
|
+
copyAttr(node, clone);
|
|
49
|
+
|
|
50
|
+
if (node.childNodes?.length) {
|
|
51
|
+
const parent = d3Select(clone);
|
|
52
|
+
|
|
53
|
+
if ("innerHTML" in clone) {
|
|
54
|
+
parent.html(node.innerHTML);
|
|
55
|
+
} else {
|
|
56
|
+
toArray(node.childNodes).forEach(v => {
|
|
57
|
+
copyAttr(v, parent.append(v.tagName).node());
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
$$.$el.defs.node().appendChild(clone);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
/**
|
|
67
|
+
* Check if point type option is valid
|
|
68
|
+
* @param {string} type point type
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
hasValidPointType(type?: string): boolean {
|
|
73
|
+
return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check if pattern point is set to be used on legend
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
hasLegendDefsPoint(): boolean {
|
|
82
|
+
const {config} = this;
|
|
83
|
+
|
|
84
|
+
return config.legend_show && config.point_pattern?.length && config.legend_usePoint;
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
getDefsPointId(id: string): string {
|
|
88
|
+
const {state: {datetimeId}} = this;
|
|
89
|
+
|
|
90
|
+
return `${datetimeId}-point${id}`;
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get generate point function
|
|
95
|
+
* @returns {Function}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
generatePoint(): Function {
|
|
99
|
+
const $$ = this;
|
|
100
|
+
const {$el, config} = $$;
|
|
101
|
+
const ids: string[] = [];
|
|
102
|
+
const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
|
103
|
+
|
|
104
|
+
return function(method, context, ...args) {
|
|
105
|
+
return function(d) {
|
|
106
|
+
const id: string = $$.getTargetSelectorSuffix(d.id || d.data?.id || d);
|
|
107
|
+
const element = d3Select(this);
|
|
108
|
+
|
|
109
|
+
ids.indexOf(id) < 0 && ids.push(id);
|
|
110
|
+
|
|
111
|
+
let point = pattern[ids.indexOf(id) % pattern.length];
|
|
112
|
+
|
|
113
|
+
if ($$.hasValidPointType(point)) {
|
|
114
|
+
point = $$[point];
|
|
115
|
+
} else if (!hasValidPointDrawMethods(point || config.point_type)) {
|
|
116
|
+
const pointId = $$.getDefsPointId(id);
|
|
117
|
+
const defsPoint = $el.defs.select(`#${pointId}`);
|
|
118
|
+
|
|
119
|
+
if (defsPoint.size() < 1) {
|
|
120
|
+
insertPointInfoDefs.bind($$)(point, pointId);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (method === "create") {
|
|
124
|
+
return $$.custom?.create.bind(context)(element, pointId, ...args);
|
|
125
|
+
} else if (method === "update") {
|
|
126
|
+
return $$.custom?.update.bind(context)(element, ...args);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return point[method]?.bind(context)(element, ...args);
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
};
|
|
@@ -2,30 +2,15 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
namespaces as d3Namespaces,
|
|
7
|
-
select as d3Select
|
|
8
|
-
} from "d3-selection";
|
|
9
|
-
import type {d3Selection} from "../../../types/types";
|
|
5
|
+
import {select as d3Select} from "d3-selection";
|
|
10
6
|
import {$CIRCLE, $COMMON, $SELECT} from "../../config/classes";
|
|
11
|
-
import {
|
|
7
|
+
import {getBoundingRect, getPointer, getRandom, isFunction, isObject, isUndefined, isValue} from "../../module/util";
|
|
8
|
+
import type {d3Selection} from "../../../types/types";
|
|
12
9
|
import type {IDataPoint, IDataRow} from "../data/IData";
|
|
13
|
-
import {getBoundingRect, getPointer, getRandom, isFunction, isObject, isObjectType, isUndefined, isValue, toArray, notEmpty} from "../../module/util";
|
|
14
10
|
|
|
15
11
|
const getTransitionName = () => getRandom();
|
|
16
12
|
|
|
17
13
|
export default {
|
|
18
|
-
hasValidPointType(type?: string): boolean {
|
|
19
|
-
return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
hasValidPointDrawMethods(type?: string): boolean {
|
|
23
|
-
const pointType = type || this.config.point_type;
|
|
24
|
-
|
|
25
|
-
return isObjectType(pointType) &&
|
|
26
|
-
isFunction(pointType.create) && isFunction(pointType.update);
|
|
27
|
-
},
|
|
28
|
-
|
|
29
14
|
initialOpacityForCircle(d): string | number | null {
|
|
30
15
|
const {config, state: {withoutFadeIn}} = this;
|
|
31
16
|
let opacity = config.point_opacity;
|
|
@@ -410,46 +395,6 @@ export default {
|
|
|
410
395
|
return sensitivity;
|
|
411
396
|
},
|
|
412
397
|
|
|
413
|
-
insertPointInfoDefs(point, id: string): void {
|
|
414
|
-
const $$ = this;
|
|
415
|
-
const copyAttr = (from, target) => {
|
|
416
|
-
const attribs = from.attributes;
|
|
417
|
-
|
|
418
|
-
for (let i = 0, name; (name = attribs[i]); i++) {
|
|
419
|
-
name = name.name;
|
|
420
|
-
target.setAttribute(name, from.getAttribute(name));
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
const doc = new DOMParser().parseFromString(point, "image/svg+xml");
|
|
425
|
-
const node = doc.documentElement;
|
|
426
|
-
const clone = document.createElementNS(d3Namespaces.svg, node.nodeName.toLowerCase());
|
|
427
|
-
|
|
428
|
-
clone.id = id;
|
|
429
|
-
clone.style.fill = "inherit";
|
|
430
|
-
clone.style.stroke = "inherit";
|
|
431
|
-
|
|
432
|
-
copyAttr(node, clone);
|
|
433
|
-
|
|
434
|
-
if (node.childNodes?.length) {
|
|
435
|
-
const parent = d3Select(clone);
|
|
436
|
-
|
|
437
|
-
if ("innerHTML" in clone) {
|
|
438
|
-
parent.html(node.innerHTML);
|
|
439
|
-
} else {
|
|
440
|
-
toArray(node.childNodes).forEach(v => {
|
|
441
|
-
copyAttr(v, parent.append(v.tagName).node());
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
$$.$el.defs.node().appendChild(clone);
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
pointFromDefs(id: string) {
|
|
450
|
-
return this.$el.defs.select(`#${id}`);
|
|
451
|
-
},
|
|
452
|
-
|
|
453
398
|
updatePointClass(d) {
|
|
454
399
|
const $$ = this;
|
|
455
400
|
const {circle} = $$.$el;
|
|
@@ -504,43 +449,6 @@ export default {
|
|
|
504
449
|
};
|
|
505
450
|
},
|
|
506
451
|
|
|
507
|
-
generatePoint(): Function {
|
|
508
|
-
const $$ = this;
|
|
509
|
-
const {config, state: {datetimeId}} = $$;
|
|
510
|
-
const ids: string[] = [];
|
|
511
|
-
const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
|
512
|
-
|
|
513
|
-
return function(method, context, ...args) {
|
|
514
|
-
return function(d) {
|
|
515
|
-
const id: string = $$.getTargetSelectorSuffix(d.id || d.data?.id || d);
|
|
516
|
-
const element = d3Select(this);
|
|
517
|
-
|
|
518
|
-
ids.indexOf(id) < 0 && ids.push(id);
|
|
519
|
-
|
|
520
|
-
let point = pattern[ids.indexOf(id) % pattern.length];
|
|
521
|
-
|
|
522
|
-
if ($$.hasValidPointType(point)) {
|
|
523
|
-
point = $$[point];
|
|
524
|
-
} else if (!$$.hasValidPointDrawMethods(point)) {
|
|
525
|
-
const pointId = `${datetimeId}-point${id}`;
|
|
526
|
-
const pointFromDefs = $$.pointFromDefs(pointId);
|
|
527
|
-
|
|
528
|
-
if (pointFromDefs.size() < 1) {
|
|
529
|
-
$$.insertPointInfoDefs(point, pointId);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (method === "create") {
|
|
533
|
-
return $$.custom.create.bind(context)(element, pointId, ...args);
|
|
534
|
-
} else if (method === "update") {
|
|
535
|
-
return $$.custom.update.bind(context)(element, ...args);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
return point[method].bind(context)(element, ...args);
|
|
540
|
-
};
|
|
541
|
-
};
|
|
542
|
-
},
|
|
543
|
-
|
|
544
452
|
custom: {
|
|
545
453
|
create(element, id, fillStyleFn) {
|
|
546
454
|
return element.append("use")
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
import {select as d3Select} from "d3-selection";
|
|
26
26
|
import type {d3Selection} from "../../../types/types";
|
|
27
27
|
import CLASS from "../../config/classes";
|
|
28
|
-
import {capitalize, getPointer, getRectSegList, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty} from "../../module/util";
|
|
28
|
+
import {capitalize, getPointer, getRectSegList, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty, parseDate} from "../../module/util";
|
|
29
29
|
import type {IDataRow, IDataIndice, TIndices} from "../data/IData";
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -423,13 +423,25 @@ export default {
|
|
|
423
423
|
const $$ = this;
|
|
424
424
|
const {config, org, scale} = $$;
|
|
425
425
|
const maxDataCount = $$.getMaxDataCount();
|
|
426
|
-
const isGrouped = type === "bar" && config.data_groups
|
|
426
|
+
const isGrouped = type === "bar" && config.data_groups?.length;
|
|
427
427
|
const configName = `${type}_width`;
|
|
428
|
+
const {k} = $$.getZoomTransform?.() ?? {k: 1};
|
|
429
|
+
const xMinMax = <[number, number]>[
|
|
430
|
+
config.axis_x_min ?? org.xDomain[0],
|
|
431
|
+
config.axis_x_max ?? org.xDomain[1]
|
|
432
|
+
].map($$.axis.isTimeSeries() ? parseDate.bind($$) : Number);
|
|
428
433
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
434
|
+
let tickInterval = axis.tickInterval(maxDataCount);
|
|
435
|
+
|
|
436
|
+
if (scale.zoom && !$$.axis.isCategorized() && k > 1) {
|
|
437
|
+
const isSameMinMax = xMinMax.every((v, i) => v === org.xDomain[i]);
|
|
438
|
+
|
|
439
|
+
tickInterval = org.xDomain.map((v, i) => {
|
|
440
|
+
const value = isSameMinMax ? v : v - Math.abs(xMinMax[i]);
|
|
441
|
+
|
|
442
|
+
return scale.zoom(value);
|
|
443
|
+
}).reduce((a, c) => Math.abs(a) + c) / maxDataCount;
|
|
444
|
+
}
|
|
433
445
|
|
|
434
446
|
const getWidth = (id?: string) => {
|
|
435
447
|
const width = id ? config[configName][id] : config[configName];
|
|
@@ -55,7 +55,7 @@ export default class State {
|
|
|
55
55
|
dataMax: 0,
|
|
56
56
|
|
|
57
57
|
maxTickSize: {
|
|
58
|
-
x: {width: 0, height: 0, ticks: <number[]> [], clipPath: 0, domain: ""},
|
|
58
|
+
x: {width: 0, height: 0, ticks: <(number|string)[]> [], clipPath: 0, domain: ""},
|
|
59
59
|
y: {width: 0, height: 0, domain: ""},
|
|
60
60
|
y2: {width: 0, height: 0, domain: ""}
|
|
61
61
|
},
|
|
@@ -39,7 +39,7 @@ export const api = [
|
|
|
39
39
|
apiX
|
|
40
40
|
];
|
|
41
41
|
|
|
42
|
-
export const internal =
|
|
42
|
+
export const internal = {
|
|
43
43
|
axis,
|
|
44
44
|
clip,
|
|
45
45
|
eventrect,
|
|
@@ -47,10 +47,10 @@ export const internal = [
|
|
|
47
47
|
grid,
|
|
48
48
|
region,
|
|
49
49
|
sizeAxis,
|
|
50
|
-
|
|
50
|
+
};
|
|
51
51
|
|
|
52
|
-
export const options =
|
|
52
|
+
export const options = {
|
|
53
53
|
optDataAxis,
|
|
54
54
|
optAxis,
|
|
55
55
|
optGrid,
|
|
56
|
-
|
|
56
|
+
};
|
|
@@ -23,6 +23,7 @@ import shapeCandlestick from "../../ChartInternal/shape/candlestick";
|
|
|
23
23
|
import shapeGauge from "../../ChartInternal/shape/gauge";
|
|
24
24
|
import shapeBubble from "../../ChartInternal/shape/bubble";
|
|
25
25
|
import shapeLine from "../../ChartInternal/shape/line";
|
|
26
|
+
import shapePointCommon from "../../ChartInternal/shape/point.common";
|
|
26
27
|
import shapePoint from "../../ChartInternal/shape/point";
|
|
27
28
|
import shapePolar from "../../ChartInternal/shape/polar";
|
|
28
29
|
import shapeRadar from "../../ChartInternal/shape/radar";
|
|
@@ -75,9 +76,9 @@ export {
|
|
|
75
76
|
* @private
|
|
76
77
|
*/
|
|
77
78
|
function extendAxis(module, option?): void {
|
|
78
|
-
extend(ChartInternal.prototype, axisInternal.concat(module));
|
|
79
|
+
extend(ChartInternal.prototype, Object.values(axisInternal).concat(module));
|
|
79
80
|
extend(Chart.prototype, axisAPI);
|
|
80
|
-
Options.setOptions(axisOptions.concat(option || []));
|
|
81
|
+
Options.setOptions(Object.values(axisOptions).concat(option || []));
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
/**
|
|
@@ -87,7 +88,7 @@ function extendAxis(module, option?): void {
|
|
|
87
88
|
* @private
|
|
88
89
|
*/
|
|
89
90
|
function extendLine(module?, option?): void {
|
|
90
|
-
extendAxis([shapePoint, shapeLine].concat(module || []));
|
|
91
|
+
extendAxis([shapePointCommon, shapePoint, shapeLine].concat(module || []));
|
|
91
92
|
Options.setOptions([optPoint, optLine].concat(option || []));
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -98,8 +99,8 @@ function extendLine(module?, option?): void {
|
|
|
98
99
|
* @private
|
|
99
100
|
*/
|
|
100
101
|
function extendArc(module?, option?): void {
|
|
101
|
-
extend(ChartInternal.prototype, [shapeArc].concat(module || []));
|
|
102
|
-
Options.setOptions(option);
|
|
102
|
+
extend(ChartInternal.prototype, [shapeArc, shapePointCommon].concat(module || []));
|
|
103
|
+
Options.setOptions([optPoint].concat(option || []));
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
// Area types
|
|
@@ -138,19 +139,30 @@ let polar = (): string => (
|
|
|
138
139
|
extendArc([shapePolar], [optArc, optPolar]), (polar = () => TYPE.POLAR)()
|
|
139
140
|
);
|
|
140
141
|
let radar = (): string => (
|
|
141
|
-
extendArc(
|
|
142
|
+
extendArc(
|
|
143
|
+
[axisInternal.eventrect, shapePoint, shapeRadar],
|
|
144
|
+
[optPoint, optRadar, {axis_x_categories: axisOptions.optAxis.axis_x_categories}]
|
|
145
|
+
), (radar = () => TYPE.RADAR)()
|
|
142
146
|
);
|
|
143
147
|
|
|
144
148
|
// Axis based types
|
|
145
|
-
let bar = (): string => (
|
|
149
|
+
let bar = (): string => (
|
|
150
|
+
extendAxis([shapeBar, shapePointCommon], [optBar, optPoint]), (bar = () => TYPE.BAR)()
|
|
151
|
+
);
|
|
146
152
|
let bubble = (): string => (
|
|
147
|
-
extendAxis(
|
|
153
|
+
extendAxis(
|
|
154
|
+
[shapePointCommon, shapePoint, shapeBubble], [optBubble, optPoint]
|
|
155
|
+
), (bubble = () => TYPE.BUBBLE)()
|
|
148
156
|
);
|
|
149
157
|
let candlestick = (): string => (
|
|
150
|
-
extendAxis(
|
|
158
|
+
extendAxis(
|
|
159
|
+
[shapeCandlestick, shapePointCommon], [optCandlestick, optPoint]
|
|
160
|
+
), (candlestick = () => TYPE.CANDLESTICK)()
|
|
151
161
|
);
|
|
152
162
|
let scatter = (): string => (
|
|
153
|
-
extendAxis(
|
|
163
|
+
extendAxis(
|
|
164
|
+
[shapePointCommon, shapePoint], [optPoint, optScatter]
|
|
165
|
+
), (scatter = () => TYPE.SCATTER)()
|
|
154
166
|
);
|
|
155
167
|
|
|
156
168
|
// Non Axis based types
|