billboard.js 3.9.3 → 3.10.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 -2
- package/dist/billboard.css +2 -2
- package/dist/billboard.js +2687 -2541
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +3493 -3331
- package/dist/billboard.pkgd.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +15 -15
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +215 -196
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +244 -239
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +184 -164
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +170 -151
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/{billboardjs-plugin-bubblecompare.js → billboardjs-plugin-bubblecompare.pkgd.js} +664 -634
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-sparkline.js → billboardjs-plugin-sparkline.pkgd.js} +861 -812
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-stanford.js → billboardjs-plugin-stanford.pkgd.js} +926 -892
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-tableview.js → billboardjs-plugin-tableview.pkgd.js} +830 -780
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-textoverlap.js → billboardjs-plugin-textoverlap.pkgd.js} +929 -889
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +12 -0
- package/dist/theme/dark.css +5 -4
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +5 -4
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +5 -4
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +5 -4
- package/dist/theme/insight.min.css +2 -2
- package/dist-esm/billboard.js +591 -462
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +13 -7
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +21 -28
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +17 -11
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +13 -7
- package/package.json +27 -27
- package/src/Chart/api/axis.ts +4 -0
- package/src/Chart/api/category.ts +8 -4
- package/src/Chart/api/export.ts +1 -2
- package/src/Chart/api/subchart.ts +162 -89
- package/src/Chart/api/zoom.ts +69 -79
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +0 -8
- package/src/ChartInternal/data/IData.ts +4 -1
- package/src/ChartInternal/data/convert.helper.ts +1 -15
- package/src/ChartInternal/data/data.ts +8 -2
- package/src/ChartInternal/interactions/eventrect.ts +0 -1
- package/src/ChartInternal/interactions/flow.ts +1 -7
- package/src/ChartInternal/interactions/interaction.ts +10 -4
- package/src/ChartInternal/interactions/subchart.ts +36 -30
- package/src/ChartInternal/interactions/zoom.ts +13 -3
- package/src/ChartInternal/internals/category.ts +2 -2
- package/src/ChartInternal/internals/clip.ts +4 -4
- package/src/ChartInternal/internals/domain.ts +46 -10
- package/src/ChartInternal/internals/grid.ts +57 -86
- package/src/ChartInternal/internals/redraw.ts +0 -5
- package/src/ChartInternal/internals/region.ts +35 -12
- package/src/ChartInternal/internals/text.ts +1 -26
- package/src/ChartInternal/internals/title.ts +10 -48
- package/src/ChartInternal/internals/tooltip.ts +47 -51
- package/src/ChartInternal/shape/arc.ts +2 -2
- package/src/ChartInternal/shape/candlestick.ts +2 -17
- package/src/ChartInternal/shape/shape.ts +50 -4
- package/src/ChartInternal/shape/treemap.ts +2 -2
- package/src/Plugin/bubblecompare/index.ts +1 -1
- package/src/Plugin/stanford/Elements.ts +10 -2
- package/src/Plugin/stanford/index.ts +1 -24
- package/src/Plugin/tableview/index.ts +2 -2
- package/src/config/Options/axis/x.ts +1 -0
- package/src/config/Options/common/main.ts +12 -2
- package/src/config/Options/common/tooltip.ts +10 -10
- package/src/config/Options/data/axis.ts +3 -1
- package/src/config/Options/data/data.ts +10 -2
- package/src/config/Store/State.ts +3 -0
- package/src/module/Cache.ts +7 -5
- package/src/module/browser.ts +34 -14
- package/src/module/util.ts +8 -4
- package/src/module/worker.ts +24 -13
- package/src/scss/billboard.scss +4 -2
- package/src/scss/theme/dark.scss +4 -2
- package/src/scss/theme/datalab.scss +4 -2
- package/src/scss/theme/graph.scss +4 -2
- package/src/scss/theme/insight.scss +4 -2
- package/types/chart.d.ts +11 -0
- package/types/options.d.ts +3 -3
- package/types/types.d.ts +15 -1
|
@@ -2,99 +2,172 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
+
import {extend, parseDate} from "../../module/util";
|
|
5
6
|
import {$COMMON} from "../../config/classes";
|
|
7
|
+
import type {TDomain} from "../../ChartInternal/data/IData";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!show) {
|
|
38
|
-
// unbind zoom event bound to chart rect area
|
|
39
|
-
$$.unbindZoomEvent();
|
|
40
|
-
|
|
41
|
-
config.subchart_show = !show;
|
|
42
|
-
!subchart.main && $$.initSubchart();
|
|
43
|
-
|
|
44
|
-
let $target = subchart.main.selectAll(`.${$COMMON.target}`);
|
|
45
|
-
|
|
46
|
-
// need to cover when new data has been loaded
|
|
47
|
-
if ($$.data.targets.length !== $target.size()) {
|
|
48
|
-
$$.updateSizes();
|
|
49
|
-
$$.updateTargetsForSubchart($$.data.targets);
|
|
50
|
-
|
|
51
|
-
$target = subchart.main?.selectAll(`.${$COMMON.target}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
$target?.style("opacity", null);
|
|
55
|
-
subchart.main?.style("display", null);
|
|
56
|
-
|
|
57
|
-
this.resize();
|
|
9
|
+
/**
|
|
10
|
+
* Select subchart by giving x domain range.
|
|
11
|
+
* - **ℹ️ NOTE:**
|
|
12
|
+
* - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
|
|
13
|
+
* @function subchart
|
|
14
|
+
* @instance
|
|
15
|
+
* @memberof Chart
|
|
16
|
+
* @param {Array} domainValue If domain range is given, the subchart will be seleted to the given domain. If no argument is given, the current subchart selection domain will be returned.
|
|
17
|
+
* @returns {Array} domain value in array
|
|
18
|
+
* @example
|
|
19
|
+
* // Specify domain for subchart selection
|
|
20
|
+
* chart.subchart([1, 2]);
|
|
21
|
+
*
|
|
22
|
+
* // Get the current subchart selection domain range
|
|
23
|
+
* // Domain value may not be exact returning approximately values.
|
|
24
|
+
* chart.subchart();
|
|
25
|
+
*/
|
|
26
|
+
// NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
|
|
27
|
+
const subchart = function<T = TDomain[]>(domainValue?: T): T | undefined {
|
|
28
|
+
const $$ = this.internal;
|
|
29
|
+
const {axis, brush, config, scale: {x, subX}, state} = $$;
|
|
30
|
+
let domain;
|
|
31
|
+
|
|
32
|
+
if (config.subchart_show) {
|
|
33
|
+
domain = domainValue;
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(domain)) {
|
|
36
|
+
if (axis.isTimeSeries()) {
|
|
37
|
+
domain = domain.map(x => parseDate.bind($$)(x));
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (config.subchart_show && main?.style("display") !== "none") {
|
|
75
|
-
config.subchart_show = false;
|
|
76
|
-
main.style("display", "none");
|
|
77
|
-
|
|
78
|
-
this.resize();
|
|
39
|
+
|
|
40
|
+
const isWithinRange = $$.withinRange(
|
|
41
|
+
domain,
|
|
42
|
+
$$.getZoomDomain("subX", true),
|
|
43
|
+
$$.getZoomDomain("subX")
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
if (isWithinRange) {
|
|
47
|
+
state.domain = domain;
|
|
48
|
+
|
|
49
|
+
brush.move(
|
|
50
|
+
brush.getSelection(),
|
|
51
|
+
domain.map(subX)
|
|
52
|
+
);
|
|
79
53
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Toggle the visiblity of subchart
|
|
84
|
-
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
85
|
-
* @function subchart․toggle
|
|
86
|
-
* @instance
|
|
87
|
-
* @memberof Chart
|
|
88
|
-
* @example
|
|
89
|
-
* // When subchart is hidden, will be shown
|
|
90
|
-
* // When subchart is shown, will be hidden
|
|
91
|
-
* chart.subchart.toggle();
|
|
92
|
-
*/
|
|
93
|
-
toggle(): void {
|
|
94
|
-
const $$ = this.internal;
|
|
95
|
-
const {config} = $$;
|
|
96
|
-
|
|
97
|
-
this.subchart[config.subchart_show ? "hide" : "show"]();
|
|
54
|
+
} else {
|
|
55
|
+
domain = state.domain ?? x.orgDomain();
|
|
98
56
|
}
|
|
99
57
|
}
|
|
58
|
+
|
|
59
|
+
return domain as T;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
extend(subchart, {
|
|
63
|
+
/**
|
|
64
|
+
* Show subchart
|
|
65
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
66
|
+
* @function subchart․show
|
|
67
|
+
* @instance
|
|
68
|
+
* @memberof Chart
|
|
69
|
+
* @example
|
|
70
|
+
* // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
|
|
71
|
+
* import {subchart} from "billboard.js";
|
|
72
|
+
*
|
|
73
|
+
* const chart = bb.generate({
|
|
74
|
+
* ...
|
|
75
|
+
* subchart: {
|
|
76
|
+
* // need to be instantiated by calling 'subchart()'
|
|
77
|
+
* enabled: subchart()
|
|
78
|
+
*
|
|
79
|
+
* // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
|
|
80
|
+
* enabled: !subchart()
|
|
81
|
+
* }
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* chart.subchart.show();
|
|
85
|
+
*/
|
|
86
|
+
show(): void {
|
|
87
|
+
const $$ = this.internal;
|
|
88
|
+
const {$el: {subchart}, config} = $$;
|
|
89
|
+
const show = config.subchart_show;
|
|
90
|
+
|
|
91
|
+
if (!show) {
|
|
92
|
+
// unbind zoom event bound to chart rect area
|
|
93
|
+
$$.unbindZoomEvent();
|
|
94
|
+
|
|
95
|
+
config.subchart_show = !show;
|
|
96
|
+
!subchart.main && $$.initSubchart();
|
|
97
|
+
|
|
98
|
+
let $target = subchart.main.selectAll(`.${$COMMON.target}`);
|
|
99
|
+
|
|
100
|
+
// need to cover when new data has been loaded
|
|
101
|
+
if ($$.data.targets.length !== $target.size()) {
|
|
102
|
+
$$.updateSizes();
|
|
103
|
+
$$.updateTargetsForSubchart($$.data.targets);
|
|
104
|
+
|
|
105
|
+
$target = subchart.main?.selectAll(`.${$COMMON.target}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
$target?.style("opacity", null);
|
|
109
|
+
subchart.main?.style("display", null);
|
|
110
|
+
|
|
111
|
+
this.resize();
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Hide generated subchart
|
|
117
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
118
|
+
* @function subchart․hide
|
|
119
|
+
* @instance
|
|
120
|
+
* @memberof Chart
|
|
121
|
+
* @example
|
|
122
|
+
* chart.subchart.hide();
|
|
123
|
+
*/
|
|
124
|
+
hide(): void {
|
|
125
|
+
const $$ = this.internal;
|
|
126
|
+
const {$el: {subchart: {main}}, config} = $$;
|
|
127
|
+
|
|
128
|
+
if (config.subchart_show && main?.style("display") !== "none") {
|
|
129
|
+
config.subchart_show = false;
|
|
130
|
+
main.style("display", "none");
|
|
131
|
+
|
|
132
|
+
this.resize();
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Toggle the visiblity of subchart
|
|
138
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
139
|
+
* @function subchart․toggle
|
|
140
|
+
* @instance
|
|
141
|
+
* @memberof Chart
|
|
142
|
+
* @example
|
|
143
|
+
* // When subchart is hidden, will be shown
|
|
144
|
+
* // When subchart is shown, will be hidden
|
|
145
|
+
* chart.subchart.toggle();
|
|
146
|
+
*/
|
|
147
|
+
toggle(): void {
|
|
148
|
+
const $$ = this.internal;
|
|
149
|
+
const {config} = $$;
|
|
150
|
+
|
|
151
|
+
this.subchart[config.subchart_show ? "hide" : "show"]();
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Reset subchart selection
|
|
156
|
+
* @function subchart․reset
|
|
157
|
+
* @instance
|
|
158
|
+
* @memberof Chart
|
|
159
|
+
* @example
|
|
160
|
+
* // Reset subchart selection
|
|
161
|
+
* chart.subchart.reset();
|
|
162
|
+
*/
|
|
163
|
+
reset(): void {
|
|
164
|
+
const $$ = this.internal;
|
|
165
|
+
const {brush} = $$;
|
|
166
|
+
|
|
167
|
+
brush.clear(brush.getSelection());
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
export default {
|
|
172
|
+
subchart
|
|
100
173
|
};
|
package/src/Chart/api/zoom.ts
CHANGED
|
@@ -4,35 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {zoomIdentity as d3ZoomIdentity, zoomTransform as d3ZoomTransform} from "d3-zoom";
|
|
6
6
|
import {extend, getMinMax, isDefined, isObject, parseDate} from "../../module/util";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Check if the given domain is within zoom range
|
|
10
|
-
* @param {Array} domain Target domain value
|
|
11
|
-
* @param {Array} current Current zoom domain value
|
|
12
|
-
* @param {Array} range Zoom range value
|
|
13
|
-
* @param {boolean} isInverted Whether the axis is inverted or not
|
|
14
|
-
* @returns {boolean}
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
function withinRange(
|
|
18
|
-
domain: (number|Date)[], current, range: number[], isInverted = false
|
|
19
|
-
): boolean {
|
|
20
|
-
const [min, max] = range;
|
|
21
|
-
|
|
22
|
-
return domain.every((v, i) => (
|
|
23
|
-
i === 0 ? (
|
|
24
|
-
isInverted ? +v <= min : +v >= min
|
|
25
|
-
) : (
|
|
26
|
-
isInverted ? +v >= max : +v <= max
|
|
27
|
-
)
|
|
28
|
-
) && !(domain.every((v, i) => v === current[i])));
|
|
29
|
-
}
|
|
7
|
+
import type {TDomainRange} from "../../ChartInternal/data/IData";
|
|
30
8
|
|
|
31
9
|
/**
|
|
32
10
|
* Zoom by giving x domain range.
|
|
33
|
-
* -
|
|
11
|
+
* - **ℹ️ NOTE:**
|
|
34
12
|
* - For `wheel` type zoom, the minimum zoom range will be set as the given domain range. To get the initial state, [.unzoom()](#unzoom) should be called.
|
|
35
13
|
* - To be used [zoom.enabled](Options.html#.zoom) option should be set as `truthy`.
|
|
14
|
+
* - When x axis type is `category`, domain range should be specified as index numbers.
|
|
15
|
+
* - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
|
|
36
16
|
* @function zoom
|
|
37
17
|
* @instance
|
|
38
18
|
* @memberof Chart
|
|
@@ -42,72 +22,80 @@ function withinRange(
|
|
|
42
22
|
* // Zoom to specified domain range
|
|
43
23
|
* chart.zoom([10, 20]);
|
|
44
24
|
*
|
|
45
|
-
* // For timeseries, the domain value can be string, but the format should match with the 'data.xFormat' option.
|
|
25
|
+
* // For timeseries x axis, the domain value can be string, but the format should match with the 'data.xFormat' option.
|
|
46
26
|
* chart.zoom(["2021-02-03", "2021-02-08"]);
|
|
47
27
|
*
|
|
28
|
+
* // For category x axis, the domain value should be index number.
|
|
29
|
+
* chart.zoom([0, 3]);
|
|
30
|
+
*
|
|
48
31
|
* // Get the current zoomed domain range
|
|
32
|
+
* // Domain value may not be exact returning approximately values.
|
|
49
33
|
* chart.zoom();
|
|
50
34
|
*/
|
|
51
|
-
|
|
35
|
+
// NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
|
|
36
|
+
const zoom = function<T = TDomainRange>(domainValue?: T): T | undefined {
|
|
52
37
|
const $$ = this.internal;
|
|
53
|
-
const {$el, axis, config, org, scale} = $$;
|
|
38
|
+
const {$el, axis, config, org, scale, state} = $$;
|
|
54
39
|
const isRotated = config.axis_rotated;
|
|
55
|
-
const isInverted = config.axis_x_inverted;
|
|
56
40
|
const isCategorized = axis.isCategorized();
|
|
57
|
-
let domain
|
|
41
|
+
let domain;
|
|
58
42
|
|
|
59
|
-
if (config.zoom_enabled
|
|
60
|
-
|
|
61
|
-
domain = domain.map(x => parseDate.bind($$)(x));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const isWithinRange = withinRange(
|
|
65
|
-
domain as (number|Date)[],
|
|
66
|
-
$$.getZoomDomain(true),
|
|
67
|
-
$$.getZoomDomain(),
|
|
68
|
-
isInverted
|
|
69
|
-
);
|
|
43
|
+
if (config.zoom_enabled) {
|
|
44
|
+
domain = domainValue;
|
|
70
45
|
|
|
71
|
-
if (
|
|
72
|
-
if (
|
|
73
|
-
domain = domain.map(
|
|
46
|
+
if (Array.isArray(domain)) {
|
|
47
|
+
if (axis.isTimeSeries()) {
|
|
48
|
+
domain = domain.map(x => parseDate.bind($$)(x));
|
|
74
49
|
}
|
|
75
50
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
51
|
+
const isWithinRange = $$.withinRange(
|
|
52
|
+
domain,
|
|
53
|
+
$$.getZoomDomain("zoom", true),
|
|
54
|
+
$$.getZoomDomain("zoom")
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (isWithinRange) {
|
|
58
|
+
state.domain = domain;
|
|
59
|
+
|
|
60
|
+
if (isCategorized) {
|
|
61
|
+
domain = domain.map((v, i) => Number(v) + (i === 0 ? 0 : 1));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// hide any possible tooltip show before the zoom
|
|
65
|
+
$$.api.tooltip.hide();
|
|
66
|
+
|
|
67
|
+
if (config.subchart_show) {
|
|
68
|
+
const x = scale.zoom || scale.x;
|
|
69
|
+
|
|
70
|
+
$$.brush.getSelection().call($$.brush.move, domain.map(x));
|
|
71
|
+
// resultDomain = domain;
|
|
72
|
+
} else {
|
|
73
|
+
// in case of 'config.zoom_rescale=true', use org.xScale
|
|
74
|
+
const x = isCategorized ? scale.x.orgScale() : (org.xScale || scale.x);
|
|
75
|
+
|
|
76
|
+
// Get transform from given domain value
|
|
77
|
+
// https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
|
|
78
|
+
const translate = [-x(domain[0]), 0];
|
|
79
|
+
const transform = d3ZoomIdentity
|
|
80
|
+
.scale(x.range()[1] / (
|
|
81
|
+
x(domain[1]) - x(domain[0])
|
|
82
|
+
))
|
|
83
|
+
.translate(
|
|
84
|
+
...(isRotated ? translate.reverse() : translate) as [number, number]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
$el.eventRect
|
|
88
|
+
.call($$.zoom.transform, transform);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
$$.setZoomResetButton();
|
|
101
92
|
}
|
|
102
|
-
|
|
103
|
-
$$.
|
|
93
|
+
} else {
|
|
94
|
+
domain = $$.zoom.getDomain();
|
|
104
95
|
}
|
|
105
|
-
} else {
|
|
106
|
-
domain = scale.zoom ?
|
|
107
|
-
scale.zoom.domain() : scale.x.orgDomain();
|
|
108
96
|
}
|
|
109
97
|
|
|
110
|
-
return domain
|
|
98
|
+
return state.domain ?? domain;
|
|
111
99
|
};
|
|
112
100
|
|
|
113
101
|
extend(zoom, {
|
|
@@ -129,7 +117,7 @@ extend(zoom, {
|
|
|
129
117
|
* // Disable zooming
|
|
130
118
|
* chart.zoom.enable(false);
|
|
131
119
|
*/
|
|
132
|
-
enable
|
|
120
|
+
enable(enabled: boolean | "wheel" | "drag" | any): void {
|
|
133
121
|
const $$ = this.internal;
|
|
134
122
|
const {config} = $$;
|
|
135
123
|
|
|
@@ -160,7 +148,7 @@ extend(zoom, {
|
|
|
160
148
|
* // Set maximum range value
|
|
161
149
|
* chart.zoom.max(20);
|
|
162
150
|
*/
|
|
163
|
-
max
|
|
151
|
+
max(max?: number): number {
|
|
164
152
|
const $$ = this.internal;
|
|
165
153
|
const {config, org: {xDomain}} = $$;
|
|
166
154
|
|
|
@@ -182,7 +170,7 @@ extend(zoom, {
|
|
|
182
170
|
* // Set minimum range value
|
|
183
171
|
* chart.zoom.min(-1);
|
|
184
172
|
*/
|
|
185
|
-
min
|
|
173
|
+
min(min?: number): number {
|
|
186
174
|
const $$ = this.internal;
|
|
187
175
|
const {config, org: {xDomain}} = $$;
|
|
188
176
|
|
|
@@ -210,7 +198,7 @@ extend(zoom, {
|
|
|
210
198
|
* max: 100
|
|
211
199
|
* });
|
|
212
200
|
*/
|
|
213
|
-
range
|
|
201
|
+
range(range): {min: (number|undefined)[], max: (number|undefined)[]} {
|
|
214
202
|
const zoom = this.zoom;
|
|
215
203
|
|
|
216
204
|
if (isObject(range)) {
|
|
@@ -241,7 +229,7 @@ export default {
|
|
|
241
229
|
*/
|
|
242
230
|
unzoom(): void {
|
|
243
231
|
const $$ = this.internal;
|
|
244
|
-
const {config, $el: {eventRect, zoomResetBtn}} = $$;
|
|
232
|
+
const {config, $el: {eventRect, zoomResetBtn}, state} = $$;
|
|
245
233
|
|
|
246
234
|
if ($$.scale.zoom) {
|
|
247
235
|
config.subchart_show ?
|
|
@@ -255,6 +243,8 @@ export default {
|
|
|
255
243
|
if (d3ZoomTransform(eventRect.node()) !== d3ZoomIdentity) {
|
|
256
244
|
$$.zoom.transform(eventRect, d3ZoomIdentity);
|
|
257
245
|
}
|
|
246
|
+
|
|
247
|
+
state.domain = undefined;
|
|
258
248
|
}
|
|
259
249
|
}
|
|
260
250
|
};
|
|
@@ -133,14 +133,6 @@ export default class AxisRendererHelper {
|
|
|
133
133
|
|
|
134
134
|
return r;
|
|
135
135
|
});
|
|
136
|
-
} else {
|
|
137
|
-
for (let i = Math.ceil(start); i < end; i++) {
|
|
138
|
-
ticks.push(i);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (ticks.length > 0 && ticks[0] > 0) {
|
|
142
|
-
ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
|
|
143
|
-
}
|
|
144
136
|
}
|
|
145
137
|
|
|
146
138
|
return ticks;
|
|
@@ -10,6 +10,9 @@ type TDataRow = {
|
|
|
10
10
|
name?: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
export type TDomain = Date | number;
|
|
14
|
+
export type TDomainRange = [TDomain, TDomain];
|
|
15
|
+
|
|
13
16
|
export interface ITreemapData {
|
|
14
17
|
name: string;
|
|
15
18
|
id?: string; // for compatibility
|
|
@@ -19,7 +22,7 @@ export interface ITreemapData {
|
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export interface IDataRow extends TDataRow {
|
|
22
|
-
x:
|
|
25
|
+
x: TDomain & string;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export interface IDataPoint extends IDataRow {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
tsvParseRows as d3TsvParseRows,
|
|
12
12
|
} from "d3-dsv";
|
|
13
13
|
|
|
14
|
-
export {columns, json,
|
|
14
|
+
export {columns, json, rows, url, csv, tsv};
|
|
15
15
|
|
|
16
16
|
/***** Functions to be executed on Web Worker *****
|
|
17
17
|
* NOTE: Don't allowed to use
|
|
@@ -146,20 +146,6 @@ function json(json, keysParam) {
|
|
|
146
146
|
return data;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
function jsonTreemap(json) {
|
|
150
|
-
const convertKey = v => {
|
|
151
|
-
if (v.children) {
|
|
152
|
-
v.children.forEach(convertKey);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
v.name = v.id;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
json.forEach(convertKey);
|
|
159
|
-
|
|
160
|
-
return json;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
149
|
/***** Functions can't be executed on Web Worker *****/
|
|
164
150
|
/**
|
|
165
151
|
* Convert URL data
|
|
@@ -46,7 +46,13 @@ export default {
|
|
|
46
46
|
return !!(config.data_stack_normalize && config.data_groups.length);
|
|
47
47
|
},
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Check if given id is grouped data or has grouped data
|
|
51
|
+
* @param {string} id Data id value
|
|
52
|
+
* @returns {boolean} is grouped data or has grouped data
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
isGrouped(id?: string): boolean {
|
|
50
56
|
const groups = this.config.data_groups;
|
|
51
57
|
|
|
52
58
|
return id ?
|
|
@@ -392,7 +398,7 @@ export default {
|
|
|
392
398
|
* @private
|
|
393
399
|
*/
|
|
394
400
|
getMaxDataCount(): number {
|
|
395
|
-
return Math.max(...this.data.targets.map(t => t.values.length));
|
|
401
|
+
return Math.max(...this.data.targets.map(t => t.values.length), 0);
|
|
396
402
|
},
|
|
397
403
|
|
|
398
404
|
getMaxDataCountTarget() {
|
|
@@ -150,9 +150,6 @@ export default {
|
|
|
150
150
|
} else if (v === "gridLines.x") {
|
|
151
151
|
n.attr("x1", isRotated ? 0 : xv)
|
|
152
152
|
.attr("x2", isRotated ? state.width : xv);
|
|
153
|
-
} else if (v === "gridLines.x") {
|
|
154
|
-
n.select("line").attr("x1", isRotated ? 0 : xv)
|
|
155
|
-
.attr("x2", isRotated ? state.width : xv);
|
|
156
153
|
|
|
157
154
|
n.select("text")
|
|
158
155
|
.attr("x", isRotated ? state.width : 0)
|
|
@@ -170,10 +167,7 @@ export default {
|
|
|
170
167
|
const xFunc = d => cx(d) - config.point_r;
|
|
171
168
|
const yFunc = d => cy(d) - config.point_r;
|
|
172
169
|
|
|
173
|
-
n.attr("x", xFunc)
|
|
174
|
-
.attr("y", yFunc)
|
|
175
|
-
.attr("cx", cx) // when pattern is used, it possibly contain 'circle' also.
|
|
176
|
-
.attr("cy", cy);
|
|
170
|
+
n.attr("x", xFunc).attr("y", yFunc);
|
|
177
171
|
}
|
|
178
172
|
} else if (v === "region.list") {
|
|
179
173
|
n.select("rect").filter($$.isRegionOnX)
|
|
@@ -166,7 +166,7 @@ export default {
|
|
|
166
166
|
* @param {number} index Index of eventRect
|
|
167
167
|
* @param {Array} mouse x and y coordinate value
|
|
168
168
|
*/
|
|
169
|
-
dispatchEvent(type: string, index: number, mouse): void {
|
|
169
|
+
dispatchEvent(type: string, index: number, mouse: [number, number]): void {
|
|
170
170
|
const $$ = this;
|
|
171
171
|
const {config, state: {
|
|
172
172
|
eventReceiver, hasAxis, hasRadar, hasTreemap
|
|
@@ -185,9 +185,15 @@ export default {
|
|
|
185
185
|
if (hasAxis && !hasRadar && !isMultipleX) {
|
|
186
186
|
const coords = eventReceiver.coords[index];
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
if (coords) {
|
|
189
|
+
width = coords.w;
|
|
190
|
+
left += coords.x;
|
|
191
|
+
top += coords.y;
|
|
192
|
+
} else {
|
|
193
|
+
width = 0;
|
|
194
|
+
left = 0;
|
|
195
|
+
top = 0;
|
|
196
|
+
}
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
const x = left + (mouse ? mouse[0] : 0) + (
|