billboard.js 3.8.2 → 3.9.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.
Files changed (63) hide show
  1. package/dist/billboard.css +7 -7
  2. package/dist/billboard.js +386 -71
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +868 -361
  6. package/dist/billboard.pkgd.min.js +2 -2
  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 +4 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +4 -4
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +484 -292
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +487 -294
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +488 -295
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +489 -297
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +501 -320
  22. package/dist/theme/dark.css +298 -0
  23. package/dist/theme/dark.min.css +9 -0
  24. package/dist/theme/datalab.css +9 -2
  25. package/dist/theme/datalab.min.css +2 -2
  26. package/dist/theme/graph.css +7 -5
  27. package/dist/theme/graph.min.css +2 -2
  28. package/dist/theme/insight.css +7 -5
  29. package/dist/theme/insight.min.css +2 -2
  30. package/dist-esm/billboard.js +367 -59
  31. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -3
  33. package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -3
  34. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  35. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  36. package/package.json +35 -34
  37. package/src/Chart/Chart.ts +30 -1
  38. package/src/ChartInternal/ChartInternal.ts +12 -4
  39. package/src/ChartInternal/data/IData.ts +5 -0
  40. package/src/ChartInternal/data/data.ts +23 -9
  41. package/src/ChartInternal/internals/size.ts +5 -1
  42. package/src/ChartInternal/internals/text.ts +20 -15
  43. package/src/ChartInternal/internals/tooltip.ts +4 -3
  44. package/src/ChartInternal/shape/arc.ts +161 -18
  45. package/src/ChartInternal/shape/bar.ts +7 -3
  46. package/src/ChartInternal/shape/bubble.ts +0 -1
  47. package/src/ChartInternal/shape/point.ts +2 -0
  48. package/src/config/Options/common/legend.ts +1 -1
  49. package/src/config/Options/common/point.ts +30 -2
  50. package/src/config/Options/data/data.ts +22 -6
  51. package/src/config/Options/shape/arc.ts +73 -1
  52. package/src/config/Options/shape/bar.ts +7 -1
  53. package/src/config/Options/shape/donut.ts +5 -0
  54. package/src/config/Options/shape/gauge.ts +6 -0
  55. package/src/config/Store/State.ts +2 -1
  56. package/src/config/classes.ts +2 -1
  57. package/src/scss/billboard.scss +8 -5
  58. package/src/scss/theme/dark.scss +423 -0
  59. package/src/scss/theme/datalab.scss +11 -0
  60. package/src/scss/theme/graph.scss +9 -4
  61. package/src/scss/theme/insight.scss +9 -4
  62. package/types/options.d.ts +36 -14
  63. package/types/options.shape.d.ts +81 -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.8.2
8
+ * @version 3.9.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -104,7 +104,7 @@ var Plugin = /** @class */ (function () {
104
104
  delete _this[key];
105
105
  });
106
106
  };
107
- Plugin.version = "3.8.2";
107
+ Plugin.version = "3.9.0-next.2";
108
108
  return Plugin;
109
109
  }());
110
110
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -86,7 +86,8 @@ var $ARC = {
86
86
  chartArc: "bb-chart-arc",
87
87
  chartArcs: "bb-chart-arcs",
88
88
  chartArcsBackground: "bb-chart-arcs-background",
89
- chartArcsTitle: "bb-chart-arcs-title"
89
+ chartArcsTitle: "bb-chart-arcs-title",
90
+ needle: "bb-needle"
90
91
  };
91
92
  var $AREA = {
92
93
  area: "bb-area",
@@ -278,7 +279,7 @@ var Plugin = /** @class */ (function () {
278
279
  delete _this[key];
279
280
  });
280
281
  };
281
- Plugin.version = "3.8.2";
282
+ Plugin.version = "3.9.0-next.2";
282
283
  return Plugin;
283
284
  }());
284
285
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -92,7 +92,8 @@ var $ARC = {
92
92
  chartArc: "bb-chart-arc",
93
93
  chartArcs: "bb-chart-arcs",
94
94
  chartArcsBackground: "bb-chart-arcs-background",
95
- chartArcsTitle: "bb-chart-arcs-title"
95
+ chartArcsTitle: "bb-chart-arcs-title",
96
+ needle: "bb-needle"
96
97
  };
