billboard.js 3.9.2 → 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.
Files changed (91) hide show
  1. package/README.md +2 -2
  2. package/dist/billboard.css +2 -2
  3. package/dist/billboard.js +2705 -2529
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +2 -2
  6. package/dist/billboard.pkgd.js +3516 -3329
  7. package/dist/billboard.pkgd.min.js +4 -4
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +15 -15
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +215 -196
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +244 -239
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +184 -164
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +170 -151
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/{billboardjs-plugin-bubblecompare.js → billboardjs-plugin-bubblecompare.pkgd.js} +667 -642
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +12 -0
  20. package/dist/plugin/pkgd/{billboardjs-plugin-sparkline.js → billboardjs-plugin-sparkline.pkgd.js} +864 -820
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +12 -0
  22. package/dist/plugin/pkgd/{billboardjs-plugin-stanford.js → billboardjs-plugin-stanford.pkgd.js} +929 -900
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -0
  24. package/dist/plugin/pkgd/{billboardjs-plugin-tableview.js → billboardjs-plugin-tableview.pkgd.js} +833 -788
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -0
  26. package/dist/plugin/pkgd/{billboardjs-plugin-textoverlap.js → billboardjs-plugin-textoverlap.pkgd.js} +932 -897
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +12 -0
  28. package/dist/theme/dark.css +5 -4
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +5 -4
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +5 -4
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +5 -4
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist-esm/billboard.js +605 -468
  37. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
  38. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +13 -7
  39. package/dist-esm/plugin/billboardjs-plugin-stanford.js +21 -28
  40. package/dist-esm/plugin/billboardjs-plugin-tableview.js +17 -11
  41. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +13 -7
  42. package/package.json +31 -31
  43. package/src/Chart/api/axis.ts +4 -0
  44. package/src/Chart/api/category.ts +8 -4
  45. package/src/Chart/api/export.ts +1 -2
  46. package/src/Chart/api/subchart.ts +162 -89
  47. package/src/Chart/api/zoom.ts +69 -79
  48. package/src/ChartInternal/Axis/AxisRendererHelper.ts +0 -8
  49. package/src/ChartInternal/data/IData.ts +4 -1
  50. package/src/ChartInternal/data/convert.helper.ts +1 -15
  51. package/src/ChartInternal/data/data.ts +8 -2
  52. package/src/ChartInternal/interactions/eventrect.ts +0 -1
  53. package/src/ChartInternal/interactions/flow.ts +1 -7
  54. package/src/ChartInternal/interactions/interaction.ts +10 -4
  55. package/src/ChartInternal/interactions/subchart.ts +36 -30
  56. package/src/ChartInternal/interactions/zoom.ts +13 -3
  57. package/src/ChartInternal/internals/category.ts +2 -2
  58. package/src/ChartInternal/internals/clip.ts +4 -4
  59. package/src/ChartInternal/internals/domain.ts +46 -10
  60. package/src/ChartInternal/internals/grid.ts +57 -86
  61. package/src/ChartInternal/internals/redraw.ts +0 -5
  62. package/src/ChartInternal/internals/region.ts +35 -12
  63. package/src/ChartInternal/internals/text.ts +1 -26
  64. package/src/ChartInternal/internals/title.ts +10 -48
  65. package/src/ChartInternal/internals/tooltip.ts +47 -51
  66. package/src/ChartInternal/shape/arc.ts +16 -6
  67. package/src/ChartInternal/shape/candlestick.ts +2 -17
  68. package/src/ChartInternal/shape/shape.ts +50 -4
  69. package/src/ChartInternal/shape/treemap.ts +2 -2
  70. package/src/Plugin/bubblecompare/index.ts +1 -1
  71. package/src/Plugin/stanford/Elements.ts +10 -2
  72. package/src/Plugin/stanford/index.ts +1 -24
  73. package/src/Plugin/tableview/index.ts +2 -2
  74. package/src/config/Options/axis/x.ts +1 -0
  75. package/src/config/Options/common/main.ts +12 -2
  76. package/src/config/Options/common/tooltip.ts +10 -10
  77. package/src/config/Options/data/axis.ts +3 -1
  78. package/src/config/Options/data/data.ts +10 -2
  79. package/src/config/Store/State.ts +3 -0
  80. package/src/module/Cache.ts +7 -5
  81. package/src/module/browser.ts +34 -14
  82. package/src/module/util.ts +8 -4
  83. package/src/module/worker.ts +24 -13
  84. package/src/scss/billboard.scss +4 -2
  85. package/src/scss/theme/dark.scss +4 -2
  86. package/src/scss/theme/datalab.scss +4 -2
  87. package/src/scss/theme/graph.scss +4 -2
  88. package/src/scss/theme/insight.scss +4 -2
  89. package/types/chart.d.ts +11 -0
  90. package/types/options.d.ts +3 -3
  91. 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
