@eclipse-scout/chart 22.0.39 → 22.0.41

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.
@@ -187,7 +187,9 @@ __webpack_require__.r(__webpack_exports__);
187
187
  /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jquery */ "jquery");
188
188
  /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_1__);
189
189
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "./src/index.js");
190
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
190
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
191
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
192
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
191
193
  /*
192
194
  * Copyright (c) 2010-2021 BSI Business Systems Integration AG.
193
195
  * All rights reserved. This program and the accompanying materials
@@ -562,7 +564,9 @@ __webpack_require__.r(__webpack_exports__);
562
564
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./src/index.js");
563
565
  /* harmony import */ var _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @eclipse-scout/core */ "@eclipse-scout/core");
564
566
  /* harmony import */ var _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__);
565
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
567
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
568
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
569
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
566
570
  /*
567
571
  * Copyright (c) 2010-2022 BSI Business Systems Integration AG.
568
572
  * All rights reserved. This program and the accompanying materials
@@ -805,6 +809,7 @@ class Chart extends _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__.Widget {
805
809
  */
806
810
  updateChart(opts) {
807
811
  opts = opts || {};
812
+ opts.onlyUpdateData = opts.onlyUpdateData && this.chartRenderer && this.chartRenderer.isDataUpdatable();
808
813
  opts.enforceRerender = !opts.onlyUpdateData && !opts.onlyRefresh;
809
814
 
810
815
  // Cancel previously scheduled update and merge opts
@@ -856,7 +861,7 @@ class Chart extends _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__.Widget {
856
861
  this.chartRenderer.render(opts.requestAnimation);
857
862
  this.trigger('chartRender');
858
863
  });
859
- } else if (opts.onlyUpdateData && this.chartRenderer.isDataUpdatable()) {
864
+ } else if (opts.onlyUpdateData) {
860
865
  this.chartRenderer.updateData(opts.requestAnimation);
861
866
  } else if (opts.onlyRefresh) {
862
867
  this.chartRenderer.refresh();
@@ -993,7 +998,9 @@ __webpack_require__.r(__webpack_exports__);
993
998
  /* harmony import */ var chartjs_plugin_datalabels__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(chartjs_plugin_datalabels__WEBPACK_IMPORTED_MODULE_3__);
994
999
  /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! jquery */ "jquery");
995
1000
  /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_4__);
996
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1001
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1002
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
1003
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
997
1004
  /*
998
1005
  * Copyright (c) 2010-2022 BSI Business Systems Integration AG.
999
1006
  * All rights reserved. This program and the accompanying materials
@@ -1918,6 +1925,11 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
1918
1925
  if (dataPoints.length < 1) {
1919
1926
  return;
1920
1927
  }
1928
+ let firstDataPoint = dataPoints[0],
1929
+ chart = firstDataPoint.chart;
1930
+ if (!chart.getDatasetMeta(firstDataPoint.datasetIndex).data[firstDataPoint.dataIndex]) {
1931
+ return;
1932
+ }
1921
1933
  if (this._tooltip) {
1922
1934
  this._tooltip.destroy();
1923
1935
  this._tooltip = null;
@@ -1936,7 +1948,7 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
1936
1948
  if (_eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.objects.isFunction(tooltipItems)) {
1937
1949
  tooltipText += _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.arrays.ensure(tooltipItems(dataPoints, tooltipLabel, tooltipLabelValue, tooltipColor)).join('');
1938
1950
  }
1939
- let positionAndOffset = this._computeTooltipPositionAndOffset(dataPoints[0]),
1951
+ let positionAndOffset = this._computeTooltipPositionAndOffset(firstDataPoint),
1940
1952
  origin = _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.graphics.offsetBounds(this.$canvas);
1941
1953
  origin.x += tooltip.caretX + positionAndOffset.offsetX;
1942
1954
  origin.y += tooltip.caretY + positionAndOffset.offsetY;
@@ -1985,7 +1997,12 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
1985
1997
  dataset = datasets[datasetIndex],
1986
1998
  value = dataset.data[dataIndex];
1987
1999
  if (this._isHorizontalBar(config)) {
1988
- tooltipDirection = value < 0 ? 'left' : 'right';
2000
+ if (value && _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.objects.isArray(value.x) && value.x.length === 2) {
2001
+ let avg = (value.x[0] + value.x[1]) / 2;
2002
+ tooltipDirection = avg < 0 ? 'left' : 'right';
2003
+ } else {
2004
+ tooltipDirection = value < 0 ? 'left' : 'right';
2005
+ }
1989
2006
  } else if ((dataset.type || config.type) === _index__WEBPACK_IMPORTED_MODULE_0__.Chart.Type.BAR) {
1990
2007
  tooltipPosition = value < 0 ? 'bottom' : 'top';
1991
2008
  } else if (_eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.scout.isOneOf(config.type, _index__WEBPACK_IMPORTED_MODULE_0__.Chart.Type.PIE, _index__WEBPACK_IMPORTED_MODULE_0__.Chart.Type.DOUGHNUT, _index__WEBPACK_IMPORTED_MODULE_0__.Chart.Type.POLAR_AREA)) {
@@ -4148,13 +4165,15 @@ __webpack_require__.r(__webpack_exports__);
4148
4165
  /* harmony import */ var _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @eclipse-scout/core */ "@eclipse-scout/core");