97
98
  var $AREA = {
98
99
  area: "bb-area",
@@ -486,7 +487,7 @@ var Plugin = /** @class */ (function () {
486
487
  delete _this[key];
487
488
  });
488
489
  };
489
- Plugin.version = "3.8.2";
490
+ Plugin.version = "3.9.0-next.2";
490
491
  return Plugin;
491
492
  }());
492
493
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -121,7 +121,7 @@ var Plugin = /** @class */ (function () {
121
121
  delete _this[key];
122
122
  });
123
123
  };
124
- Plugin.version = "3.8.2";
124
+ Plugin.version = "3.9.0-next.2";
125
125
  return Plugin;
126
126
  }());
127
127
  var Plugin$1 = Plugin;
@@ -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.2
8
+ * @version 3.9.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -263,7 +263,7 @@ var Plugin = /** @class */ (function () {
263
263
  delete _this[key];
264
264
  });
265
265
  };
266
- Plugin.version = "3.8.2";
266
+ Plugin.version = "3.9.0-next.2";
267
267
  return Plugin;
268
268
  }());
269
269
  var Plugin$1 = Plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.8.2",
3
+ "version": "3.9.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",
@@ -18,7 +18,8 @@
18
18
  "import": "./dist-esm/plugin/*.js",
19
19
  "require": "./dist/plugin/pkgd/*.js"
20
20
  },
21
- "./dist/*": "./dist/*"
21
+ "./dist/*": "./dist/*",
22
+ "./src/Plugin/*": "./src/Plugin/*.js"
22
23
  },
23
24
  "scripts": {
24
25
  "start": "webpack serve --open",
@@ -101,32 +102,32 @@
101
102
  "d3-zoom": "^3.0.0"
102
103
  },