- export default {
8
- subchart: {
9
- /**
10
- * Show subchart
11
- * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
12
- * @function subchart․show
13
- * @instance
14
- * @memberof Chart
15
- * @example
16
- * // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
17
- * import {subchart} from "billboard.js";
18
- *
19
- * const chart = bb.generate({
20
- * ...
21
- * subchart: {
22
- * // need to be instantiated by calling 'subchart()'
23
- * enabled: subchart()
24
- *
25
- * // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
26
- * enabled: !subchart()
27
- * }
28
- * });
29
- *
30
- * chart.subchart.show();
31
- */
32
- show(): void {
33
- const $$ = this.internal;
34
- const {$el: {subchart}, config} = $$;
35
- const show = config.subchart_show;
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
- * Hide generated subchart
63
- * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
64
- * @function subchart․hide
65
- * @instance
66
- * @memberof Chart
67
- * @example
68
- * chart.subchart.hide();
69
- */
70
- hide(): void {
71
- const $$ = this.internal;
72
- const {$el: {subchart: {main}}, config} = $$;
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
  };
@@ -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
- * - **NOTE:**
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
- const zoom = function(domainValue?: (Date|number|string)[]): (Date|number)[]|undefined {
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 = domainValue;
41
+ let domain;
58
42
 
59
- if (config.zoom_enabled && domain) {
60
- if (axis.isTimeSeries()) {
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 (isWithinRange) {
72
- if (isCategorized) {
73
- domain = domain.map((v, i) => Number(v) + (i === 0 ? 0 : 1));
46
+ if (Array.isArray(domain)) {
47
+ if (axis.isTimeSeries()) {
48
+ domain = domain.map(x => parseDate.bind($$)(x));
74
49
  }
75
50
 
76
- // hide any possible tooltip show before the zoom
77
- $$.api.tooltip.hide();
78
-
79
- if (config.subchart_show) {
80
- const x = scale.zoom || scale.x;
81
-
82
- $$.brush.getSelection().call($$.brush.move, domain.map(x));
83
- // resultDomain = domain;
84
- } else {
85
- // in case of 'config.zoom_rescale=true', use org.xScale
86
- const x = isCategorized ? scale.x.orgScale() : (org.xScale || scale.x);
87
-
88
- // Get transform from given domain value
89
- // https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
90
- const translate = [-x(domain[0]), 0];
91
- const transform = d3ZoomIdentity
92
- .scale(x.range()[1] / (
93
- x(domain[1]) - x(domain[0])
94
- ))
95
- .translate(
96
- ...(isRotated ? translate.reverse() : translate) as [number, number]
97
- );
98
-
99
- $el.eventRect
100
- .call($$.zoom.transform, transform);
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
- $$.setZoomResetButton();
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 as (Date|number)[];
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: function(enabled: boolean | "wheel" | "drag" | any): void {
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: function(max?: number): number {
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: function(min?: number): number {
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: function(range): {min: (number|undefined)[], max: (number|undefined)[]} {
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: number | string | Date;
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, jsonTreemap, rows, url, csv, tsv};
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
- isGrouped(id) {
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() {
@@ -173,7 +173,6 @@ export default {
173
173
 
174
174
  svg.on("touchstart", event => {
175
175
  state.event = event;
176
-
177
176
  const {target} = event;
178
177
 
179
178
  if (target && target !== eventRect.node()) {
@@ -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
- width = coords.w;
189
- left += coords.x;
190
- top += coords.y;
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) + (