billboard.js 3.2.2 → 3.3.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 (52) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +230 -68
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +3196 -1856
  6. package/dist/billboard.pkgd.min.js +3 -3
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +10 -9
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +10 -9
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +12 -11
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +10 -9
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +2976 -1798
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +2985 -1806
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +2986 -1807
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +3045 -1866
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +3045 -1866
  22. package/dist/theme/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +1 -1
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +1 -1
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +1 -1
  28. package/dist-esm/billboard.js +198 -55
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  34. package/package.json +29 -29
  35. package/src/ChartInternal/ChartInternal.ts +10 -1
  36. package/src/ChartInternal/data/convert.ts +1 -1
  37. package/src/ChartInternal/data/data.ts +27 -10
  38. package/src/ChartInternal/internals/domain.ts +4 -2
  39. package/src/ChartInternal/internals/scale.ts +3 -2
  40. package/src/ChartInternal/internals/size.ts +32 -1
  41. package/src/ChartInternal/internals/text.ts +2 -2
  42. package/src/ChartInternal/internals/tooltip.ts +4 -0
  43. package/src/ChartInternal/shape/bar.ts +78 -33
  44. package/src/ChartInternal/shape/shape.ts +33 -2
  45. package/src/Plugin/tableview/index.ts +1 -1
  46. package/src/config/Options/axis/x.ts +2 -2
  47. package/src/config/Options/common/main.ts +11 -1
  48. package/src/config/Options/data/data.ts +22 -0
  49. package/src/config/Options/shape/bar.ts +1 -2
  50. package/src/module/util.ts +16 -15
  51. package/types/options.d.ts +8 -1
  52. package/types/types.d.ts +4 -4
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.2.2
8
+ * @version 3.3.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -170,7 +170,7 @@ var Plugin = /*#__PURE__*/function () {
170
170
  return Plugin;
171
171
  }();
172
172
 
173
- Plugin.version = "#3.2.2#";
173
+ Plugin.version = "#3.3.0-next.1#";
174
174
 
175
175
  /**
176
176
  * Copyright (c) 2021 ~ present NAVER Corp.
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.2.2
8
+ * @version 3.3.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -300,7 +300,7 @@ var Plugin = /*#__PURE__*/function () {
300
300
  return Plugin;
301
301
  }();
302
302
 
303
- Plugin.version = "#3.2.2#";
303
+ Plugin.version = "#3.3.0-next.1#";
304
304
 
