@carbon/charts 0.41.34 → 0.41.38

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 (102) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/axis-chart.d.ts +1 -1
  3. package/axis-chart.js +5 -3
  4. package/axis-chart.js.map +1 -1
  5. package/build/demo/data/boxplot.d.ts +34 -0
  6. package/build/demo/data/combo.d.ts +4 -31
  7. package/build/demo/data/index.d.ts +6 -0
  8. package/build/src/axis-chart.d.ts +1 -1
  9. package/build/src/charts/boxplot.d.ts +8 -0
  10. package/build/src/charts/index.d.ts +1 -0
  11. package/build/src/components/axes/ruler-stacked.d.ts +0 -1
  12. package/build/src/components/axes/two-dimensional-axes.d.ts +0 -1
  13. package/build/src/components/component.d.ts +1 -1
  14. package/build/src/components/essentials/threshold.d.ts +3 -6
  15. package/build/src/components/graphs/area-stacked.d.ts +1 -1
  16. package/build/src/components/graphs/boxplot.d.ts +7 -0
  17. package/build/src/components/index.d.ts +1 -0
  18. package/build/src/configuration-non-customizable.d.ts +19 -0
  19. package/build/src/configuration.d.ts +2 -1
  20. package/build/src/interfaces/axis-scales.d.ts +6 -1
  21. package/build/src/interfaces/charts.d.ts +6 -1
  22. package/build/src/interfaces/enums.d.ts +7 -0
  23. package/build/src/interfaces/events.d.ts +13 -0
  24. package/build/src/model-boxplot.d.ts +12 -0
  25. package/build/src/model.d.ts +1 -1
  26. package/bundle.js +1 -1
  27. package/charts/boxplot.d.ts +8 -0
  28. package/charts/boxplot.js +55 -0
  29. package/charts/boxplot.js.map +1 -0
  30. package/charts/index.d.ts +1 -0
  31. package/charts/index.js +1 -0
  32. package/charts/index.js.map +1 -1
  33. package/components/axes/axis.js +34 -13
  34. package/components/axes/axis.js.map +1 -1
  35. package/components/axes/ruler-stacked.d.ts +0 -1
  36. package/components/axes/ruler-stacked.js +0 -8
  37. package/components/axes/ruler-stacked.js.map +1 -1
  38. package/components/axes/two-dimensional-axes.d.ts +0 -1
  39. package/components/axes/two-dimensional-axes.js +0 -29
  40. package/components/axes/two-dimensional-axes.js.map +1 -1
  41. package/components/component.d.ts +1 -1
  42. package/components/component.js.map +1 -1
  43. package/components/essentials/threshold.d.ts +3 -6
  44. package/components/essentials/threshold.js +158 -79
  45. package/components/essentials/threshold.js.map +1 -1
  46. package/components/graphs/area-stacked.d.ts +1 -1
  47. package/components/graphs/area-stacked.js +5 -3
  48. package/components/graphs/area-stacked.js.map +1 -1
  49. package/components/graphs/boxplot.d.ts +7 -0
  50. package/components/graphs/boxplot.js +420 -0
  51. package/components/graphs/boxplot.js.map +1 -0
  52. package/components/index.d.ts +1 -0
  53. package/components/index.js +1 -0
  54. package/components/index.js.map +1 -1
  55. package/configuration-non-customizable.d.ts +19 -0
  56. package/configuration-non-customizable.js +19 -0
  57. package/configuration-non-customizable.js.map +1 -1
  58. package/configuration.d.ts +2 -1
  59. package/configuration.js +5 -0
  60. package/configuration.js.map +1 -1
  61. package/demo/data/boxplot.d.ts +34 -0
  62. package/demo/data/boxplot.js +48 -0
  63. package/demo/data/boxplot.js.map +1 -0
  64. package/demo/data/bubble.js +4 -4
  65. package/demo/data/bubble.js.map +1 -1
  66. package/demo/data/bundle.js +1 -1
  67. package/demo/data/combo.d.ts +4 -31
  68. package/demo/data/combo.js +4 -42
  69. package/demo/data/combo.js.map +1 -1
  70. package/demo/data/index.d.ts +6 -0
  71. package/demo/data/index.js +22 -6
  72. package/demo/data/index.js.map +1 -1
  73. package/demo/styles.css +4 -4
  74. package/demo/styles.min.css +1 -1
  75. package/demo/tsconfig.tsbuildinfo +31 -17
  76. package/interfaces/axis-scales.d.ts +6 -1
  77. package/interfaces/axis-scales.js.map +1 -1
  78. package/interfaces/charts.d.ts +6 -1
  79. package/interfaces/charts.js.map +1 -1
  80. package/interfaces/enums.d.ts +7 -0
  81. package/interfaces/enums.js +8 -0
  82. package/interfaces/enums.js.map +1 -1
  83. package/interfaces/events.d.ts +13 -0
  84. package/interfaces/events.js +14 -0
  85. package/interfaces/events.js.map +1 -1
  86. package/model-boxplot.d.ts +12 -0
  87. package/model-boxplot.js +99 -0
  88. package/model-boxplot.js.map +1 -0
  89. package/model.d.ts +1 -1
  90. package/model.js +3 -2
  91. package/model.js.map +1 -1
  92. package/package.json +1 -1
  93. package/styles/components/_threshold.scss +1 -1
  94. package/styles-g10.css +1 -1
  95. package/styles-g10.min.css +1 -1
  96. package/styles-g100.css +1 -1
  97. package/styles-g100.min.css +1 -1
  98. package/styles-g90.css +1 -1
  99. package/styles-g90.min.css +1 -1
  100. package/styles.css +1 -1
  101. package/styles.min.css +1 -1
  102. package/tsconfig.tsbuildinfo +97 -31