103
104
  "devDependencies": {
104
- "@babel/core": "^7.21.8",
105
- "@babel/eslint-parser": "^7.21.8",
105
+ "@babel/core": "^7.22.5",
106
+ "@babel/eslint-parser": "^7.22.5",
106
107
  "@babel/plugin-proposal-class-properties": "^7.18.6",
107
108
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
108
- "@babel/plugin-transform-runtime": "^7.21.4",
109
- "@babel/preset-env": "^7.21.5",
110
- "@babel/preset-typescript": "^7.21.5",
111
- "@babel/runtime": "^7.21.5",
112
- "@commitlint/cli": "17.6.3",
109
+ "@babel/plugin-transform-runtime": "^7.22.5",
110
+ "@babel/preset-env": "^7.22.5",
111
+ "@babel/preset-typescript": "^7.22.5",
112
+ "@babel/runtime": "^7.22.5",
113
+ "@commitlint/cli": "17.6.5",
113
114
  "@commitlint/config-conventional": "^17.6.3",
114
115
  "@rollup/plugin-babel": "^6.0.3",
115
116
  "@rollup/plugin-node-resolve": "^15.0.2",
116
117
  "@rollup/plugin-replace": "^5.0.2",
117
118
  "@rollup/plugin-typescript": "^11.1.1",
118
119
  "@semantic-release/changelog": "^6.0.3",
119
- "@semantic-release/commit-analyzer": "^9.0.2",
120
+ "@semantic-release/commit-analyzer": "^10.0.1",
120
121
  "@semantic-release/exec": "^6.0.3",
121
122
  "@semantic-release/git": "^10.0.1",
122
- "@semantic-release/npm": "^10.0.3",
123
- "@semantic-release/release-notes-generator": "^11.0.1",
123
+ "@semantic-release/npm": "^10.0.4",
124
+ "@semantic-release/release-notes-generator": "^11.0.3",
124
125
  "@types/chai": "^4.3.5",
125
126
  "@types/d3": "^7.4.0",
126
127
  "@types/mocha": "^10.0.1",
127
128
  "@types/sinon": "^10.0.15",
128
- "@typescript-eslint/eslint-plugin": "^5.59.6",
129
- "@typescript-eslint/parser": "^5.59.6",
129
+ "@typescript-eslint/eslint-plugin": "^5.60.0",
130
+ "@typescript-eslint/parser": "^5.60.0",
130
131
  "babel-helper-modules": "^6.0.0",
131
132
  "babel-loader": "^9.1.2",
132
133
  "babel-plugin-add-module-exports": "^1.0.4",
@@ -142,21 +143,21 @@
142
143
  "chai": "^4.3.7",
143
144
  "clean-webpack-plugin": "^4.0.0",
144
145
  "cloc": "^2.11.0",
145
- "core-js": "^3.30.2",
146
+ "core-js": "^3.31.0",
146
147
  "coveralls": "^3.1.1",
147
148
  "cross-env": "^7.0.3",
148
- "css-loader": "^6.7.3",
149
- "css-minimizer-webpack-plugin": "^5.0.0",
149
+ "css-loader": "^6.8.1",
150
+ "css-minimizer-webpack-plugin": "^5.0.1",
150
151
  "d3-color": "^3.1.0",
151
152
  "d3-delaunay": "^6.0.4",
152
153
  "d3-format": "^3.1.0",
153
154
  "d3-polygon": "^3.0.1",
154
155
  "docdash": "^2.0.1",
155
156
  "dtslint": "^4.2.1",
156
- "eslint": "^8.40.0",
157
+ "eslint": "^8.43.0",
157
158
  "eslint-config-naver": "^2.1.0",
158
159
  "eslint-plugin-import": "^2.27.5",
159
- "eslint-plugin-jsdoc": "^44.2.4",
160
+ "eslint-plugin-jsdoc": "^46.2.6",
160
161
  "eslint-webpack-plugin": "^4.0.1",
161
162
  "exports-loader": "^4.0.0",
162
163
  "hammer-simulator": "0.0.1",
@@ -176,29 +177,29 @@
176
177
  "karma-webpack": "^5.0.0",
177
178
  "lint-staged": "^13.2.2",
178
179
  "lite-fixture": "^1.0.2",
179
- "mini-css-extract-plugin": "^2.7.5",
180
+ "mini-css-extract-plugin": "^2.7.6",
180
181
  "mocha": "^10.2.0",
181
- "node-sass": "^8.0.0",
182
+ "node-sass": "^9.0.0",
182
183
  "regenerator-runtime": "^0.13.11",
183
- "rollup": "^3.21.7",
184
+ "rollup": "^3.25.1",
184
185
  "rollup-plugin-delete": "^2.0.0",
185
- "sass-loader": "^13.2.2",
186
- "semantic-release": "^21.0.2",
186
+ "sass-loader": "^13.3.2",
187
+ "semantic-release": "^21.0.5",
187
188
  "simulant": "^0.2.2",
188
- "sinon": "^15.0.4",
189
+ "sinon": "^15.1.2",
189
190
  "string-replace-loader": "^3.1.0",
190
- "style-loader": "^3.3.2",
191
+ "style-loader": "^3.3.3",
191
192
  "taffydb": "^2.7.3",
192
- "terser-webpack-plugin": "^5.3.8",
193
- "tslib": "^2.5.0",
194
- "typescript": "5.0.4",
195
- "webpack": "^5.82.1",
196
- "webpack-bundle-analyzer": "^4.8.0",
193
+ "terser-webpack-plugin": "^5.3.9",
194
+ "tslib": "^2.5.3",
195
+ "typescript": "5.1.3",
196
+ "webpack": "^5.87.0",
197
+ "webpack-bundle-analyzer": "^4.9.0",
197
198
  "webpack-clean": "^1.2.5",
198
- "webpack-cli": "^5.1.1",
199
+ "webpack-cli": "^5.1.4",
199
200
  "webpack-common-shake": "^2.1.0",
200
- "webpack-dev-server": "^4.15.0",
201
- "webpack-merge": "^5.8.0",
201
+ "webpack-dev-server": "^4.15.1",
202
+ "webpack-merge": "^5.9.0",
202
203
  "webpackbar": "^5.0.2",
203
204
  "write-file-webpack-plugin": "^4.5.1"
204
205
  }
@@ -39,6 +39,10 @@ import apiTooltip from "./api/tooltip";
39
39
  * @property {d3.selection} $.svg Main svg element