305
305
  /**
306
306
  * Copyright (c) 2017 ~ present NAVER Corp.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.2.2",
3
+ "version": "3.3.0-next.1",
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",
@@ -89,37 +89,37 @@
89
89
  "d3-scale": "^4.0.2",
90
90
  "d3-selection": "^3.0.0",
91
91
  "d3-shape": "^3.0.1",
92
- "d3-time-format": "^4.0.0",
92
+ "d3-time-format": "^4.1.0",
93
93
  "d3-transition": "^3.0.1",
94
94
  "d3-zoom": "^3.0.0"
95
95
  },
96
96
  "devDependencies": {
97
- "@babel/core": "^7.16.0",
98
- "@babel/eslint-parser": "^7.16.3",
99
- "@babel/plugin-proposal-class-properties": "^7.16.0",
100
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
101
- "@babel/plugin-transform-runtime": "^7.16.4",
102
- "@babel/preset-env": "^7.16.4",
103
- "@babel/preset-typescript": "^7.16.0",
104
- "@babel/runtime": "^7.16.3",
97
+ "@babel/core": "^7.16.5",
98
+ "@babel/eslint-parser": "^7.16.5",
99
+ "@babel/plugin-proposal-class-properties": "^7.16.5",
100
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.5",
101
+ "@babel/plugin-transform-runtime": "^7.16.5",
102
+ "@babel/preset-env": "^7.16.5",
103
+ "@babel/preset-typescript": "^7.16.5",
104
+ "@babel/runtime": "^7.16.5",
105
105
  "@commitlint/cli": "^15.0.0",
106
106
  "@commitlint/config-conventional": "^15.0.0",
107
107
  "@rollup/plugin-babel": "^5.3.0",
108
- "@rollup/plugin-node-resolve": "^13.0.6",
108
+ "@rollup/plugin-node-resolve": "^13.1.1",
109
109
  "@rollup/plugin-replace": "^3.0.0",
110
110
  "@rollup/plugin-typescript": "^8.3.0",
111
111
  "@semantic-release/changelog": "^6.0.1",
112
- "@semantic-release/commit-analyzer": "^9.0.1",
112
+ "@semantic-release/commit-analyzer": "^9.0.2",
113
113
  "@semantic-release/exec": "^6.0.2",
114
114
  "@semantic-release/git": "^10.0.1",
115
115
  "@semantic-release/npm": "^8.0.3",
116
- "@semantic-release/release-notes-generator": "^10.0.2",
117
- "@types/chai": "^4.2.22",
116
+ "@semantic-release/release-notes-generator": "^10.0.3",
117
+ "@types/chai": "^4.3.0",
118
118
  "@types/d3": "^7.1.0",
119
119
  "@types/mocha": "^9.0.0",
120
120
  "@types/sinon": "^10.0.6",
121
- "@typescript-eslint/eslint-plugin": "^5.4.0",
122
- "@typescript-eslint/parser": "^5.4.0",
121
+ "@typescript-eslint/eslint-plugin": "^5.7.0",
122
+ "@typescript-eslint/parser": "^5.7.0",
123
123
  "babel-helper-modules": "^6.0.0",
124
124
  "babel-loader": "^8.2.3",
125
125
  "babel-plugin-add-module-exports": "^1.0.4",
@@ -134,22 +134,22 @@
134
134
  "better-docs": "^2.3.2",
135
135
  "chai": "^4.3.4",
136
136
  "clean-webpack-plugin": "^4.0.0",
137
- "cloc": "^2.8.0",
138
- "core-js": "^3.19.1",
137
+ "cloc": "^2.9.0",
138
+ "core-js": "^3.19.3",
139
139
  "coveralls": "^3.1.1",
140
140
  "cross-env": "^7.0.3",
141
141
  "css-loader": "^6.5.1",
142
- "css-minimizer-webpack-plugin": "^3.1.4",
142
+ "css-minimizer-webpack-plugin": "^3.2.0",
143
143
  "d3-color": "^3.0.1",
144
144
  "d3-delaunay": "^6.0.2",
145
- "d3-format": "^3.0.1",
145
+ "d3-format": "^3.1.0",
146
146
  "d3-polygon": "^3.0.1",
147
147
  "docdash": "^1.2.0",
148
148
  "dtslint": "^4.2.1",
149
- "eslint": "^8.2.0",
149
+ "eslint": "^8.4.1",
150
150
  "eslint-config-naver": "^2.1.0",
151
151
  "eslint-plugin-import": "^2.25.3",
152
- "eslint-plugin-jsdoc": "^37.0.3",
152
+ "eslint-plugin-jsdoc": "^37.2.0",
153
153
  "eslint-webpack-plugin": "^3.1.1",
154
154
  "exports-loader": "^3.1.0",
155
155
  "hammer-simulator": "0.0.1",
@@ -172,23 +172,23 @@
172
172
  "mocha": "^9.1.3",
173
173
  "node-sass": "^6.0.1",
174
174
  "regenerator-runtime": "^0.13.7",
175
- "rollup": "^2.60.0",
175
+ "rollup": "^2.61.1",
176
176
  "rollup-plugin-delete": "^2.0.0",
177
- "sass-loader": "^12.3.0",
178
- "semantic-release": "^18.0.0",
177
+ "sass-loader": "^12.4.0",
178
+ "semantic-release": "^18.0.1",
179
179
  "simulant": "^0.2.2",
180
180
  "sinon": "^12.0.1",
181
- "string-replace-loader": "^3.0.3",
181
+ "string-replace-loader": "^3.1.0",
182
182
  "style-loader": "^3.3.1",
183
183
  "terser-webpack-plugin": "^5.2.5",
184
184
  "tslib": "^2.3.1",
185
- "typescript": "^4.5.2",
186
- "webpack": "^5.64.1",
185
+ "typescript": "^4.5.4",
186
+ "webpack": "^5.65.0",
187
187
  "webpack-bundle-analyzer": "^4.5.0",
188
188
  "webpack-clean": "^1.2.5",
189
189
  "webpack-cli": "^4.9.1",
190
190
  "webpack-common-shake": "^2.1.0",
191
- "webpack-dev-server": "^4.5.0",
191
+ "webpack-dev-server": "^4.6.0",
192
192
  "webpack-merge": "^5.8.0",
193
193
  "webpackbar": "^5.0.2",
194
194
  "write-file-webpack-plugin": "^4.5.1"
@@ -182,6 +182,14 @@ export default class ChartInternal {
182
182
  state.hasAxis = !$$.hasArcType();
183
183
  state.hasRadar = !state.hasAxis && $$.hasType("radar");
184
184
 
185
+ // when 'padding=false' is set, disable axes and subchart. Because they are useless.
186
+ if (config.padding === false) {
187
+ config.axis_x_show = false;
188
+ config.axis_y_show = false;
189
+ config.axis_y2_show = false;
190
+ config.subchart_show = false;
191
+ }
192
+
185
193
  $$.initParams();
186
194
 
187
195
  const bindto = {
@@ -290,7 +298,8 @@ export default class ChartInternal {
290
298
  state.isLegendLeft = config.legend_inset_anchor === "top-left" ||
291
299
  config.legend_inset_anchor === "bottom-left";
292
300
 
293
- state.rotatedPaddingRight = isRotated && !config.axis_x_show ? 0 : 30;
301
+ state.rotatedPadding.top = $$.getResettedPadding(state.rotatedPadding.top);
302
+ state.rotatedPadding.right = isRotated && !config.axis_x_show ? 0 : 30;
294
303
 
295
304
  state.inputType = convertInputType(
296
305
  config.interaction_inputType_mouse,
@@ -23,7 +23,7 @@ export default {
23
23
  * @returns {object}
24
24
  * @private
25
25
  */
