@carbon/charts 0.30.21 → 0.30.25

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 (215) hide show
  1. package/CHANGELOG.md +337 -1035
  2. package/README.md +3 -0
  3. package/axis-chart.js +8 -14
  4. package/axis-chart.js.map +1 -1
  5. package/build/demo/{data/create-codesandbox.d.ts → create-codesandbox.d.ts} +16 -13
  6. package/build/demo/data/bar.d.ts +175 -1
  7. package/build/demo/data/bubble.d.ts +41 -0
  8. package/build/demo/data/donut.d.ts +23 -0
  9. package/build/demo/data/line.d.ts +70 -0
  10. package/build/demo/data/pie.d.ts +13 -0
  11. package/build/demo/data/scatter.d.ts +31 -0
  12. package/build/demo/data/step.d.ts +4 -0
  13. package/build/demo/data/time-series-axis.d.ts +55 -3
  14. package/build/src/components/axes/grid.d.ts +3 -3
  15. package/build/src/components/axes/two-dimensional-axes.d.ts +3 -0
  16. package/build/src/components/essentials/threshold.d.ts +17 -0
  17. package/build/src/components/graphs/bar.d.ts +1 -1
  18. package/build/src/components/graphs/scatter.d.ts +1 -0
  19. package/build/src/components/graphs/skeleton.d.ts +22 -0
  20. package/build/src/components/index.d.ts +2 -0
  21. package/build/src/interfaces/axis-scales.d.ts +22 -11
  22. package/build/src/interfaces/charts.d.ts +5 -0
  23. package/build/src/interfaces/components.d.ts +21 -0
  24. package/build/src/interfaces/enums.d.ts +9 -0
  25. package/build/src/interfaces/events.d.ts +7 -0
  26. package/build/src/model.d.ts +1 -0
  27. package/build/src/services/scales-cartesian.d.ts +9 -1
  28. package/build/stories/tutorials/event-listeners.d.ts +1 -0
  29. package/build/stories/tutorials/index.d.ts +2 -1
  30. package/bundle.js +1 -1
  31. package/chart.js +15 -24
  32. package/chart.js.map +1 -1
  33. package/charts/bar-grouped.js +6 -2
  34. package/charts/bar-grouped.js.map +1 -1
  35. package/charts/bar-simple.js +6 -2
  36. package/charts/bar-simple.js.map +1 -1
  37. package/charts/bar-stacked.js +6 -2
  38. package/charts/bar-stacked.js.map +1 -1
  39. package/charts/bubble.js +6 -2
  40. package/charts/bubble.js.map +1 -1
  41. package/charts/donut.js +6 -2
  42. package/charts/donut.js.map +1 -1
  43. package/charts/line.js +6 -2
  44. package/charts/line.js.map +1 -1
  45. package/charts/pie.js +6 -2
  46. package/charts/pie.js.map +1 -1
  47. package/charts/radar.js +1 -3
  48. package/charts/radar.js.map +1 -1
  49. package/charts/scatter.js +6 -2
  50. package/charts/scatter.js.map +1 -1
  51. package/components/axes/axis.js +93 -43
  52. package/components/axes/axis.js.map +1 -1
  53. package/components/axes/grid.d.ts +3 -3
  54. package/components/axes/grid.js +46 -23
  55. package/components/axes/grid.js.map +1 -1
  56. package/components/axes/ruler.js +7 -5
  57. package/components/axes/ruler.js.map +1 -1
  58. package/components/axes/two-dimensional-axes.d.ts +3 -0
  59. package/components/axes/two-dimensional-axes.js +35 -2
  60. package/components/axes/two-dimensional-axes.js.map +1 -1
  61. package/components/axes/zero-line.js +16 -1
  62. package/components/axes/zero-line.js.map +1 -1
  63. package/components/component.js +2 -4
  64. package/components/component.js.map +1 -1
  65. package/components/essentials/legend.js +46 -23
  66. package/components/essentials/legend.js.map +1 -1
  67. package/components/essentials/threshold.d.ts +17 -0
  68. package/components/essentials/threshold.js +171 -0
  69. package/components/essentials/threshold.js.map +1 -0
  70. package/components/essentials/title.js +6 -4
  71. package/components/essentials/title.js.map +1 -1
  72. package/components/essentials/tooltip-bar.js +39 -20
  73. package/components/essentials/tooltip-bar.js.map +1 -1
  74. package/components/essentials/tooltip-pie.js +4 -3
  75. package/components/essentials/tooltip-pie.js.map +1 -1
  76. package/components/essentials/tooltip-radar.js +6 -3
  77. package/components/essentials/tooltip-radar.js.map +1 -1
  78. package/components/essentials/tooltip-scatter.js +3 -1
  79. package/components/essentials/tooltip-scatter.js.map +1 -1
  80. package/components/essentials/tooltip.js +35 -15
  81. package/components/essentials/tooltip.js.map +1 -1
  82. package/components/graphs/bar-grouped.js +48 -20
  83. package/components/graphs/bar-grouped.js.map +1 -1
  84. package/components/graphs/bar-simple.js +39 -19
  85. package/components/graphs/bar-simple.js.map +1 -1
  86. package/components/graphs/bar-stacked.js +50 -28
  87. package/components/graphs/bar-stacked.js.map +1 -1
  88. package/components/graphs/bar.d.ts +1 -1
  89. package/components/graphs/bar.js +1 -1
  90. package/components/graphs/bar.js.map +1 -1
  91. package/components/graphs/bubble.js +22 -8
  92. package/components/graphs/bubble.js.map +1 -1
  93. package/components/graphs/donut.js +17 -3
  94. package/components/graphs/donut.js.map +1 -1
  95. package/components/graphs/line.js +14 -7
  96. package/components/graphs/line.js.map +1 -1
  97. package/components/graphs/pie.js +80 -44
  98. package/components/graphs/pie.js.map +1 -1
  99. package/components/graphs/radar.js +271 -140
  100. package/components/graphs/radar.js.map +1 -1
  101. package/components/graphs/scatter.d.ts +1 -0
  102. package/components/graphs/scatter.js +80 -19
  103. package/components/graphs/scatter.js.map +1 -1
  104. package/components/graphs/skeleton.d.ts +22 -0
  105. package/components/graphs/skeleton.js +256 -0
  106. package/components/graphs/skeleton.js.map +1 -0
  107. package/components/index.d.ts +2 -0
  108. package/components/index.js +2 -0
  109. package/components/index.js.map +1 -1
  110. package/components/layout/layout.js +38 -26
  111. package/components/layout/layout.js.map +1 -1
  112. package/components/layout/spacer.js +2 -1
  113. package/components/layout/spacer.js.map +1 -1
  114. package/configuration.js +17 -14
  115. package/configuration.js.map +1 -1
  116. package/demo/{data/create-codesandbox.d.ts → create-codesandbox.d.ts} +16 -13
  117. package/demo/{data/create-codesandbox.js → create-codesandbox.js} +24 -21
  118. package/demo/create-codesandbox.js.map +1 -0
  119. package/demo/data/bar.d.ts +175 -1
  120. package/demo/data/bar.js +189 -3
  121. package/demo/data/bar.js.map +1 -1
  122. package/demo/data/bubble.d.ts +41 -0
  123. package/demo/data/bubble.js +48 -3
  124. package/demo/data/bubble.js.map +1 -1
  125. package/demo/data/bundle.js +1 -1
  126. package/demo/data/donut.d.ts +23 -0
  127. package/demo/data/donut.js +25 -0
  128. package/demo/data/donut.js.map +1 -1
  129. package/demo/data/index.js +189 -7
  130. package/demo/data/index.js.map +1 -1
  131. package/demo/data/line.d.ts +70 -0
  132. package/demo/data/line.js +71 -0
  133. package/demo/data/line.js.map +1 -1
  134. package/demo/data/pie.d.ts +13 -0
  135. package/demo/data/pie.js +15 -0
  136. package/demo/data/pie.js.map +1 -1
  137. package/demo/data/radar.js.map +1 -1
  138. package/demo/data/scatter.d.ts +31 -0
  139. package/demo/data/scatter.js +33 -0
  140. package/demo/data/scatter.js.map +1 -1
  141. package/demo/data/step.d.ts +4 -0
  142. package/demo/data/step.js +15 -0
  143. package/demo/data/step.js.map +1 -1
  144. package/demo/data/time-series-axis.d.ts +55 -3
  145. package/demo/data/time-series-axis.js +62 -6
  146. package/demo/data/time-series-axis.js.map +1 -1
  147. package/demo/styles.css +342 -18
  148. package/demo/styles.css.map +1 -1
  149. package/demo/styles.min.css +1 -1
  150. package/demo/styles.min.css.map +1 -1
  151. package/demo/tsconfig.tsbuildinfo +232 -229
  152. package/index.js.map +1 -1
  153. package/interfaces/axis-scales.d.ts +22 -11
  154. package/interfaces/axis-scales.js.map +1 -1
  155. package/interfaces/charts.d.ts +5 -0
  156. package/interfaces/charts.js.map +1 -1
  157. package/interfaces/components.d.ts +21 -0
  158. package/interfaces/components.js.map +1 -1
  159. package/interfaces/enums.d.ts +9 -0
  160. package/interfaces/enums.js +10 -0
  161. package/interfaces/enums.js.map +1 -1
  162. package/interfaces/events.d.ts +7 -0
  163. package/interfaces/events.js +8 -0
  164. package/interfaces/events.js.map +1 -1
  165. package/model.d.ts +1 -0
  166. package/model.js +30 -16
  167. package/model.js.map +1 -1
  168. package/package.json +4 -2
  169. package/polyfills.js +7 -2
  170. package/polyfills.js.map +1 -1
  171. package/services/angle-utils.js +34 -9
  172. package/services/angle-utils.js.map +1 -1
  173. package/services/colors.js.map +1 -1
  174. package/services/curves.js +4 -2
  175. package/services/curves.js.map +1 -1
  176. package/services/essentials/dom-utils.js +4 -3
  177. package/services/essentials/dom-utils.js.map +1 -1
  178. package/services/essentials/transitions.js +3 -4
  179. package/services/essentials/transitions.js.map +1 -1
  180. package/services/scales-cartesian.d.ts +9 -1
  181. package/services/scales-cartesian.js +96 -23
  182. package/services/scales-cartesian.js.map +1 -1
  183. package/services/time-series.js +36 -19
  184. package/services/time-series.js.map +1 -1
  185. package/styles/components/_axis.scss +4 -0
  186. package/styles/components/_layout.scss +0 -1
  187. package/styles/components/_ruler.scss +5 -2
  188. package/styles/components/_skeleton.scss +56 -0
  189. package/styles/components/_threshold.scss +49 -0
  190. package/styles/components/_tooltip.scss +6 -5
  191. package/styles/components/index.scss +2 -0
  192. package/styles/graphs/_bubble.scss +1 -1
  193. package/styles/graphs/_radar.scss +4 -2
  194. package/styles/graphs/_scatter.scss +5 -1
  195. package/styles/mixins.scss +2 -2
  196. package/styles-g10.css +87 -4
  197. package/styles-g10.css.map +1 -1
  198. package/styles-g10.min.css +1 -1
  199. package/styles-g10.min.css.map +1 -1
  200. package/styles-g100.css +87 -4
  201. package/styles-g100.css.map +1 -1
  202. package/styles-g100.min.css +1 -1
  203. package/styles-g100.min.css.map +1 -1
  204. package/styles-g90.css +87 -4
  205. package/styles-g90.css.map +1 -1
  206. package/styles-g90.min.css +1 -1
  207. package/styles-g90.min.css.map +1 -1
  208. package/styles.css +87 -4
  209. package/styles.css.map +1 -1
  210. package/styles.min.css +1 -1
  211. package/styles.min.css.map +1 -1
  212. package/tools.js +25 -7
  213. package/tools.js.map +1 -1
  214. package/tsconfig.tsbuildinfo +169 -106
  215. package/demo/data/create-codesandbox.js.map +0 -1