@@ -14,7 +14,7 @@ var __extends = (this && this.__extends) || (function () {
14
14
  import { Component } from '../component';
15
15
  import { Tools } from '../../tools';
16
16
  import { DOMUtils } from '../../services';
17
- import { AxisPositions, Events, ScaleTypes, } from '../../interfaces';
17
+ import { AxisPositions, Events, ScaleTypes } from '../../interfaces';
18
18
  import { select, mouse } from 'd3-selection';
19
19
  // Carbon position service
20
20
  import Position, { PLACEMENTS } from '@carbon/utils-position';
@@ -23,8 +23,8 @@ import settings from 'carbon-components/es/globals/js/settings';
23
23
  import { formatTick, computeTimeIntervalName, } from '../../services/time-series';
24
24
  var Threshold = /** @class */ (function (_super) {
25
25
  __extends(Threshold, _super);
26
- function Threshold(model, services, configs) {
27
- var _this = _super.call(this, model, services, configs) || this;
26
+ function Threshold(model, services) {
27
+ var _this = _super.call(this, model, services) || this;
28
28
  _this.type = 'threshold';
29
29
  _this.positionService = new Position();
30
30
  return _this;
@@ -32,74 +32,146 @@ var Threshold = /** @class */ (function (_super) {
32
32
  Threshold.prototype.render = function (animate) {
33
33
  var _this = this;
34
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.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 scaleType = this.services.cartesianScales.getScaleTypeByPosition(axisPosition);
50
- var mainXScale = this.services.cartesianScales.getMainXScale();
51
- var mainYScale = this.services.cartesianScales.getMainYScale();
52
- var isScaleTypeLabels = scaleType === ScaleTypes.LABELS;
53
- var _b = mainXScale.range(), xScaleStart = _b[0], xScaleEnd = _b[1];
54
- var _c = mainYScale.range(), yScaleEnd = _c[0], yScaleStart = _c[1];
55
- var cartesianScales = this.services.cartesianScales;
56
- var orientation = cartesianScales.getOrientation();
57
- var getDomainValue = function (d) { return cartesianScales.getDomainValue(d); };
58
- var getRangeValue = function (d) { return cartesianScales.getRangeValue(d); };
59
- var _d = Tools.flipDomainAndRangeBasedOnOrientation(getDomainValue, getRangeValue, orientation), getXValue = _d[0], getYValue = _d[1];
60
- if (axisPosition === AxisPositions.TOP ||
61
- axisPosition === AxisPositions.BOTTOM) {
62
- var position = getXValue(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);
63
- // Position the threshold on the x scale value
64
- this.threshold
65
- .transition(this.services.transitions.getTransition('threshold-update', animate))
66
- .attr('transform', "translate(" + position + ", " + yScaleStart + ")");
67
- // Set line end point on the y-axis
68
- thresholdLine.attr('y2', yScaleEnd - yScaleStart);
69
- // Set hoverable area width and rotate it
70
- thresholdRect
71
- .attr('width', Math.abs(yScaleEnd - yScaleStart))
72
- .classed('rotate', true);
73
- }
74
- else {
75
- var position = getYValue(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);
76
- // Position the threshold on the y scale value
77
- this.threshold
78
- .transition(this.services.transitions.getTransition('threshold-update', animate))
79
- .attr('transform', "translate(" + xScaleStart + ", " + position + ")");
80
- // Set line end point on the x-axis
81
- thresholdLine.attr('x2', xScaleEnd - xScaleStart);
82
- // Set hoverable area width
83
- thresholdRect.attr('width', Math.abs(xScaleEnd - xScaleStart));
84
- }
35
+ var axesOptions = Tools.getProperty(this.getOptions(), 'axes');
36
+ var thresholdData = [];
37
+ Object.keys(axesOptions).forEach(function (axisPosition) {
38
+ if (Object.values(AxisPositions).includes(axisPosition)) {
39
+ var axisOptions = axesOptions[axisPosition];
40
+ if (axisOptions.thresholds &&
41
+ axisOptions.thresholds.length > 0) {
42
+ thresholdData.push({
43
+ axisPosition: axisPosition,
44
+ thresholds: axisOptions.thresholds,
45
+ });
46
+ }
47
+ }
48
+ });
49
+ // Grab container SVG
50
+ var svg = this.getContainerSVG({ withinChartClip: true });
51
+ // Update data on all axis threshold groups
52
+ var thresholdAxisGroups = svg
53
+ .selectAll('g.axis-thresholds')
54
+ .data(thresholdData, function (thresholdData) { return thresholdData.axisPosition; });
55
+ // Remove axis threshold groups that are no longer needed
56
+ thresholdAxisGroups.exit().attr('opacity', 0).remove();
57
+ // Add the axis threshold groups that need to be introduced
58
+ var thresholdAxisGroupsEnter = thresholdAxisGroups
59
+ .enter()
60
+ .append('g');
61
+ var thresholdAxisGroupsMerge = thresholdAxisGroupsEnter.merge(thresholdAxisGroups);
62
+ thresholdAxisGroupsMerge.attr('class', function (d) { return "axis-thresholds " + d.axisPosition; });
63
+ var thresholdGroups = thresholdAxisGroupsMerge
64
+ .selectAll('g.threshold-group')
65
+ .data(function (d) {
66
+ return d.thresholds.map(function (threshold) {
67
+ threshold.axisPosition = d.axisPosition;
68
+ return threshold;
69
+ });
70
+ });
71
+ // Remove threshold groups that are no longer needed
72
+ thresholdGroups.exit().attr('opacity', 0).remove();
73
+ // Add the threshold groups that need to be introduced
74
+ var thresholdGroupsEnter = thresholdGroups.enter().append('g');
75
+ thresholdGroupsEnter.append('line').attr('class', 'threshold-line');
76
+ thresholdGroupsEnter
77
+ .append('rect')
78
+ .attr('class', 'threshold-hoverable-area');
79
+ var thresholdGroupsMerge = thresholdGroupsEnter.merge(thresholdGroups);
80
+ thresholdGroupsMerge.attr('class', 'threshold-group');
85
81
  var self = this;
86
- this.services.events.addEventListener(Events.Threshold.SHOW, function (e) {
87
- var hovered = e.detail.hoveredElement.node();
88
- // If is this threshold
89
- if (hovered === self.threshold) {
90
- // Set label position and show it
91
- _this.setThresholdLabelPosition();
92
- _this.label.classed('hidden', false);
82
+ thresholdAxisGroupsMerge.each(function (_a) {
83
+ var axisPosition = _a.axisPosition;
84
+ var scale = self.services.cartesianScales.getScaleByPosition(axisPosition);
85
+ var scaleType = self.services.cartesianScales.getScaleTypeByPosition(axisPosition);
86
+ var mainXScale = self.services.cartesianScales.getMainXScale();
87
+ var mainYScale = self.services.cartesianScales.getMainYScale();
88
+ var isScaleTypeLabels = scaleType === ScaleTypes.LABELS;
89
+ var _b = mainXScale.range(), xScaleStart = _b[0], xScaleEnd = _b[1];
90
+ var _c = mainYScale.range(), yScaleEnd = _c[0], yScaleStart = _c[1];
91
+ var cartesianScales = self.services.cartesianScales;
92
+ var orientation = cartesianScales.getOrientation();
93
+ var getDomainValue = function (d) { return cartesianScales.getDomainValue(d); };
94
+ var getRangeValue = function (d) { return cartesianScales.getRangeValue(d); };
95
+ var _d = Tools.flipDomainAndRangeBasedOnOrientation(getDomainValue, getRangeValue, orientation), getXValue = _d[0], getYValue = _d[1];
96
+ var group = select(this);
97
+ if (axisPosition === AxisPositions.TOP ||
98
+ axisPosition === AxisPositions.BOTTOM) {
99
+ group
100
+ .selectAll('line.threshold-line')
101
+ .transition(self.services.transitions.getTransition('threshold-line-update', animate))
102
+ .attr('y1', yScaleStart)
103
+ .attr('y2', yScaleEnd)
104
+ .attr('x1', function (_a) {
105
+ var value = _a.value;
106
+ return getXValue(value) +
107
+ (isScaleTypeLabels ? scale.step() / 2 : 0);
108
+ })
109
+ .attr('x2', function (_a) {
110
+ var value = _a.value;
111
+ return getXValue(value) +
112
+ (isScaleTypeLabels ? scale.step() / 2 : 0);
113
+ })
114
+ .style('stroke', function (_a) {
115
+ var fillColor = _a.fillColor;
116
+ return fillColor;
117
+ });
118
+ // Set hoverable area width and rotate it
119
+ group
120
+ .selectAll('rect.threshold-hoverable-area')
121
+ .attr('x', 0)
122
+ .attr('y', function (_a) {
123
+ var value = _a.value;
124
+ return -getXValue(value);
125
+ })
126
+ .attr('width', Math.abs(yScaleEnd - yScaleStart))
127
+ .classed('rotate', true);
128
+ }
129
+ else {
130
+ group
131
+ .selectAll('line.threshold-line')
132
+ .transition(self.services.transitions.getTransition('threshold-line-update', animate))
133
+ .attr('x1', xScaleStart)
134
+ .attr('x2', xScaleEnd)
135
+ .attr('y1', function (_a) {
136
+ var value = _a.value;
137
+ return getYValue(value) +
138
+ (isScaleTypeLabels ? scale.step() / 2 : 0);
139
+ })
140
+ .attr('y2', function (_a) {
141
+ var value = _a.value;
142
+ return getYValue(value) +
143
+ (isScaleTypeLabels ? scale.step() / 2 : 0);
144
+ })
145
+ .style('stroke', function (_a) {
146
+ var fillColor = _a.fillColor;
147
+ return fillColor;
148
+ });
149
+ // Set hoverable area width
150
+ group
151
+ .selectAll('rect.threshold-hoverable-area')
152
+ .attr('x', xScaleStart)
153
+ .attr('y', function (_a) {
154
+ var value = _a.value;
155
+ return getYValue(value);
156
+ })
157
+ .attr('width', Math.abs(xScaleEnd - xScaleStart))
158
+ .classed('rotate', false);
93
159
  }
94
160
  });
161
+ // Add event listener for showing the threshold tooltip
162
+ this.services.events.addEventListener(Events.Threshold.SHOW, function (e) {
163
+ _this.setThresholdLabelPosition(e.detail.datum);
164
+ _this.label.classed('hidden', false);
165
+ });
166
+ // Add event listener for hiding the threshold tooltip
95
167
  this.services.events.addEventListener(Events.Threshold.HIDE, function (e) {
96
168
  _this.label.classed('hidden', true);
97
169
  });
98
170
  this.appendThresholdLabel();
99
171
  this.addEventListeners();
100
172
  };
101
- Threshold.prototype.getFormattedValue = function () {
102
- var _a = this.configs, value = _a.value, axisPosition = _a.axisPosition;
173
+ Threshold.prototype.getFormattedValue = function (datum) {
174
+ var value = datum.value, axisPosition = datum.axisPosition;
103
175
  var options = this.getOptions();
104
176
  var scaleType = this.services.cartesianScales.getScaleTypeByPosition(axisPosition);
105
177
  // If scale is time, format the threshold date as the ticks format
@@ -118,22 +190,21 @@ var Threshold = /** @class */ (function (_super) {
118
190
  return value.toLocaleString('en');
119
191
  };
120
192
  Threshold.prototype.appendThresholdLabel = function () {
121
- var _a = this.configs, value = _a.value, valueFormatter = _a.valueFormatter, fillColor = _a.fillColor, _b = _a.label, label = _b === void 0 ? 'Threshold' : _b;
122
193
  var holder = select(this.services.domUtils.getHolder());
123
- // Format the threshold value using valueFormatter if defined in user-provided options
124
- var formattedValue = valueFormatter
125
- ? valueFormatter(value)
126
- : this.getFormattedValue();
127
- this.label = DOMUtils.appendOrSelect(holder, "div." + this.thresholdClass + "--label." + this.thresholdIdentifierClass);
128
- this.label
129
- .html(label + ": " + formattedValue)
130
- .classed('hidden', true)
131
- .style('background-color', fillColor);
194
+ var chartprefix = Tools.getProperty(this.getOptions(), 'style', 'prefix');
195
+ this.label = DOMUtils.appendOrSelect(holder, "div." + settings.prefix + "--" + chartprefix + "--threshold--label").classed('hidden', true);
132
196
  };
133
- Threshold.prototype.setThresholdLabelPosition = function () {
197
+ Threshold.prototype.setThresholdLabelPosition = function (datum) {
134
198
  var holder = this.services.domUtils.getHolder();
135
- var target = this.label.node();
136
199
  var mouseRelativePos = mouse(holder);
200
+ // Format the threshold value using valueFormatter if defined in user-provided options
201
+ var formattedValue = datum.valueFormatter
202
+ ? datum.valueFormatter(datum.value)
203
+ : this.getFormattedValue(datum);
204
+ this.label
205
+ .html((datum.label || 'Threshold') + ": " + formattedValue)
206
+ .style('background-color', datum.fillColor);
207
+ var target = this.label.node();
137
208
  // Find out whether threshold label should be shown on the left or right side
138
209
  var bestPlacementOption = this.positionService.findBestPlacementAt({
139
210
  left: mouseRelativePos[0],
@@ -156,18 +227,26 @@ var Threshold = /** @class */ (function (_super) {
156
227
  };
157
228
  Threshold.prototype.addEventListeners = function () {
158
229
  var self = this;
230
+ // Grab container SVG
231
+ var svg = this.getContainerSVG({ withinChartClip: true });
159
232
  // Add events to the threshold hoverable area
160
- DOMUtils.appendOrSelect(this.threshold, 'rect')
233
+ svg.selectAll('rect.threshold-hoverable-area')
161
234
  .on('mouseover mousemove', function () {
162
- self.threshold.classed('active', true);
235
+ select(this.parentNode)
236
+ .select('line.threshold-line')
237
+ .classed('active', true);
163
238
  self.services.events.dispatchEvent(Events.Threshold.SHOW, {
164
- hoveredElement: select(self.threshold),
239
+ hoveredElement: select(this),
240
+ datum: select(this).datum(),
165
241
  });
166
242
  })
167
243
  .on('mouseout', function () {
168
- self.threshold.classed('active', false);
244
+ select(this.parentNode)
245
+ .select('line.threshold-line')
246
+ .classed('active', false);
169
247
  self.services.events.dispatchEvent(Events.Threshold.HIDE, {
170
- hoveredElement: select(self.threshold),
248
+ hoveredElement: select(this),
249
+ datum: select(this).datum(),
171
250
  });
172
251
  });
173
252
  };
@@ -1 +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,EACN,aAAa,EACb,MAAM,EACN,UAAU,GAEV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C,0BAA0B;AAC1B,OA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,SAAS,CAAC;aACtC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACF,gBAAC;AAAD,CAAC,AA9OD,CAA+B,SAAS,GA8OvC","sourcesContent":["import { Component } from '../component';\nimport { Tools } from '../../tools';\nimport { DOMUtils } from '../../services';\nimport { ChartModel } from '../../model';\nimport {\n\tAxisPositions,\n\tEvents,\n\tScaleTypes,\n\tCartesianOrientations,\n} 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.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 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\tconst { cartesianScales } = this.services;\n\t\tconst orientation = cartesianScales.getOrientation();\n\t\tconst getDomainValue = (d) => cartesianScales.getDomainValue(d);\n\t\tconst getRangeValue = (d) => cartesianScales.getRangeValue(d);\n\t\tconst [\n\t\t\tgetXValue,\n\t\t\tgetYValue,\n\t\t] = Tools.flipDomainAndRangeBasedOnOrientation(\n\t\t\tgetDomainValue,\n\t\t\tgetRangeValue,\n\t\t\torientation\n\t\t);\n\n\t\tif (\n\t\t\taxisPosition === AxisPositions.TOP ||\n\t\t\taxisPosition === AxisPositions.BOTTOM\n\t\t) {\n\t\t\tconst position =\n\t\t\t\tgetXValue(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);\n\t\t\t// Position the threshold on the x scale value\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(${position}, ${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\n\t\t\t\t.attr('width', Math.abs(yScaleEnd - yScaleStart))\n\t\t\t\t.classed('rotate', true);\n\t\t} else {\n\t\t\tconst position =\n\t\t\t\tgetYValue(value) + (isScaleTypeLabels ? scale.step() / 2 : 0);\n\t\t\t// Position the threshold on the y scale value\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}, ${position})`);\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', Math.abs(xScaleEnd - xScaleStart));\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.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(\n\t\t\t\tvalue,\n\t\t\t\t0,\n\t\t\t\tscale.ticks(),\n\t\t\t\ttimeInterval,\n\t\t\t\ttimeScaleOptions\n\t\t\t);\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"]}
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,GACvB,MAAM,4BAA4B,CAAC;AAEpC;IAA+B,6BAAS;IAOvC,mBAAY,KAAiB,EAAE,QAAa;QAA5C,YACC,kBAAM,KAAK,EAAE,QAAQ,CAAC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MAAM,CAAC,IAAI,CAAC;gBAC5B,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE;aAC3B,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACF,gBAAC;AAAD,CAAC,AA7TD,CAA+B,SAAS,GA6TvC","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\tlabel: any;\n\n\tpositionService = new Position();\n\n\tconstructor(model: ChartModel, services: any) {\n\t\tsuper(model, services);\n\t}\n\n\trender(animate = false) {\n\t\tconst axesOptions = Tools.getProperty(this.getOptions(), 'axes');\n\n\t\tconst thresholdData = [];\n\n\t\tObject.keys(axesOptions).forEach((axisPosition) => {\n\t\t\tif (Object.values(AxisPositions).includes(axisPosition as any)) {\n\t\t\t\tconst axisOptions = axesOptions[axisPosition];\n\n\t\t\t\tif (\n\t\t\t\t\taxisOptions.thresholds &&\n\t\t\t\t\taxisOptions.thresholds.length > 0\n\t\t\t\t) {\n\t\t\t\t\tthresholdData.push({\n\t\t\t\t\t\taxisPosition,\n\t\t\t\t\t\tthresholds: axisOptions.thresholds,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Grab container SVG\n\t\tconst svg = this.getContainerSVG({ withinChartClip: true });\n\n\t\t// Update data on all axis threshold groups\n\t\tconst thresholdAxisGroups = svg\n\t\t\t.selectAll('g.axis-thresholds')\n\t\t\t.data(thresholdData, (thresholdData) => thresholdData.axisPosition);\n\n\t\t// Remove axis threshold groups that are no longer needed\n\t\tthresholdAxisGroups.exit().attr('opacity', 0).remove();\n\n\t\t// Add the axis threshold groups that need to be introduced\n\t\tconst thresholdAxisGroupsEnter = thresholdAxisGroups\n\t\t\t.enter()\n\t\t\t.append('g');\n\n\t\tconst thresholdAxisGroupsMerge = thresholdAxisGroupsEnter.merge(\n\t\t\tthresholdAxisGroups\n\t\t);\n\t\tthresholdAxisGroupsMerge.attr(\n\t\t\t'class',\n\t\t\t(d) => `axis-thresholds ${d.axisPosition}`\n\t\t);\n\n\t\tconst thresholdGroups = thresholdAxisGroupsMerge\n\t\t\t.selectAll('g.threshold-group')\n\t\t\t.data((d) =>\n\t\t\t\td.thresholds.map((threshold) => {\n\t\t\t\t\tthreshold.axisPosition = d.axisPosition;\n\t\t\t\t\treturn threshold;\n\t\t\t\t})\n\t\t\t);\n\n\t\t// Remove threshold groups that are no longer needed\n\t\tthresholdGroups.exit().attr('opacity', 0).remove();\n\n\t\t// Add the threshold groups that need to be introduced\n\t\tconst thresholdGroupsEnter = thresholdGroups.enter().append('g');\n\n\t\tthresholdGroupsEnter.append('line').attr('class', 'threshold-line');\n\t\tthresholdGroupsEnter\n\t\t\t.append('rect')\n\t\t\t.attr('class', 'threshold-hoverable-area');\n\n\t\tconst thresholdGroupsMerge = thresholdGroupsEnter.merge(\n\t\t\tthresholdGroups\n\t\t);\n\t\tthresholdGroupsMerge.attr('class', 'threshold-group');\n\n\t\tconst self = this;\n\t\tthresholdAxisGroupsMerge.each(function ({ axisPosition }) {\n\t\t\tconst scale = self.services.cartesianScales.getScaleByPosition(\n\t\t\t\taxisPosition\n\t\t\t);\n\t\t\tconst scaleType = self.services.cartesianScales.getScaleTypeByPosition(\n\t\t\t\taxisPosition\n\t\t\t);\n\t\t\tconst mainXScale = self.services.cartesianScales.getMainXScale();\n\t\t\tconst mainYScale = self.services.cartesianScales.getMainYScale();\n\t\t\tconst isScaleTypeLabels = scaleType === ScaleTypes.LABELS;\n\t\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\t\tconst { cartesianScales } = self.services;\n\t\t\tconst orientation = cartesianScales.getOrientation();\n\t\t\tconst getDomainValue = (d) => cartesianScales.getDomainValue(d);\n\t\t\tconst getRangeValue = (d) => cartesianScales.getRangeValue(d);\n\t\t\tconst [\n\t\t\t\tgetXValue,\n\t\t\t\tgetYValue,\n\t\t\t] = Tools.flipDomainAndRangeBasedOnOrientation(\n\t\t\t\tgetDomainValue,\n\t\t\t\tgetRangeValue,\n\t\t\t\torientation\n\t\t\t);\n\n\t\t\tconst group = select(this);\n\t\t\tif (\n\t\t\t\taxisPosition === AxisPositions.TOP ||\n\t\t\t\taxisPosition === AxisPositions.BOTTOM\n\t\t\t) {\n\t\t\t\tgroup\n\t\t\t\t\t.selectAll('line.threshold-line')\n\t\t\t\t\t.transition(\n\t\t\t\t\t\tself.services.transitions.getTransition(\n\t\t\t\t\t\t\t'threshold-line-update',\n\t\t\t\t\t\t\tanimate\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t.attr('y1', yScaleStart)\n\t\t\t\t\t.attr('y2', yScaleEnd)\n\t\t\t\t\t.attr(\n\t\t\t\t\t\t'x1',\n\t\t\t\t\t\t({ value }) =>\n\t\t\t\t\t\t\tgetXValue(value) +\n\t\t\t\t\t\t\t(isScaleTypeLabels ? scale.step() / 2 : 0)\n\t\t\t\t\t)\n\t\t\t\t\t.attr(\n\t\t\t\t\t\t'x2',\n\t\t\t\t\t\t({ value }) =>\n\t\t\t\t\t\t\tgetXValue(value) +\n\t\t\t\t\t\t\t(isScaleTypeLabels ? scale.step() / 2 : 0)\n\t\t\t\t\t)\n\t\t\t\t\t.style('stroke', ({ fillColor }) => fillColor);\n\n\t\t\t\t// Set hoverable area width and rotate it\n\t\t\t\tgroup\n\t\t\t\t\t.selectAll('rect.threshold-hoverable-area')\n\t\t\t\t\t.attr('x', 0)\n\t\t\t\t\t.attr('y', ({ value }) => -getXValue(value))\n\t\t\t\t\t.attr('width', Math.abs(yScaleEnd - yScaleStart))\n\t\t\t\t\t.classed('rotate', true);\n\t\t\t} else {\n\t\t\t\tgroup\n\t\t\t\t\t.selectAll('line.threshold-line')\n\t\t\t\t\t.transition(\n\t\t\t\t\t\tself.services.transitions.getTransition(\n\t\t\t\t\t\t\t'threshold-line-update',\n\t\t\t\t\t\t\tanimate\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t.attr('x1', xScaleStart)\n\t\t\t\t\t.attr('x2', xScaleEnd)\n\t\t\t\t\t.attr(\n\t\t\t\t\t\t'y1',\n\t\t\t\t\t\t({ value }) =>\n\t\t\t\t\t\t\tgetYValue(value) +\n\t\t\t\t\t\t\t(isScaleTypeLabels ? scale.step() / 2 : 0)\n\t\t\t\t\t)\n\t\t\t\t\t.attr(\n\t\t\t\t\t\t'y2',\n\t\t\t\t\t\t({ value }) =>\n\t\t\t\t\t\t\tgetYValue(value) +\n\t\t\t\t\t\t\t(isScaleTypeLabels ? scale.step() / 2 : 0)\n\t\t\t\t\t)\n\t\t\t\t\t.style('stroke', ({ fillColor }) => fillColor);\n\n\t\t\t\t// Set hoverable area width\n\t\t\t\tgroup\n\t\t\t\t\t.selectAll('rect.threshold-hoverable-area')\n\t\t\t\t\t.attr('x', xScaleStart)\n\t\t\t\t\t.attr('y', ({ value }) => getYValue(value))\n\t\t\t\t\t.attr('width', Math.abs(xScaleEnd - xScaleStart))\n\t\t\t\t\t.classed('rotate', false);\n\t\t\t}\n\t\t});\n\n\t\t// Add event listener for showing the threshold tooltip\n\t\tthis.services.events.addEventListener(Events.Threshold.SHOW, (e) => {\n\t\t\tthis.setThresholdLabelPosition(e.detail.datum);\n\n\t\t\tthis.label.classed('hidden', false);\n\t\t});\n\n\t\t// Add event listener for hiding the threshold tooltip\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(datum) {\n\t\tconst { value, axisPosition } = datum;\n\t\tconst options = this.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(\n\t\t\t\tvalue,\n\t\t\t\t0,\n\t\t\t\tscale.ticks(),\n\t\t\t\ttimeInterval,\n\t\t\t\ttimeScaleOptions\n\t\t\t);\n\t\t}\n\n\t\treturn value.toLocaleString('en');\n\t}\n\n\tappendThresholdLabel() {\n\t\tconst holder = select(this.services.domUtils.getHolder());\n\n\t\tconst chartprefix = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'style',\n\t\t\t'prefix'\n\t\t);\n\n\t\tthis.label = DOMUtils.appendOrSelect(\n\t\t\tholder,\n\t\t\t`div.${settings.prefix}--${chartprefix}--threshold--label`\n\t\t).classed('hidden', true);\n\t}\n\n\tsetThresholdLabelPosition(datum) {\n\t\tconst holder = this.services.domUtils.getHolder();\n\t\tconst mouseRelativePos = mouse(holder);\n\n\t\t// Format the threshold value using valueFormatter if defined in user-provided options\n\t\tconst formattedValue = datum.valueFormatter\n\t\t\t? datum.valueFormatter(datum.value)\n\t\t\t: this.getFormattedValue(datum);\n\n\t\tthis.label\n\t\t\t.html(`${datum.label || 'Threshold'}: ${formattedValue}`)\n\t\t\t.style('background-color', datum.fillColor);\n\n\t\tconst target = this.label.node();\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// Grab container SVG\n\t\tconst svg = this.getContainerSVG({ withinChartClip: true });\n\n\t\t// Add events to the threshold hoverable area\n\t\tsvg.selectAll('rect.threshold-hoverable-area')\n\t\t\t.on('mouseover mousemove', function () {\n\t\t\t\tselect(this.parentNode)\n\t\t\t\t\t.select('line.threshold-line')\n\t\t\t\t\t.classed('active', true);\n\n\t\t\t\tself.services.events.dispatchEvent(Events.Threshold.SHOW, {\n\t\t\t\t\thoveredElement: select(this),\n\t\t\t\t\tdatum: select(this).datum(),\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on('mouseout', function () {\n\t\t\t\tselect(this.parentNode)\n\t\t\t\t\t.select('line.threshold-line')\n\t\t\t\t\t.classed('active', false);\n\n\t\t\t\tself.services.events.dispatchEvent(Events.Threshold.HIDE, {\n\t\t\t\t\thoveredElement: select(this),\n\t\t\t\t\tdatum: select(this).datum(),\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n"]}
@@ -5,6 +5,6 @@ export declare class StackedArea extends Component {
5
5
  init(): void;
6
6
  render(animate?: boolean): void;
7
7
  handleLegendOnHover: (event: CustomEvent<any>) => void;
8
- handleLegendMouseOut: (event: CustomEvent<any>) => void;
8
+ handleLegendMouseOut: () => void;
9
9
  destroy(): void;
10
10
  }
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
13
13
  })();
14
14
  // Internal Imports
15
15
  import { Component } from '../component';
16
+ import { Tools } from '../../tools';
16
17
  import * as Configuration from '../../configuration';
17
18
  import { Roles, Events, ColorClassNameTypes, } from '../../interfaces';
18
19
  // D3 Imports
@@ -36,7 +37,7 @@ var StackedArea = /** @class */ (function (_super) {
36
37
  return Configuration.area.opacity.selected;
37
38
  });
38
39
  };
39
- _this.handleLegendMouseOut = function (event) {
40
+ _this.handleLegendMouseOut = function () {
40
41
  _this.parent
41
42
  .selectAll('path.area')
42
43
  .transition(_this.services.transitions.getTransition('legend-mouseout-area'))
@@ -63,10 +64,11 @@ var StackedArea = /** @class */ (function (_super) {
63
64
  percentage: percentage,
64
65
  groups: this.configs.groups,
65
66
  });
67
+ var firstDatum = Tools.getProperty(stackedData, 0, 0);
66
68
  // area doesnt have to use the main range and domain axes - they can be mapped to the secondary (in the case of a combo chart)
67
69
  // however area _cannot_ have multiple datasets that are mapped to _different_ ranges and domains so we can use the first data item
68
- var domainAxisPosition = this.services.cartesianScales.getDomainAxisPosition({ datum: stackedData[0][0] });
69
- var rangeAxisPosition = this.services.cartesianScales.getRangeAxisPosition({ datum: stackedData[0][0] });
70
+ var domainAxisPosition = this.services.cartesianScales.getDomainAxisPosition({ firstDatum: firstDatum });
71
+ var rangeAxisPosition = this.services.cartesianScales.getRangeAxisPosition({ firstDatum: firstDatum });
70
72
  var mainYScale = this.services.cartesianScales.getScaleByPosition(rangeAxisPosition);
71
73
  var areas = svg
72
74
  .selectAll('path.area')
@@ -1 +1 @@
1
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AAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAjB,CAAiB,CAAC;aAC3C,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;aACrB,IAAI,CAAC,OAAO,EAAE,UAAC,CAAC;YAChB,OAAA,KAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;gBAC5B,cAAc,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC;gBAC1C,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;gBAChC,iBAAiB,EAAE,MAAM;aACzB,CAAC;QAJF,CAIE,CACF;aACA,KAAK,CAAC,MAAM,EAAE,UAAC,CAAC,IAAK,OAAA,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,EAA1C,CAA0C,CAAC;aAChE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC;aACnC,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC;aACpC,UAAU,CACV,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,aAAa,CACtC,mBAAmB,EACnB,OAAO,CACP,CACD;aACA,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;aACpD,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IA8BD,6BAAO,GAAP;QACC,yBAAyB;QACzB,IAAI,CAAC,MAAM;aACT,SAAS,CAAC,WAAW,CAAC;aACtB,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;aACrB,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;aACrB,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IACF,kBAAC;AAAD,CAAC,AAjID,CAAiC,SAAS,GAiIzC","sourcesContent":["// Internal Imports\nimport { Component } from '../component';\nimport * as Configuration from '../../configuration';\nimport {\n\tRoles,\n\tScaleTypes,\n\tEvents,\n\tColorClassNameTypes,\n\tCartesianOrientations,\n} from '../../interfaces';\n\n// D3 Imports\nimport { area } from 'd3-shape';\n\nexport class StackedArea extends Component {\n\ttype = 'area-stacked';\n\n\tareaGenerator: any;\n\n\tinit() {\n\t\tconst eventsFragment = this.services.events;\n\n\t\t// Highlight correct area on legend item hovers\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Legend.ITEM_HOVER,\n\t\t\tthis.handleLegendOnHover\n\t\t);\n\n\t\t// Un-highlight area on legend item mouseouts\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Legend.ITEM_MOUSEOUT,\n\t\t\tthis.handleLegendMouseOut\n\t\t);\n\t}\n\n\trender(animate = true) {\n\t\tconst svg = this.getContainerSVG({ withinChartClip: true });\n\t\tconst self = this;\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst percentage = Object.keys(options.axes).some(\n\t\t\t(axis) => options.axes[axis].percentage\n\t\t);\n\n\t\tconst stackedData = this.model.getStackedData({\n\t\t\tpercentage,\n\t\t\tgroups: this.configs.groups,\n\t\t});\n\n\t\t// area doesnt have to use the main range and domain axes - they can be mapped to the secondary (in the case of a combo chart)\n\t\t// however area _cannot_ have multiple datasets that are mapped to _different_ ranges and domains so we can use the first data item\n\t\tconst domainAxisPosition = this.services.cartesianScales.getDomainAxisPosition(\n\t\t\t{ datum: stackedData[0][0] }\n\t\t);\n\t\tconst rangeAxisPosition = this.services.cartesianScales.getRangeAxisPosition(\n\t\t\t{ datum: stackedData[0][0] }\n\t\t);\n\t\tconst mainYScale = this.services.cartesianScales.getScaleByPosition(\n\t\t\trangeAxisPosition\n\t\t);\n\n\t\tconst areas = svg\n\t\t\t.selectAll('path.area')\n\t\t\t.data(stackedData, (d) => d[0][groupMapsTo]);\n\n\t\t// D3 area generator function\n\t\tthis.areaGenerator = area()\n\t\t\t.x((d: any, i) =>\n\t\t\t\tthis.services.cartesianScales.getValueThroughAxisPosition(\n\t\t\t\t\tdomainAxisPosition,\n\t\t\t\t\td.data.sharedStackKey,\n\t\t\t\t\ti\n\t\t\t\t)\n\t\t\t)\n\t\t\t.y0((d) => mainYScale(d[0]))\n\t\t\t.y1((d) => mainYScale(d[1]))\n\t\t\t.curve(this.services.curves.getD3Curve());\n\n\t\tareas.exit().attr('opacity', 0).remove();\n\n\t\tconst enteringAreas = areas.enter().append('path').attr('opacity', 0);\n\n\t\tenteringAreas\n\t\t\t.merge(areas)\n\t\t\t.data(stackedData, (d) => d[0][groupMapsTo])\n\t\t\t.attr('class', 'area')\n\t\t\t.attr('class', (d) =>\n\t\t\t\tthis.model.getColorClassName({\n\t\t\t\t\tclassNameTypes: [ColorClassNameTypes.FILL],\n\t\t\t\t\tdataGroupName: d[0][groupMapsTo],\n\t\t\t\t\toriginalClassName: 'area',\n\t\t\t\t})\n\t\t\t)\n\t\t\t.style('fill', (d) => self.model.getFillColor(d[0][groupMapsTo]))\n\t\t\t.attr('role', Roles.GRAPHICS_SYMBOL)\n\t\t\t.attr('aria-roledescription', 'area')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition(\n\t\t\t\t\t'area-update-enter',\n\t\t\t\t\tanimate\n\t\t\t\t)\n\t\t\t)\n\t\t\t.attr('opacity', Configuration.area.opacity.selected)\n\t\t\t.attr('d', this.areaGenerator);\n\t}\n\n\thandleLegendOnHover = (event: CustomEvent) => {\n\t\tconst { hoveredElement } = event.detail;\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tthis.parent\n\t\t\t.selectAll('path.area')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-hover-area')\n\t\t\t)\n\t\t\t.attr('opacity', (d) => {\n\t\t\t\tif (d[0][groupMapsTo] !== hoveredElement.datum().name) {\n\t\t\t\t\treturn Configuration.area.opacity.unselected;\n\t\t\t\t}\n\n\t\t\t\treturn Configuration.area.opacity.selected;\n\t\t\t});\n\t};\n\n\thandleLegendMouseOut = (event: CustomEvent) => {\n\t\tthis.parent\n\t\t\t.selectAll('path.area')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-mouseout-area')\n\t\t\t)\n\t\t\t.attr('opacity', Configuration.area.opacity.selected);\n\t};\n\n\tdestroy() {\n\t\t// Remove event listeners\n\t\tthis.parent\n\t\t\t.selectAll('path.area')\n\t\t\t.on('mouseover', null)\n\t\t\t.on('mousemove', null)\n\t\t\t.on('mouseout', null);\n\t}\n}\n"]}
1
+ {"version":3,"file":"area-stacked.js","sourceRoot":"","sources":["area-stacked.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACN,KAAK,EAEL,MAAM,EACN,mBAAmB,GAEnB,MAAM,kBAAkB,CAAC;AAE1B,aAAa;AACb,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC;IAAiC,+BAAS;IAA1C;QAAA,qEAmIC;QAlIA,UAAI,GAAG,cAAc,CAAC;QA8FtB,yBAAmB,GAAG,UAAC,KAAkB;YAChC,IAAA,4CAAc,CAAkB;YACxC,IAAM,OAAO,GAAG,KAAI,CAAC,UAAU,EAAE,CAAC;YAC1B,IAAA,sCAAW,CAAkB;YAErC,KAAI,CAAC,MAAM;iBACT,SAAS,CAAC,WAAW,CAAC;iBACtB,UAAU,CACV,KAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAC5D;iBACA,IAAI,CAAC,SAAS,EAAE,UAAC,CAAC;gBAClB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,cAAc,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE;oBACtD,OAAO,aAAa,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CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IA8BD,6BAAO,GAAP;QACC,yBAAyB;QACzB,IAAI,CAAC,MAAM;aACT,SAAS,CAAC,WAAW,CAAC;aACtB,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;aACrB,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;aACrB,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IACF,kBAAC;AAAD,CAAC,AAnID,CAAiC,SAAS,GAmIzC","sourcesContent":["// Internal Imports\nimport { Component } from '../component';\nimport { Tools } from '../../tools';\nimport * as Configuration from '../../configuration';\nimport {\n\tRoles,\n\tScaleTypes,\n\tEvents,\n\tColorClassNameTypes,\n\tCartesianOrientations,\n} from '../../interfaces';\n\n// D3 Imports\nimport { area } from 'd3-shape';\n\nexport class StackedArea extends Component {\n\ttype = 'area-stacked';\n\n\tareaGenerator: any;\n\n\tinit() {\n\t\tconst eventsFragment = this.services.events;\n\n\t\t// Highlight correct area on legend item hovers\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Legend.ITEM_HOVER,\n\t\t\tthis.handleLegendOnHover\n\t\t);\n\n\t\t// Un-highlight area on legend item mouseouts\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Legend.ITEM_MOUSEOUT,\n\t\t\tthis.handleLegendMouseOut\n\t\t);\n\t}\n\n\trender(animate = true) {\n\t\tconst svg = this.getContainerSVG({ withinChartClip: true });\n\t\tconst self = this;\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst percentage = Object.keys(options.axes).some(\n\t\t\t(axis) => options.axes[axis].percentage\n\t\t);\n\n\t\tconst stackedData = this.model.getStackedData({\n\t\t\tpercentage,\n\t\t\tgroups: this.configs.groups,\n\t\t});\n\n\t\tconst firstDatum = Tools.getProperty(stackedData, 0, 0);\n\n\t\t// area doesnt have to use the main range and domain axes - they can be mapped to the secondary (in the case of a combo chart)\n\t\t// however area _cannot_ have multiple datasets that are mapped to _different_ ranges and domains so we can use the first data item\n\t\tconst domainAxisPosition = this.services.cartesianScales.getDomainAxisPosition(\n\t\t\t{ firstDatum }\n\t\t);\n\t\tconst rangeAxisPosition = this.services.cartesianScales.getRangeAxisPosition(\n\t\t\t{ firstDatum }\n\t\t);\n\t\tconst mainYScale = this.services.cartesianScales.getScaleByPosition(\n\t\t\trangeAxisPosition\n\t\t);\n\n\t\tconst areas = svg\n\t\t\t.selectAll('path.area')\n\t\t\t.data(stackedData, (d) => d[0][groupMapsTo]);\n\n\t\t// D3 area generator function\n\t\tthis.areaGenerator = area()\n\t\t\t.x((d: any, i) =>\n\t\t\t\tthis.services.cartesianScales.getValueThroughAxisPosition(\n\t\t\t\t\tdomainAxisPosition,\n\t\t\t\t\td.data.sharedStackKey,\n\t\t\t\t\ti\n\t\t\t\t)\n\t\t\t)\n\t\t\t.y0((d) => mainYScale(d[0]))\n\t\t\t.y1((d) => mainYScale(d[1]))\n\t\t\t.curve(this.services.curves.getD3Curve());\n\n\t\tareas.exit().attr('opacity', 0).remove();\n\n\t\tconst enteringAreas = areas.enter().append('path').attr('opacity', 0);\n\n\t\tenteringAreas\n\t\t\t.merge(areas)\n\t\t\t.data(stackedData, (d) => d[0][groupMapsTo])\n\t\t\t.attr('class', 'area')\n\t\t\t.attr('class', (d) =>\n\t\t\t\tthis.model.getColorClassName({\n\t\t\t\t\tclassNameTypes: [ColorClassNameTypes.FILL],\n\t\t\t\t\tdataGroupName: d[0][groupMapsTo],\n\t\t\t\t\toriginalClassName: 'area',\n\t\t\t\t})\n\t\t\t)\n\t\t\t.style('fill', (d) => self.model.getFillColor(d[0][groupMapsTo]))\n\t\t\t.attr('role', Roles.GRAPHICS_SYMBOL)\n\t\t\t.attr('aria-roledescription', 'area')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition(\n\t\t\t\t\t'area-update-enter',\n\t\t\t\t\tanimate\n\t\t\t\t)\n\t\t\t)\n\t\t\t.attr('opacity', Configuration.area.opacity.selected)\n\t\t\t.attr('d', this.areaGenerator);\n\t}\n\n\thandleLegendOnHover = (event: CustomEvent) => {\n\t\tconst { hoveredElement } = event.detail;\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tthis.parent\n\t\t\t.selectAll('path.area')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-hover-area')\n\t\t\t)\n\t\t\t.attr('opacity', (d) => {\n\t\t\t\tif (d[0][groupMapsTo] !== hoveredElement.datum().name) {\n\t\t\t\t\treturn Configuration.area.opacity.unselected;\n\t\t\t\t}\n\n\t\t\t\treturn Configuration.area.opacity.selected;\n\t\t\t});\n\t};\n\n\thandleLegendMouseOut = () => {\n\t\tthis.parent\n\t\t\t.selectAll('path.area')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-mouseout-area')\n\t\t\t)\n\t\t\t.attr('opacity', Configuration.area.opacity.selected);\n\t};\n\n\tdestroy() {\n\t\t// Remove event listeners\n\t\tthis.parent\n\t\t\t.selectAll('path.area')\n\t\t\t.on('mouseover', null)\n\t\t\t.on('mousemove', null)\n\t\t\t.on('mouseout', null);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { Component } from '../component';
2
+ export declare class Boxplot extends Component {
3
+ type: string;
4
+ render(animate: boolean): void;
5
+ addBoxEventListeners(): void;
6
+ addCircleEventListeners(): void;
7
+ }