40
40
  * @property {d3.selection} $.defs Definition element
41
41
  * @property {d3.selection} $.main Main grouping element
42
+ * @property {d3.selection} $.needle Needle element
43
+ * - **NOTE:**
44
+ * - The element will have `bb-needle` as class name.
45
+ * - Will provide speical helper `.updateHelper(value: number, updateConfig: boolean)` method to facilitate needle position update.
42
46
  * @property {d3.selection} $.tooltip Tooltip element
43
47
  * @property {d3.selection} $.legend Legend element
44
48
  * @property {d3.selection} $.title Title element
@@ -55,10 +59,35 @@ import apiTooltip from "./api/tooltip";
55
59
  * @property {d3.selection} $.text.texts Data label text elements
56
60
  * @memberof Chart
57
61
  * @example
58
- * var chart = bb.generate({ ... });
62
+ * const chart = bb.generate({ ... });
59
63
  *
60
64
  * chart.$.chart; // wrapper element
61
65
  * chart.$.line.circles; // all data point circle elements
66
+ * @example
67
+ * // Update arc needle position
68
+ * const chart = bb.generate({
69
+ * data: {
70
+ * type: "donut"
71
+ * },
72
+ * arc: {
73
+ * needle: {
74
+ * show: true,
75
+ * ...
76
+ * }
77
+ * }
78
+ * });
79
+ *
80
+ * chart.$.needle.updateHelper(70); // update needle position to point value 70.
81
+ *
82
+ * // update needle position to point value 70 and the config value.
83
+ * // NOTE: updating config value, will update needle pointer initial value too.
84
+ * chart.$.needle.updateHelper(70, true);
85
+ *
86
+ * // update needle point position every 1 second
87
+ * let i = 0;
88
+ * setInterval(() => {
89
+ * chart.$.needle.updateHelper(i += 10);
90
+ * }, 1000)
62
91
  */