4149
4166
  /* harmony import */ var _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__);
4150
4167
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./src/index.js");
4151
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4168
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4169
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4170
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4152
4171
  /*
4153
- * Copyright (c) 2010-2021 BSI Business Systems Integration AG.
4172
+ * Copyright (c) 2010-2022 BSI Business Systems Integration AG.
4154
4173
  * All rights reserved. This program and the accompanying materials
4155
4174
  * are made available under the terms of the Eclipse Public License v1.0
4156
4175
  * which accompanies this distribution, and is available at
4157
- * http://www.eclipse.org/legal/epl-v10.html
4176
+ * https://www.eclipse.org/legal/epl-v10.html
4158
4177
  *
4159
4178
  * Contributors:
4160
4179
  * BSI Business Systems Integration AG - initial API and implementation
@@ -4216,10 +4235,10 @@ class SpeedoChartRenderer extends _index__WEBPACK_IMPORTED_MODULE_1__.AbstractSv
4216
4235
  this.widthOfSegmentWithGap = this.segmentWidth + SpeedoChartRenderer.SEGMENT_GAP;
4217
4236
 
4218
4237
  // pointer value in range [0,1]
4219
- let valuePercentage = this._limitValue((value - minValue) / (maxValue - minValue), 1);
4238
+ let valuePercentage = this._getValuePercentage(value, minValue, maxValue);
4220
4239
 
4221
- // value in the range [0,1] rounded to one segment
4222
- let segmentToPointAt = Math.round(valuePercentage * numTotalGaps);
4240
+ // value in the range [0,numTotalSegments - 1] rounded to one segment
4241
+ let segmentToPointAt = this._getSegmentToPointAt(valuePercentage, numTotalSegments);
4223
4242
 
4224
4243
  // value rounded to the closest segment so that the pointer never stays "in between" two segments but always on a segment
4225
4244
  let valuePercentageRounded = this._getPercentageValueOfSegment(segmentToPointAt % this.numSegmentsPerPart, this._getPartForValue(valuePercentage));
@@ -4233,6 +4252,12 @@ class SpeedoChartRenderer extends _index__WEBPACK_IMPORTED_MODULE_1__.AbstractSv
4233
4252
  this.$svg.on('click', this._createClickObject(null, null), this.chart._onValueClick.bind(this.chart));
4234
4253
  }
4235
4254
  }
4255
+ _getValuePercentage(value, minValue, maxValue) {
4256
+ return this._limitValue((value - minValue) / (maxValue - minValue), 1);
4257
+ }
4258
+ _getSegmentToPointAt(valuePercentage, numTotalSegments) {
4259
+ return this._limitValue(Math.floor(valuePercentage * numTotalSegments), numTotalSegments - 1);
4260
+ }
4236
4261
  _limitValue(value, maxValue) {
4237
4262
  value = Math.max(value, 0); // cannot be < 0
4238
4263
  value = Math.min(value, maxValue); // cannot be > maxValue
@@ -5466,7 +5491,9 @@ __webpack_require__.r(__webpack_exports__);
5466
5491
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../index */ "./src/index.js");
5467
5492
  /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! jquery */ "jquery");
5468
5493
  /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_2__);
5469
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5494
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5495
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5496
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5470
5497
  /*
5471
5498
  * Copyright (c) 2010-2021 BSI Business Systems Integration AG.
5472
5499
  * All rights reserved. This program and the accompanying materials
@@ -6640,7 +6667,9 @@ __webpack_require__.r(__webpack_exports__);
6640
6667
  /* harmony export */ });
6641
6668
  /* harmony import */ var _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @eclipse-scout/core */ "@eclipse-scout/core");
6642
6669
  /* harmony import */ var _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__);
6643
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6670
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6671
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
6672
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6644
6673
  /*
6645
6674
  * Copyright (c) 2010-2020 BSI Business Systems Integration AG.
6646
6675
  * All rights reserved. This program and the accompanying materials