@eclipse-scout/chart 24.1.15 → 24.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/d.ts/chart/Chart.d.ts +18 -0
  2. package/dist/d.ts/chart/Chart.d.ts.map +1 -1
  3. package/dist/d.ts/chart/ChartJsRenderer.d.ts +14 -6
  4. package/dist/d.ts/chart/ChartJsRenderer.d.ts.map +1 -1
  5. package/dist/d.ts/chart/ChartLayout.d.ts.map +1 -1
  6. package/dist/d.ts/table/controls/ChartTableControl.d.ts.map +1 -1
  7. package/dist/eclipse-scout-chart-8156b4ff3ded6a4a0a51.min.js +3 -0
  8. package/dist/eclipse-scout-chart-8156b4ff3ded6a4a0a51.min.js.map +1 -0
  9. package/dist/eclipse-scout-chart-theme-3ac5a1e9bedc33d600c8.min.css +1 -0
  10. package/dist/eclipse-scout-chart-theme-dark-e9c7a6ec1bc2f34437ba.min.css +1 -0
  11. package/dist/eclipse-scout-chart-theme-dark.css +7 -4
  12. package/dist/eclipse-scout-chart-theme-dark.css.map +1 -1
  13. package/dist/eclipse-scout-chart-theme.css +7 -4
  14. package/dist/eclipse-scout-chart-theme.css.map +1 -1
  15. package/dist/eclipse-scout-chart.esm-d6c3855b96d1a2003edc.min.js +3 -0
  16. package/dist/eclipse-scout-chart.esm-d6c3855b96d1a2003edc.min.js.map +1 -0
  17. package/dist/eclipse-scout-chart.esm.js +77 -20
  18. package/dist/eclipse-scout-chart.esm.js.map +1 -1
  19. package/dist/eclipse-scout-chart.js +75 -19
  20. package/dist/eclipse-scout-chart.js.map +1 -1
  21. package/dist/file-list +6 -6
  22. package/package.json +3 -3
  23. package/src/chart/Chart.less +9 -5
  24. package/src/chart/Chart.ts +20 -0
  25. package/src/chart/ChartJsRenderer.ts +49 -21
  26. package/src/chart/ChartLayout.ts +11 -3
  27. package/src/table/controls/ChartTableControl.ts +4 -2
  28. package/dist/eclipse-scout-chart-2c6ae7947528f036e203.min.js +0 -3
  29. package/dist/eclipse-scout-chart-2c6ae7947528f036e203.min.js.map +0 -1
  30. package/dist/eclipse-scout-chart-theme-56ba6667e592ef147869.min.css +0 -1
  31. package/dist/eclipse-scout-chart-theme-dark-593955eea95984c5aa62.min.css +0 -1
  32. package/dist/eclipse-scout-chart.esm-25520de13e473a9171b1.min.js +0 -3
  33. package/dist/eclipse-scout-chart.esm-25520de13e473a9171b1.min.js.map +0 -1
@@ -607,7 +607,8 @@ _defineProperty(AbstractSvgChartRenderer, "FONT_SIZE_BIG", 'bigFont');
607
607
 
608
608
  __webpack_require__.r(__webpack_exports__);
609
609
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
610
- /* harmony export */ Chart: () => (/* binding */ Chart)
610
+ /* harmony export */ Chart: () => (/* binding */ Chart),
611
+ /* harmony export */ ChartColorMode: () => (/* binding */ ChartColorMode)
611
612
  /* harmony export */ });
612
613
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./src/index.ts");
613
614
  /* harmony import */ var _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @eclipse-scout/core */ "@eclipse-scout/core");
@@ -724,6 +725,7 @@ class Chart extends _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__.Widget {
724
725
  type: Chart.Type.PIE,
725
726
  options: {
726
727
  autoColor: true,
728
+ colorMode: ChartColorMode.AUTO,
727
729
  colorScheme: _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__.colorSchemes.ColorSchemeId.DEFAULT,
728
730
  transparent: false,
729
731
  maxSegments: 5,
@@ -949,6 +951,9 @@ class Chart extends _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_1__.Widget {
949
951
  });
950
952
  }