26
- convertData(args, callback: Function): object {
26
+ convertData(args, callback: Function): any[] | false {
27
27
  let data;
28
28
 
29
29
  if (args.bindto) {
@@ -82,7 +82,7 @@ export default {
82
82
  * @returns {number} index number
83
83
  * @private
84
84
  */
85
- getIndexByX(x, basedX: (string|Date)[]): number {
85
+ getIndexByX(x: Date|number|string, basedX: (Date|number|string)[]): number {
86
86
  const $$ = this;
87
87
 
88
88
  return basedX ?
@@ -586,6 +586,7 @@ export default {
586
586
 
587
587
  /**
588
588
  * Sort targets data
589
+ * Note: For stacked bar, will sort from the total sum of data series, not for each stacked bar
589
590
  * @param {Array} targetsValue Target value
590
591
  * @returns {Array}
591
592
  * @private
@@ -617,9 +618,9 @@ export default {
617
618
  if (orderAsc || orderDesc) {
618
619
  const reducer = (p, c) => p + Math.abs(c.value);
619
620
 
620
- fn = (t1, t2) => {
621
- const t1Sum = t1.values.reduce(reducer, 0);
622
- const t2Sum = t2.values.reduce(reducer, 0);
621
+ fn = (t1: IData | IDataRow, t2: IData | IDataRow) => {
622
+ const t1Sum = "values" in t1 ? t1.values.reduce(reducer, 0) : t1.value;
623
+ const t2Sum = "values" in t2 ? t2.values.reduce(reducer, 0) : t2.value;
623
624
 
624
625
  return isArc ?
625
626
  (orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum) :
@@ -743,20 +744,23 @@ export default {
743
744
  let minDist = config.point_sensitivity;
744
745
  let closest;
745
746
 
746
- // find mouseovering bar
747
+ // find mouseovering bar/candlestick
748
+ // https://github.com/naver/billboard.js/issues/2434
747
749
  data
748
- .filter(v => $$.isBarType(v.id))
750
+ .filter(v => $$.isBarType(v.id) || $$.isCandlestickType(v.id))
749
751
  .forEach(v => {
750
- const shape = main.select(`.${CLASS.bars}${$$.getTargetSelectorSuffix(v.id)} .${CLASS.bar}-${v.index}`).node();
752
+ const selector = $$.isBarType(v.id) ?
753
+ `.${CLASS.chartBar}.${CLASS.target}${$$.getTargetSelectorSuffix(v.id)} .${CLASS.bar}-${v.index}` :
754
+ `.${CLASS.chartCandlestick}.${CLASS.target}${$$.getTargetSelectorSuffix(v.id)} .${CLASS.candlestick}-${v.index} path`;
751
755
 
752
- if (!closest && $$.isWithinBar(shape)) {
756
+ if (!closest && $$.isWithinBar(main.select(selector).node())) {
753
757
  closest = v;
754
758
  }
755
759
  });
756
760
 
757
- // find closest point from non-bar
761
+ // find closest point from non-bar/candlestick
758
762
  data
759
- .filter(v => !$$.isBarType(v.id))
763
+ .filter(v => !$$.isBarType(v.id) && !$$.isCandlestickType(v.id))
760
764
  .forEach(v => {
761
765
  const d = $$.dist(v, pos);
762
766
 
@@ -983,6 +987,19 @@ export default {
983
987
  );
984
988
  },
985
989
 
990
+ /**
991
+ * Determine if bar has ranged data
992
+ * @param {Array} d data value
993
+ * @returns {boolean}
994
+ * @private
995
+ */
996
+ isBarRangeType(d): boolean {
997
+ const $$ = this;
998
+ const {value} = d;
999
+
1000
+ return $$.isBarType(d) && isArray(value) && value.length === 2 && value.every(v => isNumber(v));
1001
+ },
1002
+
986
1003
  /**
987
1004
  * Get data object by id
988
1005
  * @param {string} id data id
@@ -145,7 +145,7 @@ export default {
145
145
  }
146
146
 
147
147
  const domainLength = Math.abs(yDomainMax - yDomainMin);
148
- const padding = {top: domainLength * 0.1, bottom: domainLength * 0.1};
148
+ let padding = {top: domainLength * 0.1, bottom: domainLength * 0.1};
149
149
 
150
150
  if (isDefined(center)) {
151
151
  const yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
@@ -171,6 +171,8 @@ export default {
171
171
  });
172
172
  }
173
173
 
174
+ padding = $$.getResettedPadding(padding);
175
+
174
176
  // if padding is set, the domain will be updated relative the current domain value
175
177
  // ex) $$.height=300, padding.top=150, domainLength=4 --> domain=6
176
178
  const p = config[`${pfx}_padding`];
@@ -233,7 +235,7 @@ export default {
233
235
 
234
236
  defaultValue = maxDataCount > 1 ? (diff / (maxDataCount - 1)) / 2 : 0.5;
235
237
  } else {
236
- defaultValue = diff * 0.01;
238
+ defaultValue = $$.getResettedPadding(diff * 0.01);
237
239
  }
238
240
 
239
241
  let {left = defaultValue, right = defaultValue} = isNumber(padding) ?
@@ -146,10 +146,11 @@ export default {
146
146
 
147
147
  if (hasAxis) {
148
148
  const isRotated = config.axis_rotated;
149
+ const resettedPadding = $$.getResettedPadding(1);
149
150
 
150
151
  // update edges
151
152
  const min = {
152
- x: isRotated ? 1 : 0,
153
+ x: isRotated ? resettedPadding : 0,
153
154
  y: isRotated ? 0 : height,
154
155
  subX: isRotated ? 1 : 0,
155
156
  subY: isRotated ? 0 : height2
@@ -157,7 +158,7 @@ export default {
157
158
 
158
159
  const max = {
159
160
  x: isRotated ? height : width,
160
- y: isRotated ? width : 1,
161
+ y: isRotated ? width : resettedPadding,
161
162
  subX: isRotated ? height : width,
162
163
  subY: isRotated ? width2 : 1
163
164
  };
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import {document} from "../../module/browser";
6
6
  import CLASS from "../../config/classes";
7
- import {isValue, ceil10, capitalize} from "../../module/util";
7
+ import {isValue, ceil10, capitalize, isNumber, isEmpty} from "../../module/util";
8
8
 
9
9
  export default {
10
10
  /**
@@ -232,6 +232,35 @@ export default {
232
232
  }
233
233
  },
234
234
 
235
+ /**
236
+ * Get resetted padding values when 'padding=false' option is set
237
+ * https://github.com/naver/billboard.js/issues/2367
238
+ * @param {number|object} v Padding values to be resetted
239
+ * @returns {number|object} Padding value
240
+ * @private
241
+ */
242
+ getResettedPadding<T = number | {[key: string]: string;}>(v: T): T {
243
+ const $$ = this;
244
+ const {config} = $$;
245
+ const isNum = isNumber(v);
246
+ let p = isNum ? 0 : {};
247
+
248
+ if (config.padding === false) {
249
+ !isNum && Object.keys(v).forEach(key => {
250
+ // when data.lables=true, do not reset top padding
251
+ p[key] = (
252
+ !isEmpty(config.data_labels) &&
253
+ config.data_labels !== false &&
254
+ key === "top"
255
+ ) ? v[key] : 0;
256
+ });
257
+ } else {
258
+ p = v;
259
+ }
260
+
261
+ return p as T;
262
+ },
263
+
235
264
  /**
236
265
  * Update size values
237
266
  * @param {boolean} isInit If is called at initialization
@@ -275,6 +304,8 @@ export default {
275
304
  left: hasArc ? 0 : $$.getCurrentPaddingLeft()
276
305
  };
277
306
 
307
+ state.margin = $$.getResettedPadding(state.margin);
308
+
278
309
  // for subchart
279
310
  state.margin2 = isRotated ? {
280
311
  top: state.margin.top,
@@ -339,9 +339,9 @@ export default {
339
339
  let xPos = points[0][0];
340
340
 
341
341
 
342
- if ($$.hasType("candlestick")) {
342
+ if ($$.isCandlestickType(d)) {
343
343
  if (isRotated) {
344
- xPos = $$.getCandlestickData(d)._isUp ?
344
+ xPos = $$.getCandlestickData(d)?._isUp ?
345
345
  points[2][2] + 4 : points[2][1] - 4;
346
346
  } else {
347
347
  xPos += (points[1][0] - xPos) / 2;
@@ -203,6 +203,10 @@ export default {
203
203
  ));
204
204
 
205
205
  value = `<b>Open:</b> ${open} <b>High:</b> ${high} <b>Low:</b> ${low} <b>Close:</b> ${close}${volume ? ` <b>Volume:</b> ${volume}` : ""}`;
206
+ } else if ($$.isBarRangeType(row)) {
207
+ const [start, end] = row.value;
208
+
209
+ value = `${valueFormat(start)} ~ ${valueFormat(end)}`;
206
210
  }
207
211
 
208
212
  if (value !== undefined) {
@@ -2,8 +2,12 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
+ import {DataRow} from "../../../types/types";
5
6
  import CLASS from "../../config/classes";
6
- import {getPointer, getRandom, getRectSegList, isNumber} from "../../module/util";
7
+ import {getRandom, isNumber} from "../../module/util";
8
+ import {IDataRow} from "../data/IData";
9
+
10
+ type BarTypeDataRow = DataRow<number | number[]>;
7
11
 
8
12
  export default {
9
13
  initBar(): void {
@@ -23,7 +27,7 @@ export default {
23
27
  }
24
28
  },
25
29
 
26
- updateTargetsForBar(targets): void {
30
+ updateTargetsForBar(targets: BarTypeDataRow[]): void {
27
31
  const $$ = this;
28
32
  const {config, $el} = $$;
29
33
  const classChartBar = $$.getChartClass("Bar");
@@ -40,7 +44,7 @@ export default {
40
44
  .data(
41
45
  // remove
42
46
  targets.filter(
43
- v => !v.values.every(d => !isNumber(d.value))
47
+ v => v.values.some(d => (isNumber(d.value) || $$.isBarRangeType(d)))
44
48
  )
45
49
  )
46
50
  .attr("class", d => classChartBar(d) + classFocus(d));
@@ -86,7 +90,7 @@ export default {
86
90
 
87
91
  /**
88
92
  * Redraw function
89
- * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
93
+ * @param {Function} drawFn Retuned function from .getDrawShape() => .generateDrawBar()
90
94
  * @param {boolean} withTransition With or without transition
91
95
  * @param {boolean} isSub Subchart draw
92
96
  * @returns {Array}
@@ -97,18 +101,37 @@ export default {
97
101
 
98
102
  return [
99
103
  $$.$T(bar, withTransition, getRandom())
100
- .attr("d", d => isNumber(d.value) && drawFn(d))
104
+ .attr("d", d => (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d))
101
105
  .style("fill", this.color)
102
106
  .style("opacity", null)
103
107
  ];
104
108
  },
105
109
 
106
- generateDrawBar(barIndices, isSub?: boolean): Function {
110
+ /**
111
+ * Generate draw function
112
+ * @param {object} barIndices data order within x axis.
113
+ * barIndices ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
114
+ *
115
+ * When gropus given as:
116
+ * groups: [
117
+ * ["data1", "data2"],
118
+ * ["data3", "data4"]
119
+ * ],
120
+ *
121
+ * Will be rendered as:
122
+ * data1 data3 data1 data3
123
+ * data2 data4 data2 data4
124
+ * -------------------------
125
+ * 0 1
126
+ * @param {boolean} isSub If is for subchart
127
+ * @returns {Function}
128
+ * @private
129
+ */
130
+ generateDrawBar(barIndices, isSub?: boolean): (d: IDataRow, i: number) => string {
107
131
  const $$ = this;
108
132
  const {config} = $$;
109
133
  const getPoints = $$.generateGetBarPoints(barIndices, isSub);
110
134
  const isRotated = config.axis_rotated;
111
- const isGrouped = config.data_groups.length;
112
135
  const barRadius = config.bar_radius;
113
136
  const barRadiusRatio = config.bar_radius_ratio;
114
137
 
@@ -118,7 +141,7 @@ export default {
118
141
  isNumber(barRadiusRatio) ? w => w * barRadiusRatio : null
119
142
  );
120
143
 
121
- return (d, i) => {
144
+ return (d: IDataRow, i: number) => {
122
145
  // 4 points that make a bar
123
146
  const points = getPoints(d, i);
124
147
 
@@ -130,7 +153,9 @@ export default {
130
153
  const pathRadius = ["", ""];
131
154
  let radius = 0;
132
155
 
133
- if (d.value !== 0 && getRadius && !isGrouped) {
156
+ const isRadiusData = $$.isGrouped(d.id) ? $$.isStackingRadiusData(d) : false;
157
+
158
+ if ((d.value !== 0 && getRadius) && (!$$.isGrouped(d.id) || isRadiusData)) {
134
159
  const index = isRotated ? indexY : indexX;
135
160
  const barW = points[2][index] - points[0][index];
136
161
 
@@ -154,7 +179,46 @@ export default {
154
179
  };
155
180
  },
156
181
 
157
- generateGetBarPoints(barIndices, isSub?: boolean): Function {
182
+ /**
183
+ * Determine if given stacking bar data is radius type
184
+ * @param {Object} d Data row
185
+ * @returns {boolean}
186
+ */
187
+ isStackingRadiusData(d: IDataRow): boolean {
188
+ const $$ = this;
189
+ const {config, data} = $$;
190
+ const {id, index, value} = d;
191
+
192
+ // Find same grouped ids
193
+ const keys = config.data_groups.find(v => v.indexOf(id) > -1);
194
+
195
+ // Get sorted list
196
+ const sortedList = $$.orderTargets(
197
+ $$.filterTargetsToShow(data.targets.filter($$.isBarType, $$))
198
+ ).filter(v => keys.indexOf(v.id) > -1);
199
+
200
+ // Get sorted Ids. Filter positive or negative values Ids from given value
201
+ const sortedIds = sortedList
202
+ .map(v => v.values.filter(
203
+ v2 => v2.index === index && (
204
+ value > 0 ? v2.value > 0 : v2.value < 0
205
+ ))[0]
206
+ )
207
+ .filter(Boolean)
208
+ .map(v => v.id);
209
+
210
+ // If the given id stays in the last position, then radius should be applied.
211
+ return value !== 0 && (sortedIds.indexOf(id) === sortedIds.length - 1);
212
+ },
213
+
214
+ /**
215
+ * Generate bar coordinate points data
216
+ * @param {object} barIndices Data order within x axis.
217
+ * @param {boolean} isSub If is for subchart
218
+ * @returns {Array} Array of coordinate points
219
+ * @private
220
+ */
221
+ generateGetBarPoints(barIndices, isSub?: boolean): (d: IDataRow, i: number) => [number, number][] {
158
222
  const $$ = this;
159
223
  const {config} = $$;
160
224
  const axis = isSub ? $$.axis.subX : $$.axis.x;
@@ -165,7 +229,7 @@ export default {
165
229
  const barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub);
166
230
  const yScale = $$.getYScaleById.bind($$);
167
231
 
168
- return (d, i) => {
232
+ return (d: IDataRow, i: number) => {
169
233
  const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
170
234
  const offset = barOffset(d, i) || y0; // offset is for stacked bar chart
171
235
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
@@ -179,7 +243,9 @@ export default {
179
243
  posY = y0;
180
244
  }
181
245
 
182
- posY -= (y0 - offset);
246
+ if (!$$.isBarRangeType(d)) {
247
+ posY -= (y0 - offset);
248
+ }
183
249
 
184
250
  const startPosX = posX + width;
185
251
 
@@ -191,26 +257,5 @@ export default {
191
257
  [startPosX, offset]
192
258
  ];
193
259
  };
194
- },
195
-
196
- isWithinBar(that): boolean {
197
- const mouse = getPointer(this.state.event, that);
198
- const list = getRectSegList(that);
199
- const [seg0, seg1] = list;
200
- const x = Math.min(seg0.x, seg1.x);
201
- const y = Math.min(seg0.y, seg1.y);
202
- const offset = this.config.bar_sensitivity;
203
- const {width, height} = that.getBBox();
204
- const sx = x - offset;
205
- const ex = x + width + offset;
206
- const sy = y + height + offset;
207
- const ey = y - offset;
208
-
209
- const isWithin = sx < mouse[0] &&
210
- mouse[0] < ex &&
211
- ey < mouse[1] &&
212
- mouse[1] < sy;
213
-
214
- return isWithin;
215
260
  }
216
261
  };
@@ -23,9 +23,9 @@ import {
23
23
  curveStep as d3CurveStep
24
24
  } from "d3-shape";
25
25
  import {select as d3Select} from "d3-selection";
26
- import {d3Selection} from "types/types";
26
+ import {d3Selection} from "../../../types/types";
27
27
  import CLASS from "../../config/classes";
28
- import {capitalize, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty} from "../../module/util";
28
+ import {capitalize, getPointer, getRectSegList, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty} from "../../module/util";
29
29
 
30
30
  export default {
31
31
  /**
@@ -204,6 +204,9 @@ export default {
204
204
  value = $$.getRatio("index", d, true);
205
205
  } else if ($$.isBubbleZType(d)) {
206
206
  value = $$.getBubbleZData(d.value, "y");
207
+ } else if ($$.isBarRangeType(d)) {
208
+ // TODO use range.getEnd() like method
209
+ value = value[1];
207
210
  }
208
211
 
209
212
  return $$.getYScaleById(d.id, isSub)(value);
@@ -275,6 +278,12 @@ export default {
275
278
  const {id, value, x} = d;
276
279
  const ind = $$.getIndices(indices, id);
277
280
  const scale = $$.getYScaleById(id, isSub);
281
+
282
+ if ($$.isBarRangeType(d)) {
283
+ // TODO use range.getStart()
284
+ return scale(value[0]);
285
+ }
286
+
278
287
  const y0 = scale($$.getShapeYMin(id));
279
288
 
280
289
  const dataXAsNumber = Number(x);
@@ -285,6 +294,7 @@ export default {
285
294
  .forEach(t => {
286
295
  const {id: tid, rowValueMapByXValue, rowValues, values: tvalues} = t;
287
296
 
297
+ // for same stacked group (ind[tid] === ind[id])
288
298
  if (ind[tid] === ind[id] && indexMapByTargetId[tid] < indexMapByTargetId[id]) {
289
299
  let row = rowValues[idx];
290
300
 
@@ -424,5 +434,26 @@ export default {
424
434
  $$.isStepType(d) ?
425
435
  config.line_step_type : "linear"
426
436
  );
437
+ },
438
+
439
+ isWithinBar(that): boolean {
440
+ const mouse = getPointer(this.state.event, that);
441
+ const list = getRectSegList(that);
442
+ const [seg0, seg1] = list;
443
+ const x = Math.min(seg0.x, seg1.x);
444
+ const y = Math.min(seg0.y, seg1.y);
445
+ const offset = this.config.bar_sensitivity;
446
+ const {width, height} = that.getBBox();
447
+ const sx = x - offset;
448
+ const ex = x + width + offset;
449
+ const sy = y + height + offset;
450
+ const ey = y - offset;
451
+
452
+ const isWithin = sx < mouse[0] &&
453
+ mouse[0] < ex &&
454
+ ey < mouse[1] &&
455
+ mouse[1] < sy;
456
+
457
+ return isWithin;
427
458
  }
428
459
  };
@@ -114,7 +114,7 @@ export default class TableView extends Plugin {
114
114
  title: dataToShow.length ? this.config.categoryTitle : ""
115
115
  });
116
116
  let tbody = "";
117
- const rows: number|string[][] = [];
117
+ const rows: (number|string)[][] = [];
118
118
 
119
119
  dataToShow.forEach(v => {
120
120
  thead += tplProcess(tpl.thead, {title: v.id});