billboard.js 3.12.4 → 3.13.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 +10 -3
- package/dist/billboard.css +167 -118
- package/dist/billboard.js +213 -90
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +10 -10
- package/dist/billboard.pkgd.js +1212 -1504
- package/dist/billboard.pkgd.min.js +15 -15
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +5 -12
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +7 -13
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +9 -21
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +7 -13
- package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +7 -13
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +597 -628
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -5
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +759 -953
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +6 -6
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +840 -1105
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -12
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +759 -953
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +7 -7
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +832 -1092
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -7
- package/dist/theme/dark.css +220 -154
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +221 -157
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +223 -158
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +212 -149
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +223 -159
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +249 -73
- 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 +28 -42
- package/src/Chart/api/show.ts +1 -1
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/data/data.ts +11 -0
- package/src/ChartInternal/interactions/zoom.ts +12 -1
- package/src/ChartInternal/internals/legend.ts +1 -1
- package/src/ChartInternal/internals/scale.ts +13 -5
- package/src/ChartInternal/shape/line.ts +170 -41
- package/src/ChartInternal/shape/shape.ts +8 -5
- package/src/config/Options/axis/y2.ts +13 -0
- package/src/config/Options/common/legend.ts +3 -2
- package/src/config/Options/data/axis.ts +6 -2
- package/src/config/Options/data/data.ts +7 -4
- package/src/config/Options/shape/bar.ts +22 -6
- package/src/config/const.ts +10 -4
- package/src/config/resolver/shape.ts +4 -0
- package/src/index.esm.ts +1 -0
- package/src/module/browser.ts +1 -1
- package/src/module/util.ts +2 -2
- package/src/module/worker.ts +1 -1
- package/types/bb.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/options.d.ts +6 -6
- package/types/options.shape.d.ts +10 -1
- package/types/types.d.ts +1 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.
|
|
8
|
+
* @version 3.13.0-next.2
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -501,7 +501,7 @@ var Plugin = /** @class */ (function () {
|
|
|
501
501
|
delete _this[key];
|
|
502
502
|
});
|
|
503
503
|
};
|
|
504
|
-
Plugin.version = "3.
|
|
504
|
+
Plugin.version = "3.13.0-next.2";
|
|
505
505
|
return Plugin;
|
|
506
506
|
}());
|
|
507
507
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.
|
|
8
|
+
* @version 3.13.0-next.2
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -290,7 +290,7 @@ var Plugin = /** @class */ (function () {
|
|
|
290
290
|
delete _this[key];
|
|
291
291
|
});
|
|
292
292
|
};
|
|
293
|
-
Plugin.version = "3.
|
|
293
|
+
Plugin.version = "3.13.0-next.2";
|
|
294
294
|
return Plugin;
|
|
295
295
|
}());
|
|
296
296
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.
|
|
8
|
+
* @version 3.13.0-next.2
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -267,7 +267,7 @@ var Plugin = /** @class */ (function () {
|
|
|
267
267
|
delete _this[key];
|
|
268
268
|
});
|
|
269
269
|
};
|
|
270
|
-
Plugin.version = "3.
|
|
270
|
+
Plugin.version = "3.13.0-next.2";
|
|
271
271
|
return Plugin;
|
|
272
272
|
}());
|
|
273
273
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0-next.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",
|
|
@@ -39,9 +39,8 @@
|
|
|
39
39
|
"lint": "eslint",
|
|
40
40
|
"format": "dprint fmt",
|
|
41
41
|
"loc": "cloc --by-file src",
|
|
42
|
-
"test": "
|
|
43
|
-
"
|
|
44
|
-
"coverage": "cross-env TEST_TYPE=coverage npm test",
|
|
42
|
+
"test": "vitest",
|
|
43
|
+
"coverage": "vitest run",
|
|
45
44
|
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
46
45
|
"jsdoc": "node ./config/jsdoc.js",
|
|
47
46
|
"jsdoc:cmd": "jsdoc -c jsdoc.json",
|
|
@@ -104,22 +103,24 @@
|
|
|
104
103
|
"devDependencies": {
|
|
105
104
|
"@commitlint/cli": "19.3.0",
|
|
106
105
|
"@commitlint/config-conventional": "^19.2.2",
|
|
107
|
-
"@eslint/js": "^9.
|
|
106
|
+
"@eslint/js": "^9.8.0",
|
|
108
107
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
109
108
|
"@rollup/plugin-replace": "^5.0.7",
|
|
110
109
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
111
110
|
"@semantic-release/changelog": "^6.0.3",
|
|
112
|
-
"@semantic-release/commit-analyzer": "^
|
|
111
|
+
"@semantic-release/commit-analyzer": "^13.0.0",
|
|
113
112
|
"@semantic-release/exec": "^6.0.3",
|
|
114
113
|
"@semantic-release/git": "^10.0.1",
|
|
115
114
|
"@semantic-release/npm": "^12.0.1",
|
|
116
|
-
"@semantic-release/release-notes-generator": "^14.0.
|
|
117
|
-
"@
|
|
115
|
+
"@semantic-release/release-notes-generator": "^14.0.1",
|
|
116
|
+
"@testing-library/dom": "^10.4.0",
|
|
117
|
+
"@testing-library/react": "^16.0.0",
|
|
118
118
|
"@types/d3": "^7.4.3",
|
|
119
|
-
"@types/mocha": "^10.0.6",
|
|
120
119
|
"@types/sinon": "^17.0.3",
|
|
120
|
+
"@vitest/browser": "^2.0.5",
|
|
121
|
+
"@vitest/coverage-istanbul": "^2.0.5",
|
|
122
|
+
"@vitest/ui": "^2.0.5",
|
|
121
123
|
"better-docs": "^2.7.3",
|
|
122
|
-
"chai": "^4.3.10",
|
|
123
124
|
"clean-webpack-plugin": "^4.0.0",
|
|
124
125
|
"cloc": "^2.11.0",
|
|
125
126
|
"core-js": "^3.37.1",
|
|
@@ -131,54 +132,39 @@
|
|
|
131
132
|
"d3-format": "^3.1.0",
|
|
132
133
|
"d3-polygon": "^3.0.1",
|
|
133
134
|
"docdash": "^2.0.2",
|
|
134
|
-
"dprint": "^0.
|
|
135
|
-
"esbuild-loader": "^4.
|
|
136
|
-
"eslint": "^9.
|
|
137
|
-
"eslint-config-naver": "^2.1.0",
|
|
135
|
+
"dprint": "^0.47.2",
|
|
136
|
+
"esbuild-loader": "^4.2.2",
|
|
137
|
+
"eslint": "^9.8.0",
|
|
138
138
|
"eslint-plugin-import": "^2.29.1",
|
|
139
|
-
"eslint-plugin-jsdoc": "^48.2
|
|
140
|
-
"
|
|
141
|
-
"hammer-simulator": "0.0.1",
|
|
142
|
-
"husky": "^9.0.11",
|
|
143
|
-
"istanbul-instrumenter-loader": "^3.0.1",
|
|
144
|
-
"istanbul-lib-instrument": "^6.0.2",
|
|
139
|
+
"eslint-plugin-jsdoc": "^48.9.2",
|
|
140
|
+
"husky": "^9.1.4",
|
|
145
141
|
"jsdoc": "^4.0.3",
|
|
146
|
-
"
|
|
147
|
-
"karma-chai": "^0.1.0",
|
|
148
|
-
"karma-chrome-launcher": "^3.2.0",
|
|
149
|
-
"karma-coverage-istanbul-reporter": "^3.0.3",
|
|
150
|
-
"karma-mocha": "^2.0.1",
|
|
151
|
-
"karma-mocha-reporter": "^2.2.3",
|
|
152
|
-
"karma-scss-preprocessor": "^4.0.0",
|
|
153
|
-
"karma-sinon": "^1.0.5",
|
|
154
|
-
"karma-sourcemap-loader": "^0.4.0",
|
|
155
|
-
"karma-webpack": "^5.0.1",
|
|
156
|
-
"lint-staged": "^15.2.5",
|
|
157
|
-
"lite-fixture": "^1.0.2",
|
|
142
|
+
"lint-staged": "^15.2.7",
|
|
158
143
|
"mini-css-extract-plugin": "^2.9.0",
|
|
159
|
-
"
|
|
160
|
-
"node-sass": "^9.0.0",
|
|
144
|
+
"playwright": "^1.46.0",
|
|
161
145
|
"regenerator-runtime": "^0.14.1",
|
|
162
|
-
"rollup": "^4.
|
|
146
|
+
"rollup": "^4.19.1",
|
|
163
147
|
"rollup-plugin-delete": "^2.0.0",
|
|
164
|
-
"sass
|
|
148
|
+
"sass": "^1.77.8",
|
|
149
|
+
"sass-loader": "^16.0.0",
|
|
165
150
|
"semantic-release": "^24.0.0",
|
|
166
151
|
"simulant": "^0.2.2",
|
|
167
152
|
"sinon": "^18.0.0",
|
|
168
153
|
"string-replace-loader": "^3.1.0",
|
|
169
154
|
"style-loader": "^4.0.0",
|
|
170
|
-
"taffydb": "^2.7.3",
|
|
171
155
|
"tslib": "^2.6.3",
|
|
172
|
-
"typescript": "5.4
|
|
173
|
-
"typescript-eslint": "^7.
|
|
174
|
-
"
|
|
156
|
+
"typescript": "5.5.4",
|
|
157
|
+
"typescript-eslint": "^7.18.0",
|
|
158
|
+
"vitest": "^2.0.5",
|
|
159
|
+
"webpack": "^5.93.0",
|
|
175
160
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
176
161
|
"webpack-clean": "^1.2.5",
|
|
177
162
|
"webpack-cli": "^5.1.4",
|
|
178
163
|
"webpack-common-shake": "^2.1.0",
|
|
179
164
|
"webpack-dev-server": "^5.0.4",
|
|
180
|
-
"webpack-merge": "^
|
|
165
|
+
"webpack-merge": "^6.0.1",
|
|
181
166
|
"webpackbar": "^6.0.1",
|
|
182
167
|
"write-file-webpack-plugin": "^4.5.1"
|
|
183
|
-
}
|
|
168
|
+
},
|
|
169
|
+
"packageManager": "yarn@4.3.1"
|
|
184
170
|
}
|
package/src/Chart/api/show.ts
CHANGED
|
@@ -36,7 +36,7 @@ function showHide(show: boolean, targetIdsValue: string[], options: any): void {
|
|
|
36
36
|
// https://github.com/naver/billboard.js/issues/1758
|
|
37
37
|
if (!show && hiddenIds.length === 0) {
|
|
38
38
|
targets.style("display", "none");
|
|
39
|
-
callFn($$.config
|
|
39
|
+
callFn($$.config?.data_onhidden, this, targetIds);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
targets.style("opacity", opacity);
|
|
@@ -437,7 +437,7 @@ export default class ChartInternal {
|
|
|
437
437
|
$el.defs = $el.svg.append("defs");
|
|
438
438
|
|
|
439
439
|
if (hasAxis) {
|
|
440
|
-
["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
|
|
440
|
+
["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(v => {
|
|
441
441
|
$$.appendClip($el.defs, state.clip[v]);
|
|
442
442
|
});
|
|
443
443
|
}
|
|
@@ -683,10 +683,21 @@ export default {
|
|
|
683
683
|
(isObjectType(dataLabels) && notEmpty(dataLabels));
|
|
684
684
|
},
|
|
685
685
|
|
|
686
|
+
/**
|
|
687
|
+
* Determine if has null value
|
|
688
|
+
* @param {Array} targets Data array to be evaluated
|
|
689
|
+
* @returns {boolean}
|
|
690
|
+
* @private
|
|
691
|
+
*/
|
|
692
|
+
hasNullDataValue(targets: IDataRow[]): boolean {
|
|
693
|
+
return targets.some(({value}) => value === null);
|
|
694
|
+
},
|
|
695
|
+
|
|
686
696
|
/**
|
|
687
697
|
* Get data index from the event coodinates
|
|
688
698
|
* @param {Event} event Event object
|
|
689
699
|
* @returns {number}
|
|
700
|
+
* @private
|
|
690
701
|
*/
|
|
691
702
|
getDataIndexFromEvent(event): number {
|
|
692
703
|
const $$ = this;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
zoomTransform as d3ZoomTransform
|
|
10
10
|
} from "d3-zoom";
|
|
11
11
|
import {$COMMON, $ZOOM} from "../../config/classes";
|
|
12
|
+
import {window} from "../../module/browser";
|
|
12
13
|
import {callFn, diffDomain, getPointer, isFunction} from "../../module/util";
|
|
13
14
|
|
|
14
15
|
export default {
|
|
@@ -329,9 +330,19 @@ export default {
|
|
|
329
330
|
*/
|
|
330
331
|
bindZoomOnEventRect(): void {
|
|
331
332
|
const $$ = this;
|
|
332
|
-
const {config, $el: {eventRect}} = $$;
|
|
333
|
+
const {config, $el: {eventRect, svg}} = $$;
|
|
333
334
|
const behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;
|
|
334
335
|
|
|
336
|
+
// On Safari, event can't be built inside the svg content
|
|
337
|
+
// for workaround, register wheel event on <svg> element first
|
|
338
|
+
// https://bugs.webkit.org/show_bug.cgi?id=226683#c3
|
|
339
|
+
// https://stackoverflow.com/questions/67836886/wheel-event-is-not-fired-on-a-svg-group-element-in-safari
|
|
340
|
+
if (
|
|
341
|
+
window.GestureEvent && /^((?!chrome|android|mobile).)*safari/i.test(navigator.userAgent)
|
|
342
|
+
) {
|
|
343
|
+
svg.on("wheel", () => {});
|
|
344
|
+
}
|
|
345
|
+
|
|
335
346
|
eventRect?.call(behaviour)
|
|
336
347
|
.on("dblclick.zoom", null);
|
|
337
348
|
},
|
|
@@ -41,7 +41,7 @@ function getFormattedText<T = string>(id: T, formatted = true): T {
|
|
|
41
41
|
let text = config.data_names[id] ?? id;
|
|
42
42
|
|
|
43
43
|
if (formatted && isFunction(config.legend_format)) {
|
|
44
|
-
text = config.legend_format(text);
|
|
44
|
+
text = config.legend_format(text, id !== text ? id : undefined);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
return text;
|
|
@@ -15,12 +15,12 @@ import type {IDataRow, IGridData} from "../data/IData";
|
|
|
15
15
|
/**
|
|
16
16
|
* Get scale
|
|
17
17
|
* @param {string} [type='linear'] Scale type
|
|
18
|
-
* @param {number} [min] Min range
|
|
19
|
-
* @param {number} [max] Max range
|
|
18
|
+
* @param {number|Date} [min] Min range
|
|
19
|
+
* @param {number|Date} [max] Max range
|
|
20
20
|
* @returns {d3.scaleLinear|d3.scaleTime} scale
|
|
21
21
|
* @private
|
|
22
22
|
*/
|
|
23
|
-
export function getScale(type = "linear", min
|
|
23
|
+
export function getScale<T = IDataRow["x"]>(type = "linear", min?: T, max?: T): any {
|
|
24
24
|
const scale = ({
|
|
25
25
|
linear: d3ScaleLinear,
|
|
26
26
|
log: d3ScaleSymlog,
|
|
@@ -32,7 +32,7 @@ export function getScale(type = "linear", min = 0, max = 1): any {
|
|
|
32
32
|
scale.type = type;
|
|
33
33
|
/_?log/.test(type) && scale.clamp(true);
|
|
34
34
|
|
|
35
|
-
return scale.range([min, max]);
|
|
35
|
+
return scale.range([min ?? 0, max ?? 1]);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export default {
|
|
@@ -99,7 +99,15 @@ export default {
|
|
|
99
99
|
const $$ = this;
|
|
100
100
|
const offset = offsetValue || (() => $$.axis.x.tickOffset());
|
|
101
101
|
const isInverted = $$.config.axis_x_inverted;
|
|
102
|
-
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get scaled value
|
|
105
|
+
* @param {object} d Data object
|
|
106
|
+
* @param {boolean} raw Get the raw value
|
|
107
|
+
* @returns {number}
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
const scale = function(d: IDataRow, raw?: boolean): number {
|
|
103
111
|
const v = scaleValue(d) + offset();
|
|
104
112
|
|
|
105
113
|
return raw ? v : Math.ceil(v);
|
|
@@ -13,8 +13,72 @@ import {
|
|
|
13
13
|
isValue,
|
|
14
14
|
parseDate
|
|
15
15
|
} from "../../module/util";
|
|
16
|
+
import type {IDataRow} from "../data/IData";
|
|
16
17
|
import {getScale} from "../internals/scale";
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Get stroke dasharray style value
|
|
21
|
+
* @param {number} start Start position in path length
|
|
22
|
+
* @param {number} end End position in path length
|
|
23
|
+
* @param {Array} pattern Dash array pattern
|
|
24
|
+
* @param {boolean} isLastX Weather is last x tick
|
|
25
|
+
* @returns {object} Stroke dasharray style value and its length
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
function getStrokeDashArray(start: number, end: number, pattern: [number, number],
|
|
29
|
+
isLastX = false): {dash: string, length: number} {
|
|
30
|
+
const dash = start ? [start, 0] : pattern;
|
|
31
|
+
|
|
32
|
+
for (let i = start ? start : pattern.reduce((a, c) => a + c); i <= end;) {
|
|
33
|
+
pattern.forEach(v => {
|
|
34
|
+
if (i + v <= end) {
|
|
35
|
+
dash.push(v);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
i += v;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// make sure to have even length
|
|
43
|
+
dash.length % 2 !== 0 && dash.push(isLastX ? pattern[1] : 0);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
dash: dash.join(" "),
|
|
47
|
+
length: dash.reduce((a, b) => a + b, 0)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get regions data
|
|
53
|
+
* @param {Array} d Data object
|
|
54
|
+
* @param {object} _regions regions to be set
|
|
55
|
+
* @param {boolean} isTimeSeries whether is time series
|
|
56
|
+
* @returns {object} Regions data
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
function getRegions(d, _regions, isTimeSeries) {
|
|
60
|
+
const $$ = this;
|
|
61
|
+
const regions: {start: number | string, end: number | string, style: string}[] = [];
|
|
62
|
+
const dasharray = "2 2"; // default value
|
|
63
|
+
|
|
64
|
+
// Check start/end of regions
|
|
65
|
+
if (isDefined(_regions)) {
|
|
66
|
+
const getValue = (v: Date | any, def: number | Date): Date | any => (
|
|
67
|
+
isUndefined(v) ? def : (isTimeSeries ? parseDate.call($$, v) : v)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
for (let i = 0, reg; (reg = _regions[i]); i++) {
|
|
71
|
+
const start = getValue(reg.start, d[0].x);
|
|
72
|
+
const end = getValue(reg.end, d[d.length - 1].x);
|
|
73
|
+
const style = reg.style || {dasharray};
|
|
74
|
+
|
|
75
|
+
regions[i] = {start, end, style};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return regions;
|
|
80
|
+
}
|
|
81
|
+
|
|
18
82
|
export default {
|
|
19
83
|
initLine(): void {
|
|
20
84
|
const {$el} = this;
|
|
@@ -98,6 +162,7 @@ export default {
|
|
|
98
162
|
* @param {boolean} withTransition With or without transition
|
|
99
163
|
* @param {boolean} isSub Subchart draw
|
|
100
164
|
* @returns {Array}
|
|
165
|
+
* @private
|
|
101
166
|
*/
|
|
102
167
|
redrawLine(drawFn, withTransition?: boolean, isSub = false) {
|
|
103
168
|
const $$ = this;
|
|
@@ -210,34 +275,31 @@ export default {
|
|
|
210
275
|
};
|
|
211
276
|
},
|
|
212
277
|
|
|
213
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Set regions dasharray and get path
|
|
280
|
+
* @param {Array} d Data object
|
|
281
|
+
* @param {Function} x x scale function
|
|
282
|
+
* @param {Function} y y scale function
|
|
283
|
+
* @param {object} _regions regions to be set
|
|
284
|
+
* @returns {stirng} Path string
|
|
285
|
+
* @private
|
|
286
|
+
*/
|
|
287
|
+
lineWithRegions(d: IDataRow[], x, y, _regions): string {
|
|
214
288
|
const $$ = this;
|
|
215
289
|
const {config} = $$;
|
|
216
290
|
const isRotated = config.axis_rotated;
|
|
217
291
|
const isTimeSeries = $$.axis.isTimeSeries();
|
|
218
|
-
const regions: any[] = [];
|
|
219
292
|
const dasharray = "2 2"; // default value
|
|
293
|
+
const regions = getRegions.bind($$)(d, _regions, isTimeSeries);
|
|
294
|
+
|
|
295
|
+
// when contains null data, can't apply style dashed
|
|
296
|
+
const hasNullDataValue = $$.hasNullDataValue(d);
|
|
220
297
|
|
|
221
298
|
let xp;
|
|
222
299
|
let yp;
|
|
223
300
|
let diff;
|
|
224
301
|
let diffx2;
|
|
225
302
|
|
|
226
|
-
// Check start/end of regions
|
|
227
|
-
if (isDefined(_regions)) {
|
|
228
|
-
const getValue = (v: Date | any, def: number): Date | any => (
|
|
229
|
-
isUndefined(v) ? def : (isTimeSeries ? parseDate.call($$, v) : v)
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
for (let i = 0, reg; (reg = _regions[i]); i++) {
|
|
233
|
-
const start = getValue(reg.start, d[0].x);
|
|
234
|
-
const end = getValue(reg.end, d[d.length - 1].x);
|
|
235
|
-
const style = reg.style || {dasharray};
|
|
236
|
-
|
|
237
|
-
regions[i] = {start, end, style};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
303
|
// Set scales
|
|
242
304
|
const xValue = isRotated ? dt => y(dt.value) : dt => x(dt.x);
|
|
243
305
|
const yValue = isRotated ? dt => x(dt.x) : dt => y(dt.value);
|
|
@@ -259,15 +321,31 @@ export default {
|
|
|
259
321
|
return generateM(points);
|
|
260
322
|
} :
|
|
261
323
|
(d0, d1, k, otherDiff) => {
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
324
|
+
const x0 = x(d1.x, !isRotated);
|
|
325
|
+
const y0 = y(d1.value, isRotated);
|
|
326
|
+
|
|
327
|
+
const gap = k + otherDiff;
|
|
328
|
+
const xValue = x(xp(k), !isRotated);
|
|
329
|
+
const yValue = y(yp(k), isRotated);
|
|
330
|
+
|
|
331
|
+
let xDiff = x(xp(gap), !isRotated);
|
|
332
|
+
let yDiff = y(yp(gap), isRotated);
|
|
333
|
+
|
|
334
|
+
// fix diff values not to overflow
|
|
335
|
+
if (xDiff > x0) {
|
|
336
|
+
xDiff = x0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (d0.value > d1.value && (isRotated ? yDiff < y0 : yDiff > y0)) {
|
|
340
|
+
yDiff = y0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const points = [
|
|
344
|
+
[xValue, yValue],
|
|
345
|
+
[xDiff, yDiff]
|
|
346
|
+
];
|
|
347
|
+
|
|
348
|
+
isRotated && points.forEach(v => v.reverse());
|
|
271
349
|
|
|
272
350
|
return generateM(points);
|
|
273
351
|
};
|
|
@@ -276,6 +354,16 @@ export default {
|
|
|
276
354
|
const axisType = {x: $$.axis.getAxisType("x"), y: $$.axis.getAxisType("y")};
|
|
277
355
|
let path = "";
|
|
278
356
|
|
|
357
|
+
// clone the line path to be used to get length value
|
|
358
|
+
const target = $$.$el.line.filter(({id}) => id === d[0].id);
|
|
359
|
+
const tempNode = target.clone().style("display", "none");
|
|
360
|
+
const getLength = (node, path) => node.attr("d", path).node().getTotalLength();
|
|
361
|
+
const dashArray = {
|
|
362
|
+
dash: <string[]>[],
|
|
363
|
+
lastLength: 0
|
|
364
|
+
};
|
|
365
|
+
let isLastX = false;
|
|
366
|
+
|
|
279
367
|
for (let i = 0, data; (data = d[i]); i++) {
|
|
280
368
|
const prevData = d[i - 1];
|
|
281
369
|
const hasPrevData = prevData && isValue(prevData.value);
|
|
@@ -290,34 +378,75 @@ export default {
|
|
|
290
378
|
if (isUndefined(regions) || !style || !hasPrevData) {
|
|
291
379
|
path += `${i && hasPrevData ? "L" : "M"}${xValue(data)},${yValue(data)}`;
|
|
292
380
|
} else if (hasPrevData) {
|
|
293
|
-
|
|
294
|
-
style = style.dasharray.split(" ");
|
|
295
|
-
} catch (e) {
|
|
296
|
-
style = dasharray.split(" ");
|
|
297
|
-
}
|
|
381
|
+
style = (style?.dasharray || dasharray).split(" ").map(Number);
|
|
298
382
|
|
|
299
383
|
// Draw with region // TODO: Fix for horizotal charts
|
|
300
384
|
xp = getScale(axisType.x, prevData.x, data.x);
|
|
301
385
|
yp = getScale(axisType.y, prevData.value, data.value);
|
|
302
386
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
387
|
+
// when it contains null data, dash can't be applied with style
|
|
388
|
+
if (hasNullDataValue) {
|
|
389
|
+
const dx = x(data.x) - x(prevData.x);
|
|
390
|
+
const dy = y(data.value) - y(prevData.value);
|
|
391
|
+
const dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
|
306
392
|
|
|
307
|
-
|
|
308
|
-
|
|
393
|
+
diff = style[0] / dd; // dash
|
|
394
|
+
diffx2 = diff * style[1]; // gap
|
|
309
395
|
|
|
310
|
-
|
|
311
|
-
|
|
396
|
+
for (let j = diff; j <= 1; j += diffx2) {
|
|
397
|
+
path += sWithRegion(prevData, data, j, diff);
|
|
312
398
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
399
|
+
// to make sure correct line drawing
|
|
400
|
+
if (j + diffx2 >= 1) {
|
|
401
|
+
path += sWithRegion(prevData, data, 1, 0);
|
|
402
|
+
}
|
|
316
403
|
}
|
|
404
|
+
} else {
|
|
405
|
+
let points = <number[][]>[];
|
|
406
|
+
isLastX = data.x === d[d.length - 1].x;
|
|
407
|
+
|
|
408
|
+
if (isTimeSeries) {
|
|
409
|
+
const x0 = +prevData.x;
|
|
410
|
+
const xv0 = new Date(x0);
|
|
411
|
+
const xv1 = new Date(x0 + (+data.x - x0));
|
|
412
|
+
|
|
413
|
+
points = [
|
|
414
|
+
[x(xv0), y(yp(0))], // M
|
|
415
|
+
[x(xv1), y(yp(1))] // L
|
|
416
|
+
];
|
|
417
|
+
} else {
|
|
418
|
+
points = [
|
|
419
|
+
[x(xp(0)), y(yp(0))], // M
|
|
420
|
+
[x(xp(1)), y(yp(1))] // L
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
isRotated && points.forEach(v => v.reverse());
|
|
425
|
+
|
|
426
|
+
const startLength = getLength(tempNode, path);
|
|
427
|
+
const endLength = getLength(tempNode, path += `L${points[1].join(",")}`);
|
|
428
|
+
|
|
429
|
+
const strokeDashArray = getStrokeDashArray(
|
|
430
|
+
startLength - dashArray.lastLength,
|
|
431
|
+
endLength - dashArray.lastLength,
|
|
432
|
+
style,
|
|
433
|
+
isLastX
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
dashArray.lastLength += strokeDashArray.length;
|
|
437
|
+
dashArray.dash.push(strokeDashArray.dash);
|
|
317
438
|
}
|
|
318
439
|
}
|
|
319
440
|
}
|
|
320
441
|
|
|
442
|
+
if (dashArray.dash.length) {
|
|
443
|
+
// if not last x tick, then should draw rest of path that is not drawed yet
|
|
444
|
+
!isLastX && dashArray.dash.push(getLength(tempNode, path));
|
|
445
|
+
|
|
446
|
+
tempNode.remove();
|
|
447
|
+
target.attr("stroke-dasharray", dashArray.dash.join(" "));
|
|
448
|
+
}
|
|
449
|
+
|
|
321
450
|
return path;
|
|
322
451
|
},
|
|
323
452
|
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
getPointer,
|
|
31
31
|
getRectSegList,
|
|
32
32
|
getUnique,
|
|
33
|
+
isFunction,
|
|
33
34
|
isNumber,
|
|
34
35
|
isObjectType,
|
|
35
36
|
isUndefined,
|
|
@@ -441,7 +442,7 @@ export default {
|
|
|
441
442
|
|
|
442
443
|
getBarW(type, axis, targetsNum: number): number | IOffset {
|
|
443
444
|
const $$ = this;
|
|
444
|
-
const {config, org, scale} = $$;
|
|
445
|
+
const {config, org, scale, state} = $$;
|
|
445
446
|
const maxDataCount = $$.getMaxDataCount();
|
|
446
447
|
const isGrouped = type === "bar" && config.data_groups?.length;
|
|
447
448
|
const configName = `${type}_width`;
|
|
@@ -467,9 +468,11 @@ export default {
|
|
|
467
468
|
const width = id ? config[configName][id] : config[configName];
|
|
468
469
|
const ratio = id ? width.ratio : config[`${configName}_ratio`];
|
|
469
470
|
const max = id ? width.max : config[`${configName}_max`];
|
|
470
|
-
const w = isNumber(width) ?
|
|
471
|
-
width
|
|
472
|
-
|
|
471
|
+
const w = isNumber(width) ? width : (
|
|
472
|
+
isFunction(width) ?
|
|
473
|
+
width.call($$, state.width, targetsNum, maxDataCount) :
|
|
474
|
+
(targetsNum ? (tickInterval * ratio) / targetsNum : 0)
|
|
475
|
+
);
|
|
473
476
|
|
|
474
477
|
return max && w > max ? max : w;
|
|
475
478
|
};
|
|
@@ -531,7 +534,7 @@ export default {
|
|
|
531
534
|
isWithin = false;
|
|
532
535
|
} else if ($$.hasValidPointType?.(that.nodeName)) {
|
|
533
536
|
isWithin = $$.isStepType(d) ?
|
|
534
|
-
$$.isWithinStep(that, $$.getYScaleById(d.id)(d
|
|
537
|
+
$$.isWithinStep(that, $$.getYScaleById(d.id)($$.getBaseValue(d))) :
|
|
535
538
|
$$.isWithinCircle(
|
|
536
539
|
that,
|
|
537
540
|
$$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0
|
|
@@ -6,6 +6,19 @@
|
|
|
6
6
|
* y2 Axis config options
|
|
7
7
|
*/
|
|
8
8
|
export default {
|
|
9
|
+
/**
|
|
10
|
+
* Set clip-path attribute for y2 axis element
|
|
11
|
+
* - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
|
|
12
|
+
* @name axis․y2․clipPath
|
|
13
|
+
* @memberof Options
|
|
14
|
+
* @type {boolean}
|
|
15
|
+
* @default true
|
|
16
|
+
* @example
|
|
17
|
+
* // don't set 'clip-path' attribute
|
|
18
|
+
* clipPath: false
|
|
19
|
+
*/
|
|
20
|
+
axis_y2_clipPath: true,
|
|
21
|
+
|
|
9
22
|
/**
|
|
10
23
|
* Show or hide y2 axis.
|
|
11
24
|
* - **NOTE**:
|
|
@@ -68,7 +68,8 @@ export default {
|
|
|
68
68
|
* - rectangle
|
|
69
69
|
* @property {boolean} [legend.format] Set formatter function for legend text.
|
|
70
70
|
* The argument:<br>
|
|
71
|
-
* - `id`:
|
|
71
|
+
* - `id`: Legend text value. When `data.names` is specified, will pass from it, otherwise will pass data id.
|
|
72
|
+
* - `dataId`: When `data.names` specified, will pass the original data id. Otherwise will be undefined.
|
|
72
73
|
* @property {boolean} [legend.tooltip=false] Show full legend text value using system tooltip(via `<title>` element).
|
|
73
74
|
* @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
|
|
74
75
|
* @see [Demo: format](https://naver.github.io/billboard.js/demo/#Legend.LegendFormat)
|
|
@@ -134,7 +135,7 @@ export default {
|
|
|
134
135
|
* r: 10
|
|
135
136
|
* }
|
|
136
137
|
* },
|
|
137
|
-
* format: function(id) {
|
|
138
|
+
* format: function(id, dataId) {
|
|
138
139
|
* // set ellipsis string when length is > 5
|
|
139
140
|
* // to get full legend value, combine with 'legend.tooltip=true'
|
|
140
141
|
* if (id.length > 5) {
|
|
@@ -108,8 +108,12 @@ export default {
|
|
|
108
108
|
* - The object type should be as:
|
|
109
109
|
* - start {number}: Start data point number. If not set, the start will be the first data point.
|
|
110
110
|
* - [end] {number}: End data point number. If not set, the end will be the last data point.
|
|
111
|
-
* - [style.dasharray="2 2"] {
|
|
112
|
-
* - **NOTE:**
|
|
111
|
+
* - [style.dasharray="2 2"] {string}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
|
|
112
|
+
* - **NOTE:**
|
|
113
|
+
* - Supports only line type.
|
|
114
|
+
* - `start` and `end` values should be in the exact x value range.
|
|
115
|
+
* - Dashes will be applied using `stroke-dasharray` css property when data doesn't contain nullish value(or nullish value with `line.connectNull=true` set).
|
|
116
|
+
* - Dashes will be applied via path command when data contains nullish value.
|
|
113
117
|
* @name data․regions
|
|
114
118
|
* @memberof Options
|
|
115
119
|
* @type {object}
|