951
953
  }
954
+ /**
955
+ * Determines what parts of the chart data is colored with the same colors.
956
+ */
952
957
  _defineProperty(Chart, "Type", {
953
958
  PIE: 'pie',
954
959
  LINE: 'line',
@@ -975,6 +980,21 @@ _defineProperty(Chart, "Position", {
975
980
  _defineProperty(Chart, "DEFAULT_ANIMATION_DURATION", 600);
976
981
  // ms
977
982
  _defineProperty(Chart, "DEFAULT_DEBOUNCE_TIMEOUT", 100);
983
+ var ChartColorMode;
984
+ (function (ChartColorMode) {
985
+ /**
986
+ * Uses one of the other options depending on the chart type.
987
+ */
988
+ ChartColorMode["AUTO"] = "auto";
989
+ /**
990
+ * Uses a different color for each dataset.
991
+ */
992
+ ChartColorMode["DATASET"] = "dataset";
993
+ /**
994
+ * Uses a different color for each datapoint in a dataset but the n-th datapoint in each dataset will be colored using the same color.
995
+ */
996
+ ChartColorMode["DATA"] = "data";
997
+ })(ChartColorMode || (ChartColorMode = {}));
978
998
 
979
999
  /***/ }),
980
1000
 
@@ -1158,9 +1178,9 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
1158
1178
  this.numSupportedColors = 6;
1159
1179
  this.colorSchemeCssClass = '';
1160
1180
  this.minRadialChartDatalabelSpace = 25;
1161
- this._labelFormatter = this._formatLabel.bind(this);
1162
- this._xLabelFormatter = this._formatXLabel.bind(this);
1163
- this._yLabelFormatter = this._formatYLabel.bind(this);
1181
+ this._labelFormatter = this._createLabelFormatter(this._formatLabel);
1182
+ this._xLabelFormatter = this._createLabelFormatter(this._formatXLabel);
1183
+ this._yLabelFormatter = this._createLabelFormatter(this._formatYLabel);
1164
1184
  this._xAxisFitter = this._fitXAxis.bind(this);
1165
1185
  this._yAxisFitter = this._fitYAxis.bind(this);
1166
1186
  this._radialChartDatalabelsDisplayHandler = this._displayDatalabelsOnRadialChart.bind(this);
@@ -1852,8 +1872,8 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
1852
1872
  return _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex].z));
1853
1873
  } else if (config.type === _index__WEBPACK_IMPORTED_MODULE_0__.Chart.Type.SCATTER) {
1854
1874
  return {
1855
- x: _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex].x)),
1856
- y: _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex].y))
1875
+ x: _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.encode(this._formatXLabel(dataset.data[tooltipItem.dataIndex].x)),
1876
+ y: _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.encode(this._formatYLabel(dataset.data[tooltipItem.dataIndex].y))
1857
1877
  };
1858
1878
  }
1859
1879
  return _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex]));
@@ -2104,6 +2124,7 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
2104
2124
  callback: this._labelFormatter
2105
2125
  },
2106
2126
  pointLabels: {
2127
+ callback: this._labelFormatter,
2107
2128
  font: {
2108
2129
  size: chart_js__WEBPACK_IMPORTED_MODULE_1__.Chart.defaults.font.size
2109
2130
  }
@@ -2323,20 +2344,41 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
2323
2344
  formatter: this._datalabelsFormatter
2324
2345
  }, plugins.datalabels);
2325
2346
  }