63
92
  /**
64
93
  * Plugin instance array
@@ -479,6 +479,8 @@ export default class ChartInternal {
479
479
 
480
480
  $$.callPluginHook("$init");
481
481
 
482
+ $$.initChartElements();
483
+
482
484
  if (hasAxis) {
483
485
  // Cover whole with rects for events
484
486
  hasInteraction && $$.initEventRect?.();
@@ -490,8 +492,6 @@ export default class ChartInternal {
490
492
  config.clipPath && $$.axis?.init();
491
493
  }
492
494
 
493
- $$.initChartElements();
494
-
495
495
  // Set targets
496
496
  $$.updateTargets($$.data.targets);
497
497
 
@@ -535,7 +535,13 @@ export default class ChartInternal {
535
535
  const types: string[] = [];
536
536
 
537
537
  if (hasAxis) {
538
- ["bar", "bubble", "candlestick", "line"].forEach(v => {
538
+ const shapes = ["bar", "bubble", "candlestick", "line"];
539
+
540
+ if ($$.config.bar_front) {
541
+ shapes.push(shapes.shift() as string);
542
+ }
543
+
544
+ shapes.forEach(v => {
539
545
  const name = capitalize(v);
540
546
 
541
547
  if ((v === "line" && $$.hasTypeOf(name)) || $$.hasType(v)) {
@@ -574,7 +580,7 @@ export default class ChartInternal {
574
580
  setChartElements(): void {
575
581
  const $$ = this;
576
582
  const {$el: {
577
- chart, svg, defs, main, tooltip, legend, title, grid,
583
+ chart, svg, defs, main, tooltip, legend, title, grid, needle,
578
584
  arcs: arc,
579
585
  circle: circles,
580
586
  bar: bars,
@@ -584,6 +590,7 @@ export default class ChartInternal {
584
590
  text: texts,
585
591
  }} = $$;
586
592
 
593
+ // public
587
594
  $$.api.$ = {
588
595
  chart,
589
596
  svg,
@@ -598,6 +605,7 @@ export default class ChartInternal {
598
605
  bar: {bars},
599
606
  candlestick,
600
607
  line: {lines, areas},
608
+ needle,
601
609
  text: {texts}
602
610
  };
603
611
  }
@@ -21,6 +21,11 @@ export interface ITreemapData {
21
21
  export interface IDataRow extends TDataRow {
22
22
  x: number | string | Date;
23
23
  }
24
+
25
+ export interface IDataPoint extends IDataRow {
26
+ r: number;
27
+ }
28
+
24
29
  export interface IArcDataRow extends TDataRow {
25
30
  ratio: number;
26
31
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import {$BAR, $CANDLESTICK, $COMMON} from "../../config/classes";
6
6
  import {KEY} from "../../module/Cache";
7
- import type {IData, IDataRow} from "./IData";
7
+ import type {IData, IDataPoint, IDataRow} from "./IData";
8
8
  import {
9
9
  findIndex,
10
10
  getUnique,
@@ -730,7 +730,7 @@ export default {
730
730
  return sames;
731
731
  },
732
732
 
733
- findClosestFromTargets(targets, pos): IDataRow | undefined {
733
+ findClosestFromTargets(targets, pos: [number, number]): IDataRow | undefined {
734
734
  const $$ = this;
735
735
  const candidates = targets.map(target => $$.findClosest(target.values, pos)); // map to array of closest points of each target
736
736
 
@@ -738,11 +738,22 @@ export default {
738
738
  return $$.findClosest(candidates, pos);
739
739
  },
740
740
 
741
- findClosest(values, pos): IDataRow | undefined {
741
+ findClosest(values, pos: [number, number]): IDataRow | undefined {
742
742
  const $$ = this;
743
743
  const {config, $el: {main}} = $$;
744
744
  const data = values.filter(v => v && isValue(v.value));
745
- let minDist = config.point_sensitivity;
745
+ const getSensitivity = (d: IDataPoint) => {
746
+ let sensitivity = config.point_sensitivity;
747
+
748
+ if (isFunction(sensitivity)) {
749
+ sensitivity = sensitivity.call($$.api, d);
750
+ } else if (sensitivity === "radius") {
751
+ sensitivity = d.r;
752
+ }
753
+
754
+ return sensitivity;
755
+ };
756
+ let minDist;
746
757
  let closest;
747
758
 
748
759
  // find mouseovering bar/candlestick
@@ -762,9 +773,11 @@ export default {
762
773
  // find closest point from non-bar/candlestick
763
774
  data
764
775
  .filter(v => !$$.isBarType(v.id) && !$$.isCandlestickType(v.id))
765
- .forEach(v => {
776
+ .forEach((v: IDataPoint) => {
766
777
  const d = $$.dist(v, pos);
767
778
 
779
+ minDist = getSensitivity(v);
780
+
768
781
  if (d < minDist) {
769
782
  minDist = d;
770
783
  closest = v;
@@ -774,11 +787,11 @@ export default {
774
787
  return closest;
775
788
  },
776
789
 
777
- dist(data, pos) {
790
+ dist(data: IDataPoint, pos: [number, number]) {
778
791
  const $$ = this;
779
792
  const {config: {axis_rotated: isRotated}, scale} = $$;
780
- const xIndex = isRotated ? 1 : 0;
781
- const yIndex = isRotated ? 0 : 1;
793
+ const xIndex = +isRotated; // true: 1, false: 0
794
+ const yIndex = +!isRotated; // true: 0, false: 1
782
795
  const y = $$.circleY(data, data.index);
783
796
  const x = (scale.zoom || scale.x)(data.x);
784
797
 
@@ -930,7 +943,8 @@ export default {
930
943
 
931
944
  // otherwise, based on the rendered angle value
932
945
  } else {
933
- const gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getStartAngle() * -2;
946
+ const gaugeArcLength = config.gauge_fullCircle ?
947
+ $$.getArcLength() : $$.getGaugeStartAngle() * -2;
934
948
  const arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
935
949
 
936
950
  ratio = (d.endAngle - d.startAngle) / arcLength;
@@ -325,6 +325,10 @@ export default {
325
325
  const subchartHeight = config.subchart_show && !isNonAxis ?
326
326
  (config.subchart_size_height + subchartXAxisHeight) : 0;
327
327
 
328
+ // when needle is shown with legend, it need some bottom space to not overlap with legend text
329
+ const gaugeHeight = $$.hasType("gauge") && config.arc_needle_show &&
330
+ !config.gauge_fullCircle && !config.gauge_label_show ? 10 : 0;
331
+
328
332
  const padding = $$.getCurrentPadding();
329
333
 
330
334
  // for main
@@ -336,7 +340,7 @@ export default {
336
340
  } : {
337
341
  top: (isFitPadding ? 0 : 4) + padding.top, // for top tick text
338
342
  right: isNonAxis ? 0 : $$.getCurrentPaddingRight(true),
339
- bottom: xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
343
+ bottom: gaugeHeight + xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
340
344
  left: isNonAxis ? 0 : padding.left
341
345
  };
342
346
 
@@ -89,6 +89,24 @@ function setRotatePos(
89
89
  return {x, y};
90
90
  }
91
91
 
92
+ /**
93
+ * Get data.labels.position value
94
+ * @param {object} d Data object
95
+ * @param {string} type x | y
96
+ * @returns {number} Position value
97
+ * @private
98
+ */
99
+ function getTextPos(d, type): number {
100
+ const position = this.config.data_labels_position;
101
+ const {id, index, value} = d;
102
+
103
+ return (
104
+ isFunction(position) ?
105
+ position.bind(this.api)(type, value, id, index, this.$el.text) :
106
+ (id in position ? position[id] : position)[type]
107
+ ) ?? 0;
108
+ }
109
+
92
110
  export default {
93
111
  opacityForText(d): null | "0" {
94
112
  const $$ = this;
@@ -424,19 +442,6 @@ export default {
424
442
  return 0;
425
443
  },
426
444
 
427
- /**
428
- * Get data.labels.position value
429
- * @param {string} id Data id value
430
- * @param {string} type x | y
431
- * @returns {number} Position value
432
- * @private
433
- */
434
- getTextPos(id, type): number {
435
- const pos = this.config.data_labels_position;
436
-
437
- return (id in pos ? pos[id] : pos)[type] || 0;
438
- },
439
-
440
445
  /**
441
446
  * Gets the x coordinate of the text
442
447
  * @param {object} points Data points position
@@ -494,7 +499,7 @@ export default {
494
499
  xPos += $$.getCenteredTextPos(d, points, textElement, "x");
495
500
  }
496
501
 
497
- return xPos + $$.getTextPos(d.id, "x");
502
+ return xPos + getTextPos.call(this, d, "x");
498
503
  },
499
504
 
500
505
  /**
@@ -582,7 +587,7 @@ export default {
582
587
  yPos += $$.getCenteredTextPos(d, points, textElement, "y");
583
588
  }
584
589
 
585
- return yPos + $$.getTextPos(d.id, "y");
590
+ return yPos + getTextPos.call(this, d, "y");
586
591
  },
587
592
 
588
593
  /**
@@ -273,6 +273,7 @@ export default {
273
273
  const {width, height, current, isLegendRight, inputType, event} = state;
274
274
  const hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
275
275
  const hasTreemap = state.hasTreemap;
276
+ const isRotated = config.axis_rotated;
276
277
  const svgLeft = $$.getSvgLeft(true);
277
278
  let chartRight = svgLeft + current.width - $$.getCurrentPaddingRight();
278
279
  const chartLeft = $$.getCurrentPaddingLeft(true);
@@ -290,9 +291,9 @@ export default {
290
291
  } else if (!hasTreemap) {
291
292
  const dataScale = scale.x(dataToShow[0].x);
292
293
 
293
- if (config.axis_rotated) {
294
+ if (isRotated) {
294
295
  y = dataScale + size;
295
- x += svgLeft + 100;
296
+ x += svgLeft;
296
297
  chartRight -= svgLeft;
297
298
  } else {
298
299
  y -= 5;
@@ -302,7 +303,7 @@ export default {
302
303
 
303
304
  // when tooltip left + tWidth > chart's width
304
305
  if ((x + tWidth + 15) > chartRight) {
305
- x -= tWidth + (hasTreemap ? 0 : chartLeft);
306
+ x -= isRotated ? tWidth - chartLeft : tWidth + (hasTreemap ? 0 : chartLeft);
306
307
  }
307
308
 
308
309
  if (y + tHeight > current.height) {