@@ -0,0 +1,171 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { Component } from "../component";
15
+ import { Tools } from "../../tools";
16
+ import { DOMUtils } from "../../services";
17
+ import { AxisPositions, Events, ScaleTypes } from "../../interfaces";
18
+ import { select, mouse } from "d3-selection";
19
+ // Carbon position service
20
+ import Position, { PLACEMENTS } from "@carbon/utils-position";
21
+ // import the settings for the css prefix
22
+ import settings from "carbon-components/es/globals/js/settings";
23
+ import { formatTick, computeTimeIntervalName } from "../../services/time-series";
24
+ var Threshold = /** @class */ (function (_super) {
25
+ __extends(Threshold, _super);
26
+ function Threshold(model, services, configs) {
27
+ var _this = _super.call(this, model, services, configs) || this;
28
+ _this.type = "threshold";
29
+ _this.positionService = new Position();
30
+ return _this;
31
+ }
32
+ Threshold.prototype.render = function (animate) {
33
+ var _this = this;
34
+ if (animate === void 0) { animate = false; }
35
+ var _a = this.configs, value = _a.value, fillColor = _a.fillColor, axisPosition = _a.axisPosition, index = _a.index;
36
+ var chartprefix = Tools.getProperty(this.model.getOptions(), "style", "prefix");
37
+ this.thresholdClass = settings.prefix + "--" + chartprefix + "--threshold";
38
+ // We can have multiple thresholds, set an unique identifier
39
+ this.thresholdIdentifierClass = axisPosition + "-" + index;
40
+ this.threshold = DOMUtils.appendOrSelect(this.parent, "g." + this.thresholdClass + "." + this.thresholdIdentifierClass).raise();
41
+ // Append threshold hoverable area
42
+ var thresholdRect = DOMUtils.appendOrSelect(this.threshold, "rect.threshold-hoverable-area");
43
+ // Append threshold line
44
+ var thresholdLine = DOMUtils.appendOrSelect(this.threshold, "line.threshold-line");
45
+ // Set threshold line color from configs options
46
+ // If not defined, the line takes the defined CSS color
47
+ thresholdLine.style("stroke", fillColor);
48
+ var scale = this.services.cartesianScales.getScaleByPosition(axisPosition);
49
+ var isVertical = [AxisPositions.LEFT, AxisPositions.RIGHT].includes(axisPosition);
50
+ var scaleType = this.services.cartesianScales.getScaleTypeByPosition(axisPosition);
51
+ var mainXScale = this.services.cartesianScales.getMainXScale();
52
+ var mainYScale = this.services.cartesianScales.getMainYScale();
53
+ var isScaleTypeLabels = scaleType === ScaleTypes.LABELS;
54
+ var _b = mainXScale.range(), xScaleStart = _b[0], xScaleEnd = _b[1];
55
+ var _c = mainYScale.range(), yScaleEnd = _c[0], yScaleStart = _c[1];
56
+ if (isVertical) {
57
+ // Position the threshold on the y scale value
58
+ var y = scale(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);
59
+ this.threshold
60
+ .transition(this.services.transitions.getTransition("threshold-update", animate))
61
+ .attr("transform", "translate(" + xScaleStart + ", " + y + ")");
62
+ // Set line end point on the x-axis
63
+ thresholdLine.attr("x2", xScaleEnd - xScaleStart);
64
+ // Set hoverable area width
65
+ thresholdRect.attr("width", xScaleEnd - xScaleStart);
66
+ }
67
+ else {
68
+ // Position the threshold on the x scale value
69
+ var x = scale(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);
70
+ this.threshold
71
+ .transition(this.services.transitions.getTransition("threshold-update", animate))
72
+ .attr("transform", "translate(" + x + ", " + yScaleStart + ")");
73
+ // Set line end point on the y-axis
74
+ thresholdLine.attr("y2", yScaleEnd - yScaleStart);
75
+ // Set hoverable area width and rotate it
76
+ thresholdRect.attr("width", yScaleEnd - yScaleStart);
77
+ thresholdRect.classed("rotate", true);
78
+ }
79
+ var self = this;
80
+ this.services.events.addEventListener(Events.Threshold.SHOW, function (e) {
81
+ var hovered = e.detail.hoveredElement.node();
82
+ // If is this threshold
83
+ if (hovered === self.threshold) {
84
+ // Set label position and show it
85
+ _this.setThresholdLabelPosition();
86
+ _this.label.classed("hidden", false);
87
+ }
88
+ });
89
+ this.services.events.addEventListener(Events.Threshold.HIDE, function (e) {
90
+ _this.label.classed("hidden", true);
91
+ });
92
+ this.appendThresholdLabel();
93
+ this.addEventListeners();
94
+ };
95
+ Threshold.prototype.getFormattedValue = function () {
96
+ var _a = this.configs, value = _a.value, axisPosition = _a.axisPosition;
97
+ var options = this.model.getOptions();
98
+ var scaleType = this.services.cartesianScales.getScaleTypeByPosition(axisPosition);
99
+ // If scale is time, format the threshold date as the ticks format
100
+ if (scaleType === ScaleTypes.TIME) {
101
+ var isVertical = [
102
+ AxisPositions.LEFT,
103
+ AxisPositions.RIGHT
104
+ ].includes(axisPosition);
105
+ var mainXScale = this.services.cartesianScales.getMainXScale();
106
+ var mainYScale = this.services.cartesianScales.getMainYScale();
107
+ var scale = isVertical ? mainYScale : mainXScale;
108
+ var timeScaleOptions = Tools.getProperty(options, "timeScale");
109
+ var timeInterval = computeTimeIntervalName(scale.ticks());
110
+ return formatTick(value, 0, timeInterval, timeScaleOptions);
111
+ }
112
+ return value.toLocaleString("en");
113
+ };
114
+ Threshold.prototype.appendThresholdLabel = function () {
115
+ var _a = this.configs, value = _a.value, valueFormatter = _a.valueFormatter, fillColor = _a.fillColor, _b = _a.label, label = _b === void 0 ? "Threshold" : _b;
116
+ var holder = select(this.services.domUtils.getHolder());
117
+ // Format the threshold value using valueFormatter if defined in user-provided options
118
+ var formattedValue = valueFormatter
119
+ ? valueFormatter(value)
120
+ : this.getFormattedValue();
121
+ this.label = DOMUtils.appendOrSelect(holder, "div." + this.thresholdClass + "--label." + this.thresholdIdentifierClass);
122
+ this.label
123
+ .html(label + ": " + formattedValue)
124
+ .classed("hidden", true)
125
+ .style("background-color", fillColor);
126
+ };
127
+ Threshold.prototype.setThresholdLabelPosition = function () {
128
+ var holder = this.services.domUtils.getHolder();
129
+ var target = this.label.node();
130
+ var mouseRelativePos = mouse(holder);
131
+ // Find out whether threshold label should be shown on the left or right side
132
+ var bestPlacementOption = this.positionService.findBestPlacementAt({
133
+ left: mouseRelativePos[0],
134
+ top: mouseRelativePos[1]
135
+ }, target, [
136
+ PLACEMENTS.RIGHT,
137
+ PLACEMENTS.LEFT,
138
+ PLACEMENTS.TOP,
139
+ PLACEMENTS.BOTTOM
140
+ ], function () { return ({
141
+ width: holder.offsetWidth,
142
+ height: holder.offsetHeight
143
+ }); });
144
+ // Get coordinates to where label should be positioned
145
+ var pos = this.positionService.findPositionAt({
146
+ left: mouseRelativePos[0],
147
+ top: mouseRelativePos[1]
148
+ }, target, bestPlacementOption);
149
+ this.positionService.setElement(target, pos);
150
+ };
151
+ Threshold.prototype.addEventListeners = function () {
152
+ var self = this;
153
+ // Add events to the threshold hoverable area
154
+ DOMUtils.appendOrSelect(this.threshold, "rect")
155
+ .on("mouseover mousemove", function () {
156
+ self.threshold.classed("active", true);
157
+ self.services.events.dispatchEvent(Events.Threshold.SHOW, {
158
+ hoveredElement: select(self.threshold)
159
+ });
160
+ })
161
+ .on("mouseout", function () {
162
+ self.threshold.classed("active", false);
163
+ self.services.events.dispatchEvent(Events.Threshold.HIDE, {
164
+ hoveredElement: select(self.threshold)
165
+ });
166
+ });
167
+ };
168
+ return Threshold;
169
+ }(Component));
170
+ export { Threshold };
171
+ //# sourceMappingURL=../../../src/components/essentials/threshold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold.js","sourceRoot":"","sources":["threshold.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C,0BAA0B;AAC1B,OAAO,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE9D,yCAAyC;AACzC,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAChE,OAAO,EACN,UAAU,EACV,uBAAuB,EACvB,MAAM,4BAA4B,CAAC;AAEpC;IAA+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,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED,qCAAiB,GAAjB;QACC,IAAM,IAAI,GAAG,IAAI,CAAC;QAElB,6CAA6C;QAC7C,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;aAC7C,EAAE,CAAC,qBAAqB,EAAE;YAC1B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;gBACzD,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;aACtC,CAAC,CAAC;QACJ,CAAC,CAAC;aACD,EAAE,CAAC,UAAU,EAAE;YACf,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;gBACzD,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;aACtC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACF,gBAAC;AAAD,CAAC,AAxND,CAA+B,SAAS,GAwNvC","sourcesContent":["import { Component } from \"../component\";\nimport { Tools } from \"../../tools\";\nimport { DOMUtils } from \"../../services\";\nimport { ChartModel } from \"../../model\";\nimport { AxisPositions, Events, ScaleTypes } from \"../../interfaces\";\nimport { select, mouse } from \"d3-selection\";\n\n// Carbon position service\nimport Position, { PLACEMENTS } from \"@carbon/utils-position\";\n\n// import the settings for the css prefix\nimport settings from \"carbon-components/es/globals/js/settings\";\nimport {\n\tformatTick,\n\tcomputeTimeIntervalName\n} from \"../../services/time-series\";\n\nexport class Threshold extends Component {\n\ttype = \"threshold\";\n\n\tthreshold: any;\n\tthresholdClass: string;\n\tthresholdIdentifierClass: string;\n\n\tlabel: any;\n\n\tpositionService = new Position();\n\n\tconstructor(model: ChartModel, services: any, configs: any) {\n\t\tsuper(model, services, configs);\n\t}\n\n\trender(animate = false) {\n\t\tconst { value, fillColor, axisPosition, index } = this.configs;\n\t\tconst chartprefix = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"style\",\n\t\t\t\"prefix\"\n\t\t);\n\t\tthis.thresholdClass = `${settings.prefix}--${chartprefix}--threshold`;\n\t\t// We can have multiple thresholds, set an unique identifier\n\t\tthis.thresholdIdentifierClass = `${axisPosition}-${index}`;\n\n\t\tthis.threshold = DOMUtils.appendOrSelect(\n\t\t\tthis.parent,\n\t\t\t`g.${this.thresholdClass}.${this.thresholdIdentifierClass}`\n\t\t).raise();\n\t\t// Append threshold hoverable area\n\t\tconst thresholdRect = DOMUtils.appendOrSelect(\n\t\t\tthis.threshold,\n\t\t\t`rect.threshold-hoverable-area`\n\t\t);\n\t\t// Append threshold line\n\t\tconst thresholdLine = DOMUtils.appendOrSelect(\n\t\t\tthis.threshold,\n\t\t\t`line.threshold-line`\n\t\t);\n\n\t\t// Set threshold line color from configs options\n\t\t// If not defined, the line takes the defined CSS color\n\t\tthresholdLine.style(\"stroke\", fillColor);\n\n\t\tconst scale = this.services.cartesianScales.getScaleByPosition(\n\t\t\taxisPosition\n\t\t);\n\t\tconst isVertical = [AxisPositions.LEFT, AxisPositions.RIGHT].includes(\n\t\t\taxisPosition\n\t\t);\n\t\tconst scaleType = this.services.cartesianScales.getScaleTypeByPosition(\n\t\t\taxisPosition\n\t\t);\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\t\tconst isScaleTypeLabels = scaleType === ScaleTypes.LABELS;\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\tif (isVertical) {\n\t\t\t// Position the threshold on the y scale value\n\t\t\tconst y = scale(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);\n\t\t\tthis.threshold\n\t\t\t\t.transition(\n\t\t\t\t\tthis.services.transitions.getTransition(\n\t\t\t\t\t\t\"threshold-update\",\n\t\t\t\t\t\tanimate\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.attr(\"transform\", `translate(${xScaleStart}, ${y})`);\n\t\t\t// Set line end point on the x-axis\n\t\t\tthresholdLine.attr(\"x2\", xScaleEnd - xScaleStart);\n\t\t\t// Set hoverable area width\n\t\t\tthresholdRect.attr(\"width\", xScaleEnd - xScaleStart);\n\t\t} else {\n\t\t\t// Position the threshold on the x scale value\n\t\t\tconst x = scale(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);\n\t\t\tthis.threshold\n\t\t\t\t.transition(\n\t\t\t\t\tthis.services.transitions.getTransition(\n\t\t\t\t\t\t\"threshold-update\",\n\t\t\t\t\t\tanimate\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.attr(\"transform\", `translate(${x}, ${yScaleStart})`);\n\t\t\t// Set line end point on the y-axis\n\t\t\tthresholdLine.attr(\"y2\", yScaleEnd - yScaleStart);\n\t\t\t// Set hoverable area width and rotate it\n\t\t\tthresholdRect.attr(\"width\", yScaleEnd - yScaleStart);\n\t\t\tthresholdRect.classed(\"rotate\", true);\n\t\t}\n\n\t\tconst self = this;\n\t\tthis.services.events.addEventListener(Events.Threshold.SHOW, e => {\n\t\t\tconst hovered = e.detail.hoveredElement.node();\n\t\t\t// If is this threshold\n\t\t\tif (hovered === self.threshold) {\n\t\t\t\t// Set label position and show it\n\t\t\t\tthis.setThresholdLabelPosition();\n\t\t\t\tthis.label.classed(\"hidden\", false);\n\t\t\t}\n\t\t});\n\n\t\tthis.services.events.addEventListener(Events.Threshold.HIDE, e => {\n\t\t\tthis.label.classed(\"hidden\", true);\n\t\t});\n\n\t\tthis.appendThresholdLabel();\n\n\t\tthis.addEventListeners();\n\t}\n\n\tgetFormattedValue() {\n\t\tconst { value, axisPosition } = this.configs;\n\t\tconst options = this.model.getOptions();\n\t\tconst scaleType = this.services.cartesianScales.getScaleTypeByPosition(\n\t\t\taxisPosition\n\t\t);\n\n\t\t// If scale is time, format the threshold date as the ticks format\n\t\tif (scaleType === ScaleTypes.TIME) {\n\t\t\tconst isVertical = [\n\t\t\t\tAxisPositions.LEFT,\n\t\t\t\tAxisPositions.RIGHT\n\t\t\t].includes(axisPosition);\n\t\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\t\t\tconst scale = isVertical ? mainYScale : mainXScale;\n\n\t\t\tconst timeScaleOptions = Tools.getProperty(options, \"timeScale\");\n\t\t\tconst timeInterval = computeTimeIntervalName(scale.ticks());\n\t\t\treturn formatTick(value, 0, timeInterval, timeScaleOptions);\n\t\t}\n\n\t\treturn value.toLocaleString(\"en\");\n\t}\n\n\tappendThresholdLabel() {\n\t\tconst {\n\t\t\tvalue,\n\t\t\tvalueFormatter,\n\t\t\tfillColor,\n\t\t\tlabel = \"Threshold\"\n\t\t} = this.configs;\n\t\tconst holder = select(this.services.domUtils.getHolder());\n\t\t// Format the threshold value using valueFormatter if defined in user-provided options\n\t\tconst formattedValue = valueFormatter\n\t\t\t? valueFormatter(value)\n\t\t\t: this.getFormattedValue();\n\n\t\tthis.label = DOMUtils.appendOrSelect(\n\t\t\tholder,\n\t\t\t`div.${this.thresholdClass}--label.${this.thresholdIdentifierClass}`\n\t\t);\n\t\tthis.label\n\t\t\t.html(`${label}: ${formattedValue}`)\n\t\t\t.classed(\"hidden\", true)\n\t\t\t.style(\"background-color\", fillColor);\n\t}\n\n\tsetThresholdLabelPosition() {\n\t\tconst holder = this.services.domUtils.getHolder();\n\t\tconst target = this.label.node();\n\t\tconst mouseRelativePos = mouse(holder);\n\n\t\t// Find out whether threshold label should be shown on the left or right side\n\t\tconst bestPlacementOption = this.positionService.findBestPlacementAt(\n\t\t\t{\n\t\t\t\tleft: mouseRelativePos[0],\n\t\t\t\ttop: mouseRelativePos[1]\n\t\t\t},\n\t\t\ttarget,\n\t\t\t[\n\t\t\t\tPLACEMENTS.RIGHT,\n\t\t\t\tPLACEMENTS.LEFT,\n\t\t\t\tPLACEMENTS.TOP,\n\t\t\t\tPLACEMENTS.BOTTOM\n\t\t\t],\n\t\t\t() => ({\n\t\t\t\twidth: holder.offsetWidth,\n\t\t\t\theight: holder.offsetHeight\n\t\t\t})\n\t\t);\n\n\t\t// Get coordinates to where label should be positioned\n\t\tconst pos = this.positionService.findPositionAt(\n\t\t\t{\n\t\t\t\tleft: mouseRelativePos[0],\n\t\t\t\ttop: mouseRelativePos[1]\n\t\t\t},\n\t\t\ttarget,\n\t\t\tbestPlacementOption\n\t\t);\n\n\t\tthis.positionService.setElement(target, pos);\n\t}\n\n\taddEventListeners() {\n\t\tconst self = this;\n\n\t\t// Add events to the threshold hoverable area\n\t\tDOMUtils.appendOrSelect(this.threshold, \"rect\")\n\t\t\t.on(\"mouseover mousemove\", function() {\n\t\t\t\tself.threshold.classed(\"active\", true);\n\t\t\t\tself.services.events.dispatchEvent(Events.Threshold.SHOW, {\n\t\t\t\t\thoveredElement: select(self.threshold)\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on(\"mouseout\", function() {\n\t\t\t\tself.threshold.classed(\"active\", false);\n\t\t\t\tself.services.events.dispatchEvent(Events.Threshold.HIDE, {\n\t\t\t\t\thoveredElement: select(self.threshold)\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n"]}
@@ -36,17 +36,19 @@ var Title = /** @class */ (function (_super) {
36
36
  // check if the title is too big for the containing svg
37
37
  if (title.node().getComputedTextLength() > containerWidth) {
38
38
  // append the ellipses to their own tspan to calculate the text length
39
- title.append("tspan")
40
- .text("...");
39
+ title.append("tspan").text("...");
41
40
  // get the bounding width including the elipses '...'
42
- var tspanLength = DOMUtils.appendOrSelect(title, "tspan").node().getComputedTextLength();
41
+ var tspanLength = DOMUtils.appendOrSelect(title, "tspan")
42
+ .node()
43
+ .getComputedTextLength();
43
44
  var truncatedSize = Math.floor(containerWidth - tspanLength);
44
45
  var titleString = this.model.getOptions().title;
45
46
  // get the index for creating the max length substring that fit within the svg
46
47
  // use one less than the index to avoid crowding (the elipsis)
47
48
  var substringIndex = this.getSubstringIndex(title.node(), 0, titleString.length - 1, truncatedSize);
48
49
  // use the substring as the title
49
- title.html(titleString.substring(0, substringIndex - 1))
50
+ title
51
+ .html(titleString.substring(0, substringIndex - 1))
50
52
  .append("tspan")
51
53
  .text("...");
52
54
  // add events for displaying the tooltip with the title
@@ -1 +1 @@
1
- {"version":3,"file":"title.js","sourceRoot":"","sources":["title.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE1D;IAA2B,yBAAS;IAApC;QAAA,qEAqFC;QApFA,UAAI,GAAG,OAAO,CAAC;;IAoFhB,CAAC;IAlFA;;OAEG;IACH,6BAAa,GAAb;QACC,+EAA+E;QAC/E,IAAM,cAAc,GAAG,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC;QAChH,IAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEjE,0DAA0D;QAC1D,IAAI,cAAc,IAAI,CAAC,EAAE;YACxB,OAAO;SACP;QAED,uDAAuD;QACvD,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,qBAAqB,EAAE,GAAG,cAAc,EAAE;YAC1D,sEAAsE;YACtE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;iBACnB,IAAI,CAAC,K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nC,IAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;aACf,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;aACb,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;QAEtC,gEAAgE;QAChE,IAAI,CAAC,aAAa,EAAE,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACO,iCAAiB,GAA3B,UAA4B,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK;QACnD,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE;YAC7C,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;SACxD;aAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE;YACpD,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE;gBACjD,OAAO,GAAG,CAAC;aACX;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;SACtD;aAAM;YACN,OAAO,GAAG,CAAC;SACX;IACF,CAAC;IACF,YAAC;AAAD,CAAC,AArFD,CAA2B,SAAS,GAqFnC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { DOMUtils } from \"../../services\";\nimport { TooltipTypes, Events } from \"./../../interfaces\";\n\nexport class Title extends Component {\n\ttype = \"title\";\n\n\t/**\n\t * Truncates title creating ellipses and attaching tooltip for exposing full title.\n\t */\n\ttruncateTitle() {\n\t\t// get a reference to the title elements to calculate the size the title can be\n\t\tconst containerWidth = DOMUtils.getSVGElementSize(this.services.domUtils.getMainSVG(), { useAttr: true }).width;\n\t\tconst title = DOMUtils.appendOrSelect(this.parent, \"text.title\");\n\n\t\t// sanity check to prevent stack overflow on binary search\n\t\tif (containerWidth <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// check if the title is too big for the containing svg\n\t\tif (title.node().getComputedTextLength() > containerWidth) {\n\t\t\t// append the ellipses to their own tspan to calculate the text length\n\t\t\ttitle.append(\"tspan\")\n\t\t\t\t.text(\"...\");\n\n\t\t\t// get the bounding width including the elipses '...'\n\t\t\tconst tspanLength = DOMUtils.appendOrSelect(title, \"tspan\").node().getComputedTextLength();\n\t\t\tconst truncatedSize = Math.floor(containerWidth - tspanLength);\n\t\t\tconst titleString = this.model.getOptions().title;\n\n\t\t\t// get the index for creating the max length substring that fit within the svg\n\t\t\t// use one less than the index to avoid crowding (the elipsis)\n\t\t\tconst substringIndex = this.getSubstringIndex(title.node(), 0, titleString.length - 1, truncatedSize);\n\n\t\t\t// use the substring as the title\n\t\t\ttitle.html(titleString.substring(0, substringIndex - 1))\n\t\t\t\t.append(\"tspan\")\n\t\t\t\t.text(\"...\");\n\n\t\t\t// add events for displaying the tooltip with the title\n\t\t\tconst self = this;\n\t\t\ttitle\n\t\t\t\t.on(\"mouseenter\", function() {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\t\t\thoveredElement: title,\n\t\t\t\t\t\ttype: TooltipTypes.TITLE\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.on(\"mouseout\", function() {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE, {\n\t\t\t\t\t\thoveredElement: title\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\t}\n\n\trender() {\n\t\tconst svg = this.getContainerSVG();\n\n\t\tconst text = DOMUtils.appendOrSelect(svg, \"text.title\");\n\t\ttext.attr(\"x\", 0)\n\t\t\t.attr(\"y\", 20)\n\t\t\t.html(this.model.getOptions().title);\n\n\t\t// title needs to first render so that we can check for overflow\n\t\tthis.truncateTitle();\n\t}\n\n\t/**\n\t * Returns the index for a maximum length substring that is less than the width parameter.\n\t * @param title the title node used for getting the text lengths of substrings\n\t * @param start the start index for the binary search\n\t * @param end the end index for the binary search\n\t * @param width the width of the svg container that holds the title\n\t */\n\tprotected getSubstringIndex(title, start, end, width) {\n\t\tconst mid = Math.floor((end + start) / 2);\n\t\tif (title.getSubStringLength(0, mid) > width) {\n\t\t\treturn this.getSubstringIndex(title, start, mid, width);\n\t\t} else if (title.getSubStringLength(0, mid) < width) {\n\t\t\tif (title.getSubStringLength(0, mid + 1) > width) {\n\t\t\t\treturn mid;\n\t\t\t}\n\t\t\treturn this.getSubstringIndex(title, mid, end, width);\n\t\t} else {\n\t\t\treturn mid;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"title.js","sourceRoot":"","sources":["title.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE1D;IAA2B,yBAAS;IAApC;QAAA,qEA+FC;QA9FA,UAAI,GAAG,OAAO,CAAC;;IA8FhB,CAAC;IA5FA;;OAEG;IACH,6BAAa,GAAb;QACC,+EAA+E;QAC/E,IAAM,cAAc,GAAG,QAAQ,CAAC,iBAAiB,CAChD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,EACnC,EAAE,OAAO,EAAE,IAAI,EAAE,CACjB,CAAC,KAAK,CAAC;QACR,IAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM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AAC;SACtD;aAAM;YACN,OAAO,GAAG,CAAC;SACX;IACF,CAAC;IACF,YAAC;AAAD,CAAC,AA/FD,CAA2B,SAAS,GA+FnC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { DOMUtils } from \"../../services\";\nimport { TooltipTypes, Events } from \"./../../interfaces\";\n\nexport class Title extends Component {\n\ttype = \"title\";\n\n\t/**\n\t * Truncates title creating ellipses and attaching tooltip for exposing full title.\n\t */\n\ttruncateTitle() {\n\t\t// get a reference to the title elements to calculate the size the title can be\n\t\tconst containerWidth = DOMUtils.getSVGElementSize(\n\t\t\tthis.services.domUtils.getMainSVG(),\n\t\t\t{ useAttr: true }\n\t\t).width;\n\t\tconst title = DOMUtils.appendOrSelect(this.parent, \"text.title\");\n\n\t\t// sanity check to prevent stack overflow on binary search\n\t\tif (containerWidth <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// check if the title is too big for the containing svg\n\t\tif (title.node().getComputedTextLength() > containerWidth) {\n\t\t\t// append the ellipses to their own tspan to calculate the text length\n\t\t\ttitle.append(\"tspan\").text(\"...\");\n\n\t\t\t// get the bounding width including the elipses '...'\n\t\t\tconst tspanLength = DOMUtils.appendOrSelect(title, \"tspan\")\n\t\t\t\t.node()\n\t\t\t\t.getComputedTextLength();\n\t\t\tconst truncatedSize = Math.floor(containerWidth - tspanLength);\n\t\t\tconst titleString = this.model.getOptions().title;\n\n\t\t\t// get the index for creating the max length substring that fit within the svg\n\t\t\t// use one less than the index to avoid crowding (the elipsis)\n\t\t\tconst substringIndex = this.getSubstringIndex(\n\t\t\t\ttitle.node(),\n\t\t\t\t0,\n\t\t\t\ttitleString.length - 1,\n\t\t\t\ttruncatedSize\n\t\t\t);\n\n\t\t\t// use the substring as the title\n\t\t\ttitle\n\t\t\t\t.html(titleString.substring(0, substringIndex - 1))\n\t\t\t\t.append(\"tspan\")\n\t\t\t\t.text(\"...\");\n\n\t\t\t// add events for displaying the tooltip with the title\n\t\t\tconst self = this;\n\t\t\ttitle\n\t\t\t\t.on(\"mouseenter\", function() {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\t\t\thoveredElement: title,\n\t\t\t\t\t\ttype: TooltipTypes.TITLE\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.on(\"mouseout\", function() {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE, {\n\t\t\t\t\t\thoveredElement: title\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\t}\n\n\trender() {\n\t\tconst svg = this.getContainerSVG();\n\n\t\tconst text = DOMUtils.appendOrSelect(svg, \"text.title\");\n\t\ttext.attr(\"x\", 0)\n\t\t\t.attr(\"y\", 20)\n\t\t\t.html(this.model.getOptions().title);\n\n\t\t// title needs to first render so that we can check for overflow\n\t\tthis.truncateTitle();\n\t}\n\n\t/**\n\t * Returns the index for a maximum length substring that is less than the width parameter.\n\t * @param title the title node used for getting the text lengths of substrings\n\t * @param start the start index for the binary search\n\t * @param end the end index for the binary search\n\t * @param width the width of the svg container that holds the title\n\t */\n\tprotected getSubstringIndex(title, start, end, width) {\n\t\tconst mid = Math.floor((end + start) / 2);\n\t\tif (title.getSubStringLength(0, mid) > width) {\n\t\t\treturn this.getSubstringIndex(title, start, mid, width);\n\t\t} else if (title.getSubStringLength(0, mid) < width) {\n\t\t\tif (title.getSubStringLength(0, mid + 1) > width) {\n\t\t\t\treturn mid;\n\t\t\t}\n\t\t\treturn this.getSubstringIndex(title, mid, end, width);\n\t\t} else {\n\t\t\treturn mid;\n\t\t}\n\t}\n}\n"]}
@@ -36,8 +36,10 @@ var TooltipBar = /** @class */ (function (_super) {
36
36
  // listen to show-tooltip Custom Events to render the tooltip
37
37
  this.services.events.addEventListener(Events.Tooltip.SHOW, function (e) {
38
38
  // check the type of tooltip and that it is enabled
39
- if ((e.detail.type === TooltipTypes.DATAPOINT && Tools.getProperty(_this.model.getOptions(), "tooltip", "datapoint", "enabled"))
40
- || (e.detail.type === TooltipTypes.GRIDLINE && Tools.getProperty(_this.model.getOptions(), "tooltip", "gridline", "enabled"))) {
39
+ if ((e.detail.type === TooltipTypes.DATAPOINT &&
40
+ Tools.getProperty(_this.model.getOptions(), "tooltip", "datapoint", "enabled")) ||
41
+ (e.detail.type === TooltipTypes.GRIDLINE &&
42
+ Tools.getProperty(_this.model.getOptions(), "tooltip", "gridline", "enabled"))) {
41
43
  var data = e.detail.hoveredElement.datum();
42
44
  var hoveredElement = e.detail.hoveredElement.node();
43
45
  var defaultHTML = void 0;
@@ -57,7 +59,9 @@ var TooltipBar = /** @class */ (function (_super) {
57
59
  }
58
60
  // if there is a provided tooltip HTML function call it and pass the defaultHTML
59
61
  if (Tools.getProperty(_this.model.getOptions(), "tooltip", "customHTML")) {
60
- tooltipTextContainer.html(_this.model.getOptions().tooltip.customHTML(data, defaultHTML));
62
+ tooltipTextContainer.html(_this.model
63
+ .getOptions()
64
+ .tooltip.customHTML(data, defaultHTML));
61
65
  }
62
66
  else {
63
67
  // default tooltip
@@ -71,7 +75,8 @@ var TooltipBar = /** @class */ (function (_super) {
71
75
  // use the chart size to enforce a max width on the tooltip
72
76
  var chart = DOMUtils.appendOrSelect(holder, "svg." + settings.prefix + "--" + chartprefix + "--chart-svg");
73
77
  // use the configs to determine how large the tooltip should be
74
- var tooltipMax = DOMUtils.getSVGElementSize(chart).width * Tools.getProperty(_this.model.getOptions(), "tooltip", "title", "width");
78
+ var tooltipMax = DOMUtils.getSVGElementSize(chart).width *
79
+ Tools.getProperty(_this.model.getOptions(), "tooltip", "title", "width");
75
80
  _this.tooltip.style("max-width", tooltipMax);
76
81
  // use tooltip.ts to get the tooltip html for titles
77
82
  tooltipTextContainer.html(_super.prototype.getTooltipHTML.call(_this, e.detail.hoveredElement, TooltipTypes.TITLE));
@@ -96,23 +101,29 @@ var TooltipBar = /** @class */ (function (_super) {
96
101
  if (data === undefined) {
97
102
  data = select(hoveredElement).datum();
98
103
  }
99
- var holderPosition = select(this.services.domUtils.getHolder()).node().getBoundingClientRect();
104
+ var holderPosition = select(this.services.domUtils.getHolder())
105
+ .node()
106
+ .getBoundingClientRect();
100
107
  var barPosition = hoveredElement.getBoundingClientRect();
101
108
  var verticalOffset = this.model.getOptions().tooltip.datapoint.verticalOffset;
102
109
  // if there is a negative value bar chart, need to place the tooltip below the bar
103
110
  if (data.value <= 0) {
104
111
  // negative bars
105
112
  var tooltipPos = {
106
- left: (barPosition.left - holderPosition.left) + barPosition.width / 2,
107
- top: (barPosition.bottom - holderPosition.top) + verticalOffset
113
+ left: barPosition.left -
114
+ holderPosition.left +
115
+ barPosition.width / 2,
116
+ top: barPosition.bottom - holderPosition.top + verticalOffset
108
117
  };
109
118
  return { placement: TooltipPosition.BOTTOM, position: tooltipPos };
110
119
  }
111
120
  else {
112
121
  // positive bars
113
122
  var tooltipPos = {
114
- left: (barPosition.left - holderPosition.left) + barPosition.width / 2,
115
- top: (barPosition.top - holderPosition.top) - verticalOffset
123
+ left: barPosition.left -
124
+ holderPosition.left +
125
+ barPosition.width / 2,
126
+ top: barPosition.top - holderPosition.top - verticalOffset
116
127
  };
117
128
  return { placement: TooltipPosition.TOP, position: tooltipPos };
118
129
  }
@@ -122,8 +133,9 @@ var TooltipBar = /** @class */ (function (_super) {
122
133
  * @param data associated values for the hovered bar
123
134
  */
124
135
  TooltipBar.prototype.getTooltipHTML = function (data) {
125
- var formattedValue = Tools.getProperty(this.model.getOptions(), "tooltip", "valueFormatter") ?
126
- this.model.getOptions().tooltip.valueFormatter(data.value) : data.value.toLocaleString("en");
136
+ var formattedValue = Tools.getProperty(this.model.getOptions(), "tooltip", "valueFormatter")
137
+ ? this.model.getOptions().tooltip.valueFormatter(data.value)
138
+ : data.value.toLocaleString("en");
127
139
  return "<div class=\"datapoint-tooltip\"><p class=\"value\">" + formattedValue + "</p></div>";
128
140
  };
129
141
  /**
@@ -136,23 +148,30 @@ var TooltipBar = /** @class */ (function (_super) {
136
148
  points.reverse();
137
149
  // in a vertical bar chart the tooltip should display in order of the drawn bars
138
150
  // in horizontal stacked bar, the order of the segments from Left to Right are displayed top down in tooltip
139
- if (this.services.cartesianScales.getOrientation() === CartesianOrientations.VERTICAL) {
151
+ if (this.services.cartesianScales.getOrientation() ===
152
+ CartesianOrientations.VERTICAL) {
140
153
  points.reverse();
141
154
  }
142
155
  // get the total for the stacked tooltip
143
156
  var total = points.reduce(function (sum, item) { return sum + item.value; }, 0);
144
157
  // format the total value
145
- total = Tools.getProperty(this.model.getOptions(), "tooltip", "valueFormatter") ?
146
- this.model.getOptions().tooltip.valueFormatter(total) : total.toLocaleString("en");
147
- return "<ul class='multi-tooltip'>" +
148
- points.map(function (datapoint) {
149
- var formattedValue = Tools.getProperty(_this.model.getOptions(), "tooltip", "valueFormatter") ?
150
- _this.model.getOptions().tooltip.valueFormatter(datapoint.value) : datapoint.value.toLocaleString("en");
158
+ total = Tools.getProperty(this.model.getOptions(), "tooltip", "valueFormatter")
159
+ ? this.model.getOptions().tooltip.valueFormatter(total)
160
+ : total.toLocaleString("en");
161
+ return ("<ul class='multi-tooltip'>" +
162
+ points
163
+ .map(function (datapoint) {
164
+ var formattedValue = Tools.getProperty(_this.model.getOptions(), "tooltip", "valueFormatter")
165
+ ? _this.model
166
+ .getOptions()
167
+ .tooltip.valueFormatter(datapoint.value)
168
+ : datapoint.value.toLocaleString("en");
151
169
  // For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.
152
170
  var indicatorColor = _this.model.getStrokeColor(datapoint.datasetLabel, datapoint.label);
153
171
  return "\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:" + indicatorColor + "\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">" + datapoint.datasetLabel + "</p>\n\t\t\t\t\t\t<p class=\"value\">" + formattedValue + "</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>";
154
- }).join("") +
155
- ("<li>\n\t\t\t\t\t<div class='total-val'>\n\t\t\t\t\t\t<p class='label'>Total</p>\n\t\t\t\t\t\t<p class='value'>" + total + "</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t</ul>");
172
+ })
173
+ .join("") +
174
+ ("<li>\n\t\t\t\t\t<div class='total-val'>\n\t\t\t\t\t\t<p class='label'>Total</p>\n\t\t\t\t\t\t<p class='value'>" + total + "</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t</ul>"));
156
175
  };
157
176
  return TooltipBar;
158
177
  }(Tooltip));
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-bar.js","sourceRoot":"","sources":["tooltip-bar.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACN,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,MAAM,EACN,MAAM,oBAAoB,CAAC;AAE5B,yCAAyC;AACzC,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAEhE,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;IAAgC,8BAAO;IAAvC;;IAmKA,CAAC;IAlKA,yBAAI,GAAJ;QAAA,iBAqEC;QApEA,2BAA2B;QAC3B,IAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QAC1D,IAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAClF,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,SAAO,QAAQ,CAAC,MAAM,UAAK,WAAW,cAAW,CAAC,CAAC;QAElG,o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from \"../../services\";\nimport {\n\tTooltipPosition,\n\tTooltipTypes,\n\tCartesianOrientations,\n\tEvents\n} from \"./../../interfaces\";\n\n// import the settings for the css prefix\nimport settings from \"carbon-components/es/globals/js/settings\";\n\n// D3 Imports\nimport { select } from \"d3-selection\";\n\nexport class TooltipBar extends Tooltip {\n\tinit() {\n\t\t// Grab the tooltip element\n\t\tconst holder = select(this.services.domUtils.getHolder());\n\t\tconst chartprefix = Tools.getProperty(this.model.getOptions(), \"style\", \"prefix\");\n\t\tthis.tooltip = DOMUtils.appendOrSelect(holder, `div.${settings.prefix}--${chartprefix}--tooltip`);\n\n\t\t// Apply html content to the tooltip\n\t\tconst tooltipTextContainer = DOMUtils.appendOrSelect(this.tooltip, \"div.content-box\");\n\t\tthis.tooltip.style(\"max-width\", null);\n\n\t\t// listen to show-tooltip Custom Events to render the tooltip\n\t\tthis.services.events.addEventListener(Events.Tooltip.SHOW, e => {\n\t\t\t// check the type of tooltip and that it is enabled\n\t\t\tif ((e.detail.type === TooltipTypes.DATAPOINT && Tools.getProperty(this.model.getOptions(), \"tooltip\", \"datapoint\", \"enabled\"))\n\t\t\t\t|| (e.detail.type === TooltipTypes.GRIDLINE && Tools.getProperty(this.model.getOptions(), \"tooltip\", \"gridline\", \"enabled\")) ) {\n\n\t\t\t\tlet data = e.detail.hoveredElement.datum() as any;\n\t\t\t\tconst hoveredElement = e.detail.hoveredElement.node();\n\n\t\t\t\tlet defaultHTML;\n\t\t\t\tif (e.detail.multidata) {\n\t\t\t\t\t// multi tooltip\n\t\t\t\t\tdata = e.detail.multidata;\n\t\t\t\t\tdefaultHTML = this.getMultilineTooltipHTML(data);\n\t\t\t\t} else {\n\t\t\t\t\tif (e.detail.data) {\n\t\t\t\t\t\tdata = e.detail.data;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdata = e.detail.hoveredElement.datum();\n\t\t\t\t\t}\n\n\t\t\t\t\tdefaultHTML = this.getTooltipHTML(data);\n\t\t\t\t}\n\n\t\t\t\t// if there is a provided tooltip HTML function call it and pass the defaultHTML\n\t\t\t\tif (Tools.getProperty(this.model.getOptions(), \"tooltip\", \"customHTML\")) {\n\t\t\t\t\ttooltipTextContainer.html(this.model.getOptions().tooltip.customHTML(data, defaultHTML));\n\t\t\t\t} else {\n\t\t\t\t\t// default tooltip\n\t\t\t\t\ttooltipTextContainer.html(defaultHTML);\n\t\t\t\t}\n\n\t\t\t\tconst position = this.getTooltipPosition(hoveredElement, data);\n\t\t\t\t// Position the tooltip relative to the bars\n\t\t\t\tthis.positionTooltip(e.detail.multidata ? undefined : position );\n\n\t\t\t} else if (e.detail.type === TooltipTypes.TITLE) {\n\t\t\t\t// use the chart size to enforce a max width on the tooltip\n\t\t\t\tconst chart = DOMUtils.appendOrSelect(holder, `svg.${settings.prefix}--${chartprefix}--chart-svg`);\n\t\t\t\t// use the configs to determine how large the tooltip should be\n\t\t\t\tconst tooltipMax = DOMUtils.getSVGElementSize(chart).width * Tools.getProperty(this.model.getOptions(), \"tooltip\", \"title\", \"width\");\n\t\t\t\tthis.tooltip.style(\"max-width\", tooltipMax);\n\n\t\t\t\t// use tooltip.ts to get the tooltip html for titles\n\t\t\t\ttooltipTextContainer.html(super.getTooltipHTML(e.detail.hoveredElement, TooltipTypes.TITLE));\n\n\t\t\t\t// get the position based on the title positioning (static)\n\t\t\t\tconst position = super.getTooltipPosition(e.detail.hoveredElement.node());\n\t\t\t\tthis.positionTooltip(position);\n\t\t\t}\n\n\t\t\t// Fade in\n\t\t\tthis.tooltip.classed(\"hidden\", false);\n\t\t});\n\n\t\t// listen to hide-tooltip Custom Events to hide the tooltip\n\t\tthis.services.events.addEventListener(Events.Tooltip.HIDE, () => {\n\t\t\tthis.tooltip.classed(\"hidden\", true);\n\t\t});\n\t}\n\n\t/**\n\t * Get the position of the tooltip relative to the active hovered bar. Tooltip should appear above\n\t * positive valued data and below negative value data.\n\t * @param hoveredElement\n\t */\n\tgetTooltipPosition(hoveredElement, data?: any) {\n\t\tif (data === undefined) {\n\t\t\tdata = select(hoveredElement).datum() as any;\n\t\t}\n\n\t\tconst holderPosition = select(this.services.domUtils.getHolder()).node().getBoundingClientRect();\n\t\tconst barPosition = hoveredElement.getBoundingClientRect();\n\n\t\tconst { verticalOffset } = this.model.getOptions().tooltip.datapoint;\n\t\t// if there is a negative value bar chart, need to place the tooltip below the bar\n\t\tif (data.value <= 0) {\n\t\t\t// negative bars\n\t\t\tconst tooltipPos = {\n\t\t\t\tleft: (barPosition.left - holderPosition.left) + barPosition.width / 2,\n\t\t\t\ttop: (barPosition.bottom - holderPosition.top) + verticalOffset\n\t\t\t};\n\n\t\t\treturn {placement: TooltipPosition.BOTTOM, position: tooltipPos};\n\t\t} else {\n\t\t\t// positive bars\n\t\t\tconst tooltipPos = {\n\t\t\t\tleft: (barPosition.left - holderPosition.left) + barPosition.width / 2,\n\t\t\t\ttop: (barPosition.top - holderPosition.top) - verticalOffset\n\t\t\t};\n\n\t\t\treturn {placement: TooltipPosition.TOP, position: tooltipPos};\n\t\t}\n\t}\n\n\t/**\n\t * Returns the html for the bar single point tooltip\n\t * @param data associated values for the hovered bar\n\t */\n\tgetTooltipHTML(data: any) {\n\t\tconst formattedValue = Tools.getProperty(this.model.getOptions(), \"tooltip\", \"valueFormatter\") ?\n\t\tthis.model.getOptions().tooltip.valueFormatter(data.value) : data.value.toLocaleString(\"en\");\n\n\t\treturn `<div class=\"datapoint-tooltip\"><p class=\"value\">${formattedValue}</p></div>`;\n\t}\n\n\t/**\n\t * Multip tooltips for bar charts include totals for each stack\n\t * @param data\n\t */\n\tgetMultilineTooltipHTML(data: any) {\n\t\tconst points = data;\n\n\t\tpoints.reverse();\n\t\t// in a vertical bar chart the tooltip should display in order of the drawn bars\n\t\t// in horizontal stacked bar, the order of the segments from Left to Right are displayed top down in tooltip\n\t\tif (this.services.cartesianScales.getOrientation() === CartesianOrientations.VERTICAL) {\n\t\t\tpoints.reverse();\n\t\t}\n\n\t\t// get the total for the stacked tooltip\n\t\tlet total = points.reduce((sum, item) => sum + item.value, 0);\n\n\t\t// format the total value\n\t\ttotal = Tools.getProperty(this.model.getOptions(), \"tooltip\", \"valueFormatter\") ?\n\t\tthis.model.getOptions().tooltip.valueFormatter(total) : total.toLocaleString(\"en\");\n\n\t\treturn \"<ul class='multi-tooltip'>\" +\n\t\t\tpoints.map(datapoint => {\n\t\t\t\tconst formattedValue = Tools.getProperty(this.model.getOptions(), \"tooltip\", \"valueFormatter\") ?\n\t\t\t\tthis.model.getOptions().tooltip.valueFormatter(datapoint.value) : datapoint.value.toLocaleString(\"en\");\n\n\t\t\t\t// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.\n\t\t\t\tconst indicatorColor = this.model.getStrokeColor(datapoint.datasetLabel, datapoint.label);\n\n\t\t\t\treturn `\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:${indicatorColor}\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">${datapoint.datasetLabel}</p>\n\t\t\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>`;\n\t\t\t}).join(\"\") +\n\t\t\t\t`<li>\n\t\t\t\t\t<div class='total-val'>\n\t\t\t\t\t\t<p class='label'>Total</p>\n\t\t\t\t\t\t<p class='value'>${total}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t</ul>`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"tooltip-bar.js","sourceRoot":"","sources":["tooltip-bar.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACN,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,MAAM,EACN,MAAM,oBAAoB,CAAC;AAE5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AC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAExC,2GAA2G;gBAC3G,IAAM,cAAc,GAAG,KAAI,CAAC,KAAK,CAAC,cAAc,CAC/C,SAAS,CAAC,YAAY,EACtB,SAAS,CAAC,KAAK,CACf,CAAC;gBAEF,OAAO,0GAGuB,cAAc,wEACxB,SAAS,CAAC,YAAY,6CACtB,cAAc,0CAE7B,CAAC;YACP,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC;aACV,mHAGsB,KAAK,uDAGrB,CAAA,CACN,CAAC;IACH,CAAC;IACF,iBAAC;AAAD,CAAC,AAvPD,CAAgC,OAAO,GAuPtC","sourcesContent":["import { Tooltip } from \"./tooltip\";\nimport { Tools } from \"../../tools\";\nimport { DOMUtils } from \"../../services\";\nimport {\n\tTooltipPosition,\n\tTooltipTypes,\n\tCartesianOrientations,\n\tEvents\n} from \"./../../interfaces\";\n\n// import the settings for the css prefix\nimport settings from \"carbon-components/es/globals/js/settings\";\n\n// D3 Imports\nimport { select } from \"d3-selection\";\n\nexport class TooltipBar extends Tooltip {\n\tinit() {\n\t\t// Grab the tooltip element\n\t\tconst holder = select(this.services.domUtils.getHolder());\n\t\tconst chartprefix = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"style\",\n\t\t\t\"prefix\"\n\t\t);\n\t\tthis.tooltip = DOMUtils.appendOrSelect(\n\t\t\tholder,\n\t\t\t`div.${settings.prefix}--${chartprefix}--tooltip`\n\t\t);\n\n\t\t// Apply html content to the tooltip\n\t\tconst tooltipTextContainer = DOMUtils.appendOrSelect(\n\t\t\tthis.tooltip,\n\t\t\t\"div.content-box\"\n\t\t);\n\t\tthis.tooltip.style(\"max-width\", null);\n\n\t\t// listen to show-tooltip Custom Events to render the tooltip\n\t\tthis.services.events.addEventListener(Events.Tooltip.SHOW, e => {\n\t\t\t// check the type of tooltip and that it is enabled\n\t\t\tif (\n\t\t\t\t(e.detail.type === TooltipTypes.DATAPOINT &&\n\t\t\t\t\tTools.getProperty(\n\t\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t\t\"tooltip\",\n\t\t\t\t\t\t\"datapoint\",\n\t\t\t\t\t\t\"enabled\"\n\t\t\t\t\t)) ||\n\t\t\t\t(e.detail.type === TooltipTypes.GRIDLINE &&\n\t\t\t\t\tTools.getProperty(\n\t\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t\t\"tooltip\",\n\t\t\t\t\t\t\"gridline\",\n\t\t\t\t\t\t\"enabled\"\n\t\t\t\t\t))\n\t\t\t) {\n\t\t\t\tlet data = e.detail.hoveredElement.datum() as any;\n\t\t\t\tconst hoveredElement = e.detail.hoveredElement.node();\n\n\t\t\t\tlet defaultHTML;\n\t\t\t\tif (e.detail.multidata) {\n\t\t\t\t\t// multi tooltip\n\t\t\t\t\tdata = e.detail.multidata;\n\t\t\t\t\tdefaultHTML = this.getMultilineTooltipHTML(data);\n\t\t\t\t} else {\n\t\t\t\t\tif (e.detail.data) {\n\t\t\t\t\t\tdata = e.detail.data;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdata = e.detail.hoveredElement.datum();\n\t\t\t\t\t}\n\n\t\t\t\t\tdefaultHTML = this.getTooltipHTML(data);\n\t\t\t\t}\n\n\t\t\t\t// if there is a provided tooltip HTML function call it and pass the defaultHTML\n\t\t\t\tif (\n\t\t\t\t\tTools.getProperty(\n\t\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t\t\"tooltip\",\n\t\t\t\t\t\t\"customHTML\"\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\ttooltipTextContainer.html(\n\t\t\t\t\t\tthis.model\n\t\t\t\t\t\t\t.getOptions()\n\t\t\t\t\t\t\t.tooltip.customHTML(data, defaultHTML)\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// default tooltip\n\t\t\t\t\ttooltipTextContainer.html(defaultHTML);\n\t\t\t\t}\n\n\t\t\t\tconst position = this.getTooltipPosition(hoveredElement, data);\n\t\t\t\t// Position the tooltip relative to the bars\n\t\t\t\tthis.positionTooltip(e.detail.multidata ? undefined : position);\n\t\t\t} else if (e.detail.type === TooltipTypes.TITLE) {\n\t\t\t\t// use the chart size to enforce a max width on the tooltip\n\t\t\t\tconst chart = DOMUtils.appendOrSelect(\n\t\t\t\t\tholder,\n\t\t\t\t\t`svg.${settings.prefix}--${chartprefix}--chart-svg`\n\t\t\t\t);\n\t\t\t\t// use the configs to determine how large the tooltip should be\n\t\t\t\tconst tooltipMax =\n\t\t\t\t\tDOMUtils.getSVGElementSize(chart).width *\n\t\t\t\t\tTools.getProperty(\n\t\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t\t\"tooltip\",\n\t\t\t\t\t\t\"title\",\n\t\t\t\t\t\t\"width\"\n\t\t\t\t\t);\n\t\t\t\tthis.tooltip.style(\"max-width\", tooltipMax);\n\n\t\t\t\t// use tooltip.ts to get the tooltip html for titles\n\t\t\t\ttooltipTextContainer.html(\n\t\t\t\t\tsuper.getTooltipHTML(\n\t\t\t\t\t\te.detail.hoveredElement,\n\t\t\t\t\t\tTooltipTypes.TITLE\n\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\t// get the position based on the title positioning (static)\n\t\t\t\tconst position = super.getTooltipPosition(\n\t\t\t\t\te.detail.hoveredElement.node()\n\t\t\t\t);\n\t\t\t\tthis.positionTooltip(position);\n\t\t\t}\n\n\t\t\t// Fade in\n\t\t\tthis.tooltip.classed(\"hidden\", false);\n\t\t});\n\n\t\t// listen to hide-tooltip Custom Events to hide the tooltip\n\t\tthis.services.events.addEventListener(Events.Tooltip.HIDE, () => {\n\t\t\tthis.tooltip.classed(\"hidden\", true);\n\t\t});\n\t}\n\n\t/**\n\t * Get the position of the tooltip relative to the active hovered bar. Tooltip should appear above\n\t * positive valued data and below negative value data.\n\t * @param hoveredElement\n\t */\n\tgetTooltipPosition(hoveredElement, data?: any) {\n\t\tif (data === undefined) {\n\t\t\tdata = select(hoveredElement).datum() as any;\n\t\t}\n\n\t\tconst holderPosition = select(this.services.domUtils.getHolder())\n\t\t\t.node()\n\t\t\t.getBoundingClientRect();\n\t\tconst barPosition = hoveredElement.getBoundingClientRect();\n\n\t\tconst { verticalOffset } = this.model.getOptions().tooltip.datapoint;\n\t\t// if there is a negative value bar chart, need to place the tooltip below the bar\n\t\tif (data.value <= 0) {\n\t\t\t// negative bars\n\t\t\tconst tooltipPos = {\n\t\t\t\tleft:\n\t\t\t\t\tbarPosition.left -\n\t\t\t\t\tholderPosition.left +\n\t\t\t\t\tbarPosition.width / 2,\n\t\t\t\ttop: barPosition.bottom - holderPosition.top + verticalOffset\n\t\t\t};\n\n\t\t\treturn { placement: TooltipPosition.BOTTOM, position: tooltipPos };\n\t\t} else {\n\t\t\t// positive bars\n\t\t\tconst tooltipPos = {\n\t\t\t\tleft:\n\t\t\t\t\tbarPosition.left -\n\t\t\t\t\tholderPosition.left +\n\t\t\t\t\tbarPosition.width / 2,\n\t\t\t\ttop: barPosition.top - holderPosition.top - verticalOffset\n\t\t\t};\n\n\t\t\treturn { placement: TooltipPosition.TOP, position: tooltipPos };\n\t\t}\n\t}\n\n\t/**\n\t * Returns the html for the bar single point tooltip\n\t * @param data associated values for the hovered bar\n\t */\n\tgetTooltipHTML(data: any) {\n\t\tconst formattedValue = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"tooltip\",\n\t\t\t\"valueFormatter\"\n\t\t)\n\t\t\t? this.model.getOptions().tooltip.valueFormatter(data.value)\n\t\t\t: data.value.toLocaleString(\"en\");\n\n\t\treturn `<div class=\"datapoint-tooltip\"><p class=\"value\">${formattedValue}</p></div>`;\n\t}\n\n\t/**\n\t * Multip tooltips for bar charts include totals for each stack\n\t * @param data\n\t */\n\tgetMultilineTooltipHTML(data: any) {\n\t\tconst points = data;\n\n\t\tpoints.reverse();\n\t\t// in a vertical bar chart the tooltip should display in order of the drawn bars\n\t\t// in horizontal stacked bar, the order of the segments from Left to Right are displayed top down in tooltip\n\t\tif (\n\t\t\tthis.services.cartesianScales.getOrientation() ===\n\t\t\tCartesianOrientations.VERTICAL\n\t\t) {\n\t\t\tpoints.reverse();\n\t\t}\n\n\t\t// get the total for the stacked tooltip\n\t\tlet total = points.reduce((sum, item) => sum + item.value, 0);\n\n\t\t// format the total value\n\t\ttotal = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"tooltip\",\n\t\t\t\"valueFormatter\"\n\t\t)\n\t\t\t? this.model.getOptions().tooltip.valueFormatter(total)\n\t\t\t: total.toLocaleString(\"en\");\n\n\t\treturn (\n\t\t\t\"<ul class='multi-tooltip'>\" +\n\t\t\tpoints\n\t\t\t\t.map(datapoint => {\n\t\t\t\t\tconst formattedValue = Tools.getProperty(\n\t\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t\t\"tooltip\",\n\t\t\t\t\t\t\"valueFormatter\"\n\t\t\t\t\t)\n\t\t\t\t\t\t? this.model\n\t\t\t\t\t\t\t\t.getOptions()\n\t\t\t\t\t\t\t\t.tooltip.valueFormatter(datapoint.value)\n\t\t\t\t\t\t: datapoint.value.toLocaleString(\"en\");\n\n\t\t\t\t\t// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.\n\t\t\t\t\tconst indicatorColor = this.model.getStrokeColor(\n\t\t\t\t\t\tdatapoint.datasetLabel,\n\t\t\t\t\t\tdatapoint.label\n\t\t\t\t\t);\n\n\t\t\t\t\treturn `\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:${indicatorColor}\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">${datapoint.datasetLabel}</p>\n\t\t\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>`;\n\t\t\t\t})\n\t\t\t\t.join(\"\") +\n\t\t\t`<li>\n\t\t\t\t\t<div class='total-val'>\n\t\t\t\t\t\t<p class='label'>Total</p>\n\t\t\t\t\t\t<p class='value'>${total}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t</ul>`\n\t\t);\n\t}\n}\n"]}
@@ -28,11 +28,12 @@ var TooltipPie = /** @class */ (function (_super) {
28
28
  var dataVal = d.data;
29
29
  var groupMapsTo = this.model.getOptions().data.groupMapsTo;
30
30
  // format the value if needed
31
- var formattedValue = Tools.getProperty(this.model.getOptions(), "tooltip", "valueFormatter") ?
32
- this.model.getOptions().tooltip.valueFormatter(dataVal.value) : dataVal.value.toLocaleString("en");
31
+ var formattedValue = Tools.getProperty(this.model.getOptions(), "tooltip", "valueFormatter")
32
+ ? this.model.getOptions().tooltip.valueFormatter(dataVal.value)
33
+ : dataVal.value.toLocaleString("en");
33
34
  // pie charts don't have a dataset label since they only support one dataset
34
35
  var label = dataVal[groupMapsTo];
35
- return ("<div class=\"datapoint-tooltip\">\n\t\t\t\t<p class=\"label\">" + label + "</p>\n\t\t\t\t<p class=\"value\">" + formattedValue + "</p>\n\t\t\t</div>");
36
+ return "<div class=\"datapoint-tooltip\">\n\t\t\t\t<p class=\"label\">" + label + "</p>\n\t\t\t\t<p class=\"value\">" + formattedValue + "</p>\n\t\t\t</div>";
36
37
  };
37
38
  return TooltipPie;
38
39
  }(Tooltip));
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-pie.js","sourceRoot":"","sources":["tooltip-pie.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;IAAgC,8BAAO;IAAvC;;IAyBA,CAAC;IAxBA,mCAAc,GAAd,UAAe,CAAM,EAAE,IAAkB;QACxC,mDAAmD;QACnD,IAAI,IAAI,KAAK,YAAY,CAAC,KAAK,EAAE;YAChC,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC;YAC5C,OAAO,wCAAoC,KAAK,kBAAe,CAAC;SAChE;QAED,IAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC;QACf,IAAA,sDAAW,CAAkC;QAErD,6BAA6B;QAC7B,IAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;YAChG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAEnG,4EAA4E;QAC5E,IAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAEnC,OAAO,CACN,mEACoB,KAAK,yCACL,cAAc,uBAC3B,CACP,CAAC;IACH,CAAC;IACF,iBAAC;AAAD,CAAC,AAzBD,CAAgC,OAAO,GAyBtC","sourcesContent":["import { Tooltip } from \"./tooltip\";\nimport { Tools } from \"../../tools\";\nimport { TooltipTypes } from \"../../interfaces\";\n\nexport class TooltipPie extends Tooltip {\n\tgetTooltipHTML(d: any, type: TooltipTypes) {\n\t\t// check if it is getting styles for a tooltip type\n\t\tif (type === TooltipTypes.TITLE) {\n\t\t\tconst title = this.model.getOptions().title;\n\t\t\treturn `<div class=\"title-tooltip\"><text>${title}</text></div>`;\n\t\t}\n\n\t\tconst dataVal = d.data;\n\t\tconst { groupMapsTo } = this.model.getOptions().data;\n\n\t\t// format the value if needed\n\t\tconst formattedValue = Tools.getProperty(this.model.getOptions(), \"tooltip\", \"valueFormatter\") ?\n\t\tthis.model.getOptions().tooltip.valueFormatter(dataVal.value) : dataVal.value.toLocaleString(\"en\");\n\n\t\t// pie charts don't have a dataset label since they only support one dataset\n\t\tconst label = dataVal[groupMapsTo];\n\n\t\treturn (\n\t\t\t`<div class=\"datapoint-tooltip\">\n\t\t\t\t<p class=\"label\">${label}</p>\n\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t</div>`\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"tooltip-pie.js","sourceRoot":"","sources":["tooltip-pie.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;IAAgC,8BAAO;IAAvC;;IA4BA,CAAC;IA3BA,mCAAc,GAAd,UAAe,CAAM,EAAE,IAAkB;QACxC,mDAAmD;QACnD,IAAI,IAAI,KAAK,YAAY,CAAC,KAAK,EAAE;YAChC,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC;YAC5C,OAAO,wCAAoC,KAAK,kBAAe,CAAC;SAChE;QAED,IAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC;QACf,IAAA,sDAAW,CAAkC;QAErD,6BAA6B;QAC7B,IAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACvC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EACvB,SAAS,EACT,gBAAgB,CAChB;YACA,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC;YAC/D,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAEtC,4EAA4E;QAC5E,IAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAEnC,OAAO,mEACc,KAAK,yCACL,cAAc,uBAC3B,CAAC;IACV,CAAC;IACF,iBAAC;AAAD,CAAC,AA5BD,CAAgC,OAAO,GA4BtC","sourcesContent":["import { Tooltip } from \"./tooltip\";\nimport { Tools } from \"../../tools\";\nimport { TooltipTypes } from \"../../interfaces\";\n\nexport class TooltipPie extends Tooltip {\n\tgetTooltipHTML(d: any, type: TooltipTypes) {\n\t\t// check if it is getting styles for a tooltip type\n\t\tif (type === TooltipTypes.TITLE) {\n\t\t\tconst title = this.model.getOptions().title;\n\t\t\treturn `<div class=\"title-tooltip\"><text>${title}</text></div>`;\n\t\t}\n\n\t\tconst dataVal = d.data;\n\t\tconst { groupMapsTo } = this.model.getOptions().data;\n\n\t\t// format the value if needed\n\t\tconst formattedValue = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"tooltip\",\n\t\t\t\"valueFormatter\"\n\t\t)\n\t\t\t? this.model.getOptions().tooltip.valueFormatter(dataVal.value)\n\t\t\t: dataVal.value.toLocaleString(\"en\");\n\n\t\t// pie charts don't have a dataset label since they only support one dataset\n\t\tconst label = dataVal[groupMapsTo];\n\n\t\treturn `<div class=\"datapoint-tooltip\">\n\t\t\t\t<p class=\"label\">${label}</p>\n\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t</div>`;\n\t}\n}\n"]}
@@ -25,8 +25,9 @@ var TooltipRadar = /** @class */ (function (_super) {
25
25
  var _a = options.radar.axes, angle = _a.angle, value = _a.value;
26
26
  // sort them so they are in the same order as the graph
27
27
  data.sort(function (a, b) { return b[value] - a[value]; });
28
- return "<ul class='multi-tooltip'>" +
29
- data.map(function (datum) {
28
+ return ("<ul class='multi-tooltip'>" +
29
+ data
30
+ .map(function (datum) {
30
31
  var userProvidedValueFormatter = Tools.getProperty(options, "tooltip", "valueFormatter");
31
32
  var formattedValue = userProvidedValueFormatter
32
33
  ? userProvidedValueFormatter(datum[value])
@@ -34,7 +35,9 @@ var TooltipRadar = /** @class */ (function (_super) {
34
35
  // For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.
35
36
  var indicatorColor = _this.model.getStrokeColor(datum[groupMapsTo]);
36
37
  return "\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:" + indicatorColor + "\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">" + datum[groupMapsTo] + "</p>\n\t\t\t\t\t\t<p class=\"value\">" + formattedValue + "</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>";
37
- }).join("") + "</ul>";
38
+ })
39
+ .join("") +
40
+ "</ul>");
38
41
  };
39
42
  return TooltipRadar;
40
43
  }(Tooltip));
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-radar.js","sourceRoot":"","sources":["tooltip-radar.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC;IAAkC,gCAAO;IAAzC;;IA6BA,CAAC;IA5BA,8CAAuB,GAAvB,UAAwB,IAAS;QAAjC,iBA2BC;QA1BA,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QAChC,IAAA,sCAAW,CAAkB;QAC/B,IAAA,uBAAqC,EAAnC,gBAAK,EAAE,gBAA4B,CAAC;QAE5C,uDAAuD;QACvD,IAAI,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAnB,CAAmB,CAAC,CAAC;QAEzC,OAAQ,4BAA4B;YACnC,IAAI,CAAC,GAAG,CAAC,UAAA,KAAK;gBACb,IAAM,0BAA0B,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;gBAC3F,IAAM,cAAc,GAAG,0BAA0B;oBAChD,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBAC1C,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAEhB,2GAA2G;gBAC3G,IAAM,cAAc,GAAG,KAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBAErE,OAAO,0GAGwB,cAAc,wEACxB,KAAK,CAAC,WAAW,CAAC,6CAClB,cAAc,0CAE7B,CAAC;YACR,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;IACxB,CAAC;IACF,mBAAC;AAAD,CAAC,AA7BD,CAAkC,OAAO,GA6BxC","sourcesContent":["import { Tooltip } from \"./tooltip\";\nimport { Tools } from \"../../tools\";\n\nexport class TooltipRadar extends Tooltip {\n\tgetMultilineTooltipHTML(data: any) {\n\t\tconst options = this.model.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst { angle, value } = options.radar.axes;\n\n\t\t// sort them so they are in the same order as the graph\n\t\tdata.sort((a, b) => b[value] - a[value]);\n\n\t\treturn \"<ul class='multi-tooltip'>\" +\n\t\t\tdata.map(datum => {\n\t\t\t\tconst userProvidedValueFormatter = Tools.getProperty(options, \"tooltip\", \"valueFormatter\");\n\t\t\t\tconst formattedValue = userProvidedValueFormatter\n\t\t\t\t\t? userProvidedValueFormatter(datum[value])\n\t\t\t\t\t: datum[value];\n\n\t\t\t\t// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.\n\t\t\t\tconst indicatorColor = this.model.getStrokeColor(datum[groupMapsTo]);\n\n\t\t\t\treturn `\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:${indicatorColor}\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">${datum[groupMapsTo]}</p>\n\t\t\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>`;\n\t\t\t}).join(\"\") + \"</ul>\";\n\t}\n}\n"]}
1
+ {"version":3,"file":"tooltip-radar.js","sourceRoot":"","sources":["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from \"../../tools\";\n\nexport class TooltipRadar extends Tooltip {\n\tgetMultilineTooltipHTML(data: any) {\n\t\tconst options = this.model.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst { angle, value } = options.radar.axes;\n\n\t\t// sort them so they are in the same order as the graph\n\t\tdata.sort((a, b) => b[value] - a[value]);\n\n\t\treturn (\n\t\t\t\"<ul class='multi-tooltip'>\" +\n\t\t\tdata\n\t\t\t\t.map(datum => {\n\t\t\t\t\tconst userProvidedValueFormatter = Tools.getProperty(\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\"tooltip\",\n\t\t\t\t\t\t\"valueFormatter\"\n\t\t\t\t\t);\n\t\t\t\t\tconst formattedValue = userProvidedValueFormatter\n\t\t\t\t\t\t? userProvidedValueFormatter(datum[value])\n\t\t\t\t\t\t: datum[value];\n\n\t\t\t\t\t// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.\n\t\t\t\t\tconst indicatorColor = this.model.getStrokeColor(\n\t\t\t\t\t\tdatum[groupMapsTo]\n\t\t\t\t\t);\n\n\t\t\t\t\treturn `\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:${indicatorColor}\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">${datum[groupMapsTo]}</p>\n\t\t\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>`;\n\t\t\t\t})\n\t\t\t\t.join(\"\") +\n\t\t\t\"</ul>\"\n\t\t);\n\t}\n}\n"]}
@@ -27,7 +27,9 @@ var TooltipScatter = /** @class */ (function (_super) {
27
27
  var groupMapsTo = this.model.getOptions().data.groupMapsTo;
28
28
  var rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();
29
29
  var userProvidedValueFormatter = Tools.getProperty(this.model.getOptions(), "tooltip", "valueFormatter");
30
- var formattedValue = userProvidedValueFormatter ? userProvidedValueFormatter(datum[rangeIdentifier]) : datum[rangeIdentifier].toLocaleString("en");
30
+ var formattedValue = userProvidedValueFormatter
31
+ ? userProvidedValueFormatter(datum[rangeIdentifier])
32
+ : datum[rangeIdentifier].toLocaleString("en");
31
33
  // For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.
32
34
  var indicatorColor = this.model.getStrokeColor(datum[groupMapsTo]);
33
35
  return "\n\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t<a style=\"background-color:" + indicatorColor + "\" class=\"tooltip-color\"></a>\n\t\t\t\t<p class=\"label\">" + datum[groupMapsTo] + "</p>\n\t\t\t\t<p class=\"value\">" + formattedValue + "</p>\n\t\t\t</div>";
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-scatter.js","sourceRoot":"","sources":["tooltip-scatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;IAAoC,kCAAO;IAA3C;;IAuBA,CAAC;IAtBA,uCAAc,GAAd,UAAe,KAAU,EAAE,IAAkB;QAC5C,IAAI,IAAI,KAAK,YAAY,CAAC,KAAK,EAAE;YAChC,kDAAkD;YAClD,OAAO,iBAAM,cAAc,YAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SACzC;QAEO,IAAA,sDAAW,CAAkC;QACrD,IAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC;QAE3E,IAAM,0BAA0B,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;QAC3G,IAAM,cAAc,GAAG,0BAA0B,CAAC,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAErJ,2GAA2G;QAC3G,IAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;QAErE,OAAO,oFAEwB,cAAc,oEACxB,KAAK,CAAC,WAAW,CAAC,yCAClB,cAAc,uBAC3B,CAAC;IACV,CAAC;IACF,qBAAC;AAAD,CAAC,AAvBD,CAAoC,OAAO,GAuB1C","sourcesContent":["import { Tooltip } from \"./tooltip\";\nimport { Tools } from \"../../tools\";\nimport { TooltipTypes } from \"./../../interfaces\";\n\nexport class TooltipScatter extends Tooltip {\n\tgetTooltipHTML(datum: any, type: TooltipTypes) {\n\t\tif (type === TooltipTypes.TITLE) {\n\t\t\t// the main tooltip component handles title styles\n\t\t\treturn super.getTooltipHTML(datum, type);\n\t\t}\n\n\t\tconst { groupMapsTo } = this.model.getOptions().data;\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\tconst userProvidedValueFormatter = Tools.getProperty(this.model.getOptions(), \"tooltip\", \"valueFormatter\");\n\t\tconst formattedValue = userProvidedValueFormatter ? userProvidedValueFormatter(datum[rangeIdentifier]) : datum[rangeIdentifier].toLocaleString(\"en\");\n\n\t\t// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.\n\t\tconst indicatorColor = this.model.getStrokeColor(datum[groupMapsTo]);\n\n\t\treturn `\n\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t<a style=\"background-color:${indicatorColor}\" class=\"tooltip-color\"></a>\n\t\t\t\t<p class=\"label\">${datum[groupMapsTo]}</p>\n\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t</div>`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"tooltip-scatter.js","sourceRoot":"","sources":["tooltip-scatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;IAAoC,kCAAO;IAA3C;;IA6BA,CAAC;IA5BA,uCAAc,GAAd,UAAe,KAAU,EAAE,IAAkB;QAC5C,IAAI,IAAI,KAAK,YAAY,CAAC,KAAK,EAAE;YAChC,kDAAkD;YAClD,OAAO,iBAAM,cAAc,YAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SACzC;QAEO,IAAA,sDAAW,CAAkC;QACrD,IAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC;QAE3E,IAAM,0BAA0B,GAAG,KAAK,CAAC,WAAW,CACnD,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EACvB,SAAS,EACT,gBAAgB,CAChB,CAAC;QACF,IAAM,cAAc,GAAG,0BAA0B;YAChD,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACpD,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE/C,2GAA2G;QAC3G,IAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;QAErE,OAAO,oFAEwB,cAAc,oEACxB,KAAK,CAAC,WAAW,CAAC,yCAClB,cAAc,uBAC3B,CAAC;IACV,CAAC;IACF,qBAAC;AAAD,CAAC,AA7BD,CAAoC,OAAO,GA6B1C","sourcesContent":["import { Tooltip } from \"./tooltip\";\nimport { Tools } from \"../../tools\";\nimport { TooltipTypes } from \"./../../interfaces\";\n\nexport class TooltipScatter extends Tooltip {\n\tgetTooltipHTML(datum: any, type: TooltipTypes) {\n\t\tif (type === TooltipTypes.TITLE) {\n\t\t\t// the main tooltip component handles title styles\n\t\t\treturn super.getTooltipHTML(datum, type);\n\t\t}\n\n\t\tconst { groupMapsTo } = this.model.getOptions().data;\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\tconst userProvidedValueFormatter = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"tooltip\",\n\t\t\t\"valueFormatter\"\n\t\t);\n\t\tconst formattedValue = userProvidedValueFormatter\n\t\t\t? userProvidedValueFormatter(datum[rangeIdentifier])\n\t\t\t: datum[rangeIdentifier].toLocaleString(\"en\");\n\n\t\t// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.\n\t\tconst indicatorColor = this.model.getStrokeColor(datum[groupMapsTo]);\n\n\t\treturn `\n\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t<a style=\"background-color:${indicatorColor}\" class=\"tooltip-color\"></a>\n\t\t\t\t<p class=\"label\">${datum[groupMapsTo]}</p>\n\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t</div>`;\n\t}\n}\n"]}