2326
- _formatLabel(label) {
2327
- return this._formatLabelMap(label, null, this._getNumberFormatter());
2328
- }
2329
2347
  _getNumberFormatter() {
2330
- if (this.chartJs && this.chartJs.config && this.chartJs.config.options) {
2331
- return this.chartJs.config.options.numberFormatter;
2332
- }
2348
+ var _this$chartJs;
2349
+ return (_this$chartJs = this.chartJs) === null || _this$chartJs === void 0 || (_this$chartJs = _this$chartJs.config) === null || _this$chartJs === void 0 || (_this$chartJs = _this$chartJs.options) === null || _this$chartJs === void 0 ? void 0 : _this$chartJs.numberFormatter;
2350
+ }
2351
+ /**
2352
+ * Creates an unbound function that calls the given formatter on this {@link ChartJsRenderer}. The context of this
2353
+ * unbound function is passed to the formatter as argument.
2354
+ */
2355
+ _createLabelFormatter(formatter) {
2356
+ const renderer = this;
2357
+ return function (label) {
2358
+ return formatter.call(renderer, label, this);
2359
+ };
2360
+ }
2361
+ _formatLabel(label, scale) {
2362
+ label = this._formatCategory(label, scale);
2363
+ return this._formatLabelMap(label, null, this._getNumberFormatter());
2333
2364
  }
2334
- _formatXLabel(label) {
2365
+ _formatXLabel(label, scale) {
2366
+ label = this._formatCategory(label, scale);
2335
2367
  return this._formatLabelMap(label, this._getXLabelMap(), this._getNumberFormatter());
2336
2368
  }
2337
- _formatYLabel(label) {
2369
+ _formatYLabel(label, scale) {
2370
+ label = this._formatCategory(label, scale);
2338
2371
  return this._formatLabelMap(label, this._getYLabelMap(), this._getNumberFormatter());
2339
2372
  }
2373
+ /**
2374
+ * Uses the given scale to format the given label iff it is a {@link CategoryScale}.
2375
+ */
2376
+ _formatCategory(label, scale) {
2377
+ if (scale instanceof chart_js__WEBPACK_IMPORTED_MODULE_1__.CategoryScale && _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.numbers.isNumber(label)) {
2378
+ return scale.getLabelForValue(label);
2379
+ }
2380
+ return label;
2381
+ }
2340
2382
  _getXLabelMap() {
2341
2383
  return this._getLabelMap('xLabelMap');
2342
2384
  }
@@ -2499,7 +2541,7 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
2499
2541
  if (config.type === _index__WEBPACK_IMPORTED_MODULE_0__.Chart.Type.BUBBLE) {
2500
2542
  return this._formatLabel(value.z);
2501
2543
  } else if (config.type === _index__WEBPACK_IMPORTED_MODULE_0__.Chart.Type.SCATTER) {
2502
- return _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.join(' / ', this._formatLabel(value.x), this._formatLabel(value.y));
2544
+ return _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.strings.join(' / ', this._formatXLabel(value.x), this._formatYLabel(value.y));
2503
2545
  }
2504
2546
  return this._formatLabel(value);
2505
2547
  }
@@ -2528,7 +2570,8 @@ class ChartJsRenderer extends _index__WEBPACK_IMPORTED_MODULE_0__.AbstractChartR
2528
2570
  type = config.type,
2529
2571
  autoColor = config.options && config.options.autoColor,
2530
2572
  checkable = config.options && config.options.checkable,
2531
- multipleColorsPerDataset = autoColor && _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.scout.isOneOf(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),
2573
+ colorMode = config.options && config.options.colorMode,
2574
+ multipleColorsPerDataset = autoColor && (colorMode === _index__WEBPACK_IMPORTED_MODULE_0__.ChartColorMode.DATASET ? false : colorMode === _index__WEBPACK_IMPORTED_MODULE_0__.ChartColorMode.DATA ? true : _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_2__.scout.isOneOf(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)),
2532
2575
  colors = {
2533
2576
  backgroundColors: [],
2534
2577
  borderColors: [],
@@ -3582,7 +3625,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
3582
3625
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3583
3626
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
3584
3627
  /*
3585
- * Copyright (c) 2010, 2023 BSI Business Systems Integration AG
3628
+ * Copyright (c) 2010, 2024 BSI Business Systems Integration AG
3586
3629
  *
3587
3630
  * This program and the accompanying materials are made
3588
3631
  * available under the terms of the Eclipse Public License 2.0
@@ -3599,6 +3642,7 @@ class ChartLayout extends _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__.Abstr
3599
3642
  this.chart = chart;
3600
3643
  }
3601
3644
  layout($container) {
3645
+ var _this$chart$findParen;
3602
3646
  let opts = {
3603
3647
  requestAnimation: true,
3604
3648
  debounce: _index__WEBPACK_IMPORTED_MODULE_1__.Chart.DEFAULT_DEBOUNCE_TIMEOUT,
@@ -3613,6 +3657,15 @@ class ChartLayout extends _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__.Abstr
3613
3657
  if (!this.chart.session.ready) {
3614
3658
  opts.debounce = false;
3615
3659
  }
3660
+ // Don't debounce if the chart is inside a tile that is being dragged so the state is correct immediately when it is dropped
3661
+ if ((_this$chart$findParen = this.chart.findParent(_eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__.Tile)) !== null && _this$chart$findParen !== void 0 && _this$chart$findParen.$container.hasClass('dragged')) {
3662
+ opts.debounce = false;
3663
+ }
3664
+ // Ensure chart has the correct size right after the layout.
3665
+ if (this.chart.chartRenderer instanceof _index__WEBPACK_IMPORTED_MODULE_1__.ChartJsRenderer) {
3666
+ var _this$chart$chartRend;
3667
+ (_this$chart$chartRend = this.chart.chartRenderer.chartJs) === null || _this$chart$chartRend === void 0 || _this$chart$chartRend.resize();
3668
+ }
3616
3669
  this.chart.updateChart(opts);
3617
3670
  }
3618
3671
  }
@@ -5617,6 +5670,7 @@ __webpack_require__.r(__webpack_exports__);
5617
5670
  /* harmony export */ AbstractSvgChartRenderer: () => (/* reexport safe */ _chart_AbstractSvgChartRenderer__WEBPACK_IMPORTED_MODULE_7__.AbstractSvgChartRenderer),
5618
5671
  /* harmony export */ Chart: () => (/* reexport safe */ _chart_Chart__WEBPACK_IMPORTED_MODULE_1__.Chart),
5619
5672
  /* harmony export */ ChartAdapter: () => (/* reexport safe */ _chart_ChartAdapter__WEBPACK_IMPORTED_MODULE_2__.ChartAdapter),
5673
+ /* harmony export */ ChartColorMode: () => (/* reexport safe */ _chart_Chart__WEBPACK_IMPORTED_MODULE_1__.ChartColorMode),
5620
5674
  /* harmony export */ ChartField: () => (/* reexport safe */ _form_fields_chartfield_ChartField__WEBPACK_IMPORTED_MODULE_17__.ChartField),
5621
5675
  /* harmony export */ ChartFieldAdapter: () => (/* reexport safe */ _form_fields_chartfield_ChartFieldAdapter__WEBPACK_IMPORTED_MODULE_18__.ChartFieldAdapter),
5622
5676
  /* harmony export */ ChartFieldTile: () => (/* reexport safe */ _tile_ChartFieldTile__WEBPACK_IMPORTED_MODULE_20__.ChartFieldTile),
@@ -5733,7 +5787,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
5733
5787
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5734
5788
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5735
5789
  /*
5736
- * Copyright (c) 2010, 2023 BSI Business Systems Integration AG
5790
+ * Copyright (c) 2010, 2024 BSI Business Systems Integration AG
5737
5791
  *
5738
5792
  * This program and the accompanying materials are made
5739
5793
  * available under the terms of the Eclipse Public License 2.0
@@ -6365,7 +6419,9 @@ class ChartTableControl extends _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__
6365
6419
  let label,
6366
6420
  keyX = xAxis[x];
6367
6421
  if (xAxis.column instanceof _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__.NumberColumn) {
6368
- label = keyX;
6422
+ // the axis will format numbers as two digit decimals and null/undefined as the text '-empty-' or something similar
6423
+ // only pass null/undefined to the axis as we want to leave the number format to the chart but need the '-empty-' string
6424
+ label = _eclipse_scout_core__WEBPACK_IMPORTED_MODULE_0__.objects.isNullOrUndefined(keyX) ? xAxis.format(keyX) : keyX;
6369
6425
  } else {
6370
6426
  label = this._handleIconLabel(xAxis.format(keyX), xAxis, iconClasses);
6371
6427
  }