@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.
- package/dist/d.ts/chart/Chart.d.ts +18 -0
- package/dist/d.ts/chart/Chart.d.ts.map +1 -1
- package/dist/d.ts/chart/ChartJsRenderer.d.ts +14 -6
- package/dist/d.ts/chart/ChartJsRenderer.d.ts.map +1 -1
- package/dist/d.ts/chart/ChartLayout.d.ts.map +1 -1
- package/dist/d.ts/table/controls/ChartTableControl.d.ts.map +1 -1
- package/dist/eclipse-scout-chart-8156b4ff3ded6a4a0a51.min.js +3 -0
- package/dist/eclipse-scout-chart-8156b4ff3ded6a4a0a51.min.js.map +1 -0
- package/dist/eclipse-scout-chart-theme-3ac5a1e9bedc33d600c8.min.css +1 -0
- package/dist/eclipse-scout-chart-theme-dark-e9c7a6ec1bc2f34437ba.min.css +1 -0
- package/dist/eclipse-scout-chart-theme-dark.css +7 -4
- package/dist/eclipse-scout-chart-theme-dark.css.map +1 -1
- package/dist/eclipse-scout-chart-theme.css +7 -4
- package/dist/eclipse-scout-chart-theme.css.map +1 -1
- package/dist/eclipse-scout-chart.esm-d6c3855b96d1a2003edc.min.js +3 -0
- package/dist/eclipse-scout-chart.esm-d6c3855b96d1a2003edc.min.js.map +1 -0
- package/dist/eclipse-scout-chart.esm.js +77 -20
- package/dist/eclipse-scout-chart.esm.js.map +1 -1
- package/dist/eclipse-scout-chart.js +75 -19
- package/dist/eclipse-scout-chart.js.map +1 -1
- package/dist/file-list +6 -6
- package/package.json +3 -3
- package/src/chart/Chart.less +9 -5
- package/src/chart/Chart.ts +20 -0
- package/src/chart/ChartJsRenderer.ts +49 -21
- package/src/chart/ChartLayout.ts +11 -3
- package/src/table/controls/ChartTableControl.ts +4 -2
- package/dist/eclipse-scout-chart-2c6ae7947528f036e203.min.js +0 -3
- package/dist/eclipse-scout-chart-2c6ae7947528f036e203.min.js.map +0 -1
- package/dist/eclipse-scout-chart-theme-56ba6667e592ef147869.min.css +0 -1
- package/dist/eclipse-scout-chart-theme-dark-593955eea95984c5aa62.min.css +0 -1
- package/dist/eclipse-scout-chart.esm-25520de13e473a9171b1.min.js +0 -3
- package/dist/eclipse-scout-chart.esm-25520de13e473a9171b1.min.js.map +0 -1
package/dist/file-list
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
eclipse-scout-chart-
|
|
2
|
-
eclipse-scout-chart-
|
|
3
|
-
eclipse-scout-chart-theme-
|
|
4
|
-
eclipse-scout-chart-theme-dark-
|
|
1
|
+
eclipse-scout-chart-8156b4ff3ded6a4a0a51.min.js
|
|
2
|
+
eclipse-scout-chart-8156b4ff3ded6a4a0a51.min.js.map
|
|
3
|
+
eclipse-scout-chart-theme-3ac5a1e9bedc33d600c8.min.css
|
|
4
|
+
eclipse-scout-chart-theme-dark-e9c7a6ec1bc2f34437ba.min.css
|
|
5
5
|
eclipse-scout-chart-theme-dark.css
|
|
6
6
|
eclipse-scout-chart-theme-dark.css.map
|
|
7
7
|
eclipse-scout-chart-theme.css
|
|
8
8
|
eclipse-scout-chart-theme.css.map
|
|
9
|
-
eclipse-scout-chart.esm-
|
|
10
|
-
eclipse-scout-chart.esm-
|
|
9
|
+
eclipse-scout-chart.esm-d6c3855b96d1a2003edc.min.js
|
|
10
|
+
eclipse-scout-chart.esm-d6c3855b96d1a2003edc.min.js.map
|
|
11
11
|
eclipse-scout-chart.esm.js
|
|
12
12
|
eclipse-scout-chart.esm.js.map
|
|
13
13
|
eclipse-scout-chart.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-scout/chart",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.2.0-beta.2",
|
|
4
4
|
"description": "Eclipse Scout chart",
|
|
5
5
|
"author": "BSI Business Systems Integration AG",
|
|
6
6
|
"homepage": "https://www.eclipse.org/scout",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@eclipse-scout/cli": "24.
|
|
29
|
+
"@eclipse-scout/cli": "24.2.0-beta.2",
|
|
30
30
|
"@eclipse-scout/releng": "^24.1.0",
|
|
31
31
|
"jasmine-core": "5.1.1",
|
|
32
32
|
"jasmine-jquery": "2.1.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/jasmine-jquery": "1.5.37"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@eclipse-scout/core": "24.
|
|
39
|
+
"@eclipse-scout/core": "24.2.0-beta.2",
|
|
40
40
|
"jquery": "3.7.1",
|
|
41
41
|
"chart.js": "4.4.0",
|
|
42
42
|
"chartjs-plugin-datalabels": "2.2.0"
|
package/src/chart/Chart.less
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010,
|
|
2
|
+
* Copyright (c) 2010, 2024 BSI Business Systems Integration AG
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -390,12 +390,16 @@
|
|
|
390
390
|
/* min-width for charts */
|
|
391
391
|
@chart-min-width: 75px;
|
|
392
392
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
overflow: visible;
|
|
393
|
+
.tile > .chart-field {
|
|
394
|
+
overflow: hidden;
|
|
396
395
|
|
|
397
|
-
|
|
396
|
+
/* use padding area for label, legend */
|
|
397
|
+
& > .field.chart {
|
|
398
398
|
overflow: visible;
|
|
399
|
+
|
|
400
|
+
& > svg {
|
|
401
|
+
overflow: visible;
|
|
402
|
+
}
|
|
399
403
|
}
|
|
400
404
|
}
|
|
401
405
|
|
package/src/chart/Chart.ts
CHANGED
|
@@ -150,6 +150,7 @@ export class Chart extends Widget implements ChartModel {
|
|
|
150
150
|
type: Chart.Type.PIE,
|
|
151
151
|
options: {
|
|
152
152
|
autoColor: true,
|
|
153
|
+
colorMode: ChartColorMode.AUTO,
|
|
153
154
|
colorScheme: colorSchemes.ColorSchemeId.DEFAULT,
|
|
154
155
|
transparent: false,
|
|
155
156
|
maxSegments: 5,
|
|
@@ -421,6 +422,7 @@ export type ChartConfig = Partial<Omit<ChartConfiguration, 'type' | 'options'>>
|
|
|
421
422
|
|
|
422
423
|
export type ChartConfigOptions = Omit<ChartOptions, 'scales'> & {
|
|
423
424
|
autoColor?: boolean;
|
|
425
|
+
colorMode?: ChartColorMode;
|
|
424
426
|
colorScheme?: ColorScheme | string;
|
|
425
427
|
transparent?: boolean;
|
|
426
428
|
maxSegments?: number;
|
|
@@ -484,6 +486,24 @@ export type ChartType = EnumObject<typeof Chart.Type>;
|
|
|
484
486
|
export type ChartPosition = EnumObject<typeof Chart.Position>;
|
|
485
487
|
export type NumberFormatter = (label: number | string, defaultFormatter: (label: number | string) => string) => string;
|
|
486
488
|
|
|
489
|
+
/**
|
|
490
|
+
* Determines what parts of the chart data is colored with the same colors.
|
|
491
|
+
*/
|
|
492
|
+
export enum ChartColorMode {
|
|
493
|
+
/**
|
|
494
|
+
* Uses one of the other options depending on the chart type.
|
|
495
|
+
*/
|
|
496
|
+
AUTO = 'auto',
|
|
497
|
+
/**
|
|
498
|
+
* Uses a different color for each dataset.
|
|
499
|
+
*/
|
|
500
|
+
DATASET = 'dataset',
|
|
501
|
+
/**
|
|
502
|
+
* 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.
|
|
503
|
+
*/
|
|
504
|
+
DATA = 'data'
|
|
505
|
+
}
|
|
506
|
+
|
|
487
507
|
export type ClickObject = {
|
|
488
508
|
datasetIndex: number;
|
|
489
509
|
dataIndex: number;
|
|
@@ -7,17 +7,16 @@
|
|
|
7
7
|
*
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
*/
|
|
10
|
-
import {AbstractChartRenderer, CartesianChartScale, Chart, chartJsDateAdapter, RadialChartScale} from '../index';
|
|
10
|
+
import {AbstractChartRenderer, CartesianChartScale, Chart, ChartAxis, ChartColorMode, ChartConfig, ChartData, chartJsDateAdapter, ChartType, ClickObject, NumberFormatter, RadialChartScale} from '../index';
|
|
11
11
|
import {
|
|
12
|
-
_adapters as chartJsAdapters, ActiveElement, ArcElement, BarElement, BubbleDataPoint, CartesianScaleOptions, Chart as ChartJs, ChartArea, ChartConfiguration, ChartDataset, ChartEvent, ChartType as ChartJsType, Color,
|
|
13
|
-
FontSpec, LegendElement, LegendItem, LegendOptions, LinearScaleOptions, PointElement, PointHoverOptions, RadialLinearScaleOptions, Scale, ScatterDataPoint, Scriptable, ScriptableContext, TooltipCallbacks, TooltipItem,
|
|
14
|
-
TooltipModel, TooltipOptions
|
|
12
|
+
_adapters as chartJsAdapters, ActiveElement, ArcElement, BarElement, BubbleDataPoint, CartesianScaleOptions, CategoryScale, Chart as ChartJs, ChartArea, ChartConfiguration, ChartDataset, ChartEvent, ChartType as ChartJsType, Color,
|
|
13
|
+
DefaultDataPoint, FontSpec, LegendElement, LegendItem, LegendOptions, LinearScaleOptions, PointElement, PointHoverOptions, RadialLinearScaleOptions, Scale, ScatterDataPoint, Scriptable, ScriptableContext, TooltipCallbacks, TooltipItem,
|
|
14
|
+
TooltipLabelStyle, TooltipModel, TooltipOptions
|
|
15
15
|
} from 'chart.js';
|
|
16
16
|
import 'chart.js/auto'; // Import from auto to register charts
|
|
17
17
|
import {aria, arrays, colorSchemes, graphics, numbers, objects, Point, scout, strings, styles, Tooltip, tooltips} from '@eclipse-scout/core';
|
|
18
18
|
import ChartDataLabels, {Context} from 'chartjs-plugin-datalabels';
|
|
19
19
|
import $ from 'jquery';
|
|
20
|
-
import {ChartAxis, ChartConfig, ChartData, ChartType, ClickObject, NumberFormatter} from './Chart';
|
|
21
20
|
|
|
22
21
|
ChartJs.register(ChartDataLabels);
|
|
23
22
|
|
|
@@ -124,9 +123,9 @@ export class ChartJsRenderer extends AbstractChartRenderer {
|
|
|
124
123
|
this.colorSchemeCssClass = '';
|
|
125
124
|
this.minRadialChartDatalabelSpace = 25;
|
|
126
125
|
|
|
127
|
-
this._labelFormatter = this.
|
|
128
|
-
this._xLabelFormatter = this.
|
|
129
|
-
this._yLabelFormatter = this.
|
|
126
|
+
this._labelFormatter = this._createLabelFormatter(this._formatLabel);
|
|
127
|
+
this._xLabelFormatter = this._createLabelFormatter(this._formatXLabel);
|
|
128
|
+
this._yLabelFormatter = this._createLabelFormatter(this._formatYLabel);
|
|
130
129
|
|
|
131
130
|
this._xAxisFitter = this._fitXAxis.bind(this);
|
|
132
131
|
this._yAxisFitter = this._fitYAxis.bind(this);
|
|
@@ -907,8 +906,8 @@ export class ChartJsRenderer extends AbstractChartRenderer {
|
|
|
907
906
|
return strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex].z));
|
|
908
907
|
} else if (config.type === Chart.Type.SCATTER) {
|
|
909
908
|
return {
|
|
910
|
-
x: strings.encode(this.
|
|
911
|
-
y: strings.encode(this.
|
|
909
|
+
x: strings.encode(this._formatXLabel(dataset.data[tooltipItem.dataIndex].x)),
|
|
910
|
+
y: strings.encode(this._formatYLabel(dataset.data[tooltipItem.dataIndex].y))
|
|
912
911
|
};
|
|
913
912
|
}
|
|
914
913
|
return strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex]));
|
|
@@ -1190,6 +1189,7 @@ export class ChartJsRenderer extends AbstractChartRenderer {
|
|
|
1190
1189
|
callback: this._labelFormatter
|
|
1191
1190
|
},
|
|
1192
1191
|
pointLabels: {
|
|
1192
|
+
callback: this._labelFormatter,
|
|
1193
1193
|
font: {
|
|
1194
1194
|
size: ChartJs.defaults.font.size
|
|
1195
1195
|
}
|
|
@@ -1428,24 +1428,46 @@ export class ChartJsRenderer extends AbstractChartRenderer {
|
|
|
1428
1428
|
}, plugins.datalabels);
|
|
1429
1429
|
}
|
|
1430
1430
|
|
|
1431
|
-
protected
|
|
1432
|
-
return this.
|
|
1431
|
+
protected _getNumberFormatter(): NumberFormatter {
|
|
1432
|
+
return this.chartJs?.config?.options?.numberFormatter;
|
|
1433
1433
|
}
|
|
1434
1434
|
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1435
|
+
/**
|
|
1436
|
+
* Creates an unbound function that calls the given formatter on this {@link ChartJsRenderer}. The context of this
|
|
1437
|
+
* unbound function is passed to the formatter as argument.
|
|
1438
|
+
*/
|
|
1439
|
+
protected _createLabelFormatter(formatter: LabelFormatter): LabelFormatter {
|
|
1440
|
+
const renderer = this;
|
|
1441
|
+
return function(label) {
|
|
1442
|
+
return formatter.call(renderer, label, this);
|
|
1443
|
+
};
|
|
1439
1444
|
}
|
|
1440
1445
|
|
|
1441
|
-
protected
|
|
1446
|
+
protected _formatLabel(label: number | string, scale?: Scale): string {
|
|
1447
|
+
label = this._formatCategory(label, scale);
|
|
1448
|
+
return this._formatLabelMap(label, null, this._getNumberFormatter());
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
protected _formatXLabel(label: number | string, scale?: Scale): string {
|
|
1452
|
+
label = this._formatCategory(label, scale);
|
|
1442
1453
|
return this._formatLabelMap(label, this._getXLabelMap(), this._getNumberFormatter());
|
|
1443
1454
|
}
|
|
1444
1455
|
|
|
1445
|
-
protected _formatYLabel(label: number | string): string {
|
|
1456
|
+
protected _formatYLabel(label: number | string, scale?: Scale): string {
|
|
1457
|
+
label = this._formatCategory(label, scale);
|
|
1446
1458
|
return this._formatLabelMap(label, this._getYLabelMap(), this._getNumberFormatter());
|
|
1447
1459
|
}
|
|
1448
1460
|
|
|
1461
|
+
/**
|
|
1462
|
+
* Uses the given scale to format the given label iff it is a {@link CategoryScale}.
|
|
1463
|
+
*/
|
|
1464
|
+
protected _formatCategory(label: number | string, scale?: Scale): number | string {
|
|
1465
|
+
if (scale instanceof CategoryScale && numbers.isNumber(label)) {
|
|
1466
|
+
return scale.getLabelForValue(label);
|
|
1467
|
+
}
|
|
1468
|
+
return label;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1449
1471
|
protected _getXLabelMap(): Record<number | string, string> {
|
|
1450
1472
|
return this._getLabelMap('xLabelMap');
|
|
1451
1473
|
}
|
|
@@ -1623,7 +1645,7 @@ export class ChartJsRenderer extends AbstractChartRenderer {
|
|
|
1623
1645
|
if (config.type === Chart.Type.BUBBLE) {
|
|
1624
1646
|
return this._formatLabel((value as BubbleDataPoint).z);
|
|
1625
1647
|
} else if (config.type === Chart.Type.SCATTER) {
|
|
1626
|
-
return strings.join(' / ', this.
|
|
1648
|
+
return strings.join(' / ', this._formatXLabel((value as ScatterDataPoint).x), this._formatYLabel((value as ScatterDataPoint).y));
|
|
1627
1649
|
}
|
|
1628
1650
|
return this._formatLabel(value as number);
|
|
1629
1651
|
}
|
|
@@ -1657,7 +1679,13 @@ export class ChartJsRenderer extends AbstractChartRenderer {
|
|
|
1657
1679
|
type = config.type,
|
|
1658
1680
|
autoColor = config.options && config.options.autoColor,
|
|
1659
1681
|
checkable = config.options && config.options.checkable,
|
|
1660
|
-
|
|
1682
|
+
colorMode = config.options && config.options.colorMode,
|
|
1683
|
+
multipleColorsPerDataset = autoColor && (
|
|
1684
|
+
colorMode === ChartColorMode.DATASET
|
|
1685
|
+
? false
|
|
1686
|
+
: colorMode === ChartColorMode.DATA
|
|
1687
|
+
? true
|
|
1688
|
+
: scout.isOneOf(type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)),
|
|
1661
1689
|
colors = {
|
|
1662
1690
|
backgroundColors: [],
|
|
1663
1691
|
borderColors: [],
|
|
@@ -2835,7 +2863,7 @@ export class ChartJsRenderer extends AbstractChartRenderer {
|
|
|
2835
2863
|
}
|
|
2836
2864
|
}
|
|
2837
2865
|
|
|
2838
|
-
export type LabelFormatter = (label: number | string) => string;
|
|
2866
|
+
export type LabelFormatter = (label: number | string, scale?: Scale) => string;
|
|
2839
2867
|
export type AxisFitter = (axis: Scale<CartesianScaleOptions>) => void;
|
|
2840
2868
|
export type DatalabelsDisplayHandler = (context: Context) => boolean;
|
|
2841
2869
|
export type DatalabelsFormatter = (value: number | ScatterDataPoint | BubbleDataPoint, context: Context) => string;
|
package/src/chart/ChartLayout.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010,
|
|
2
|
+
* Copyright (c) 2010, 2024 BSI Business Systems Integration AG
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
*/
|
|
10
|
-
import {AbstractLayout} from '@eclipse-scout/core';
|
|
11
|
-
import {
|
|
10
|
+
import {AbstractLayout, Tile} from '@eclipse-scout/core';
|
|
11
|
+
import {Chart, ChartJsRenderer, UpdateChartOptions} from '../index';
|
|
12
12
|
|
|
13
13
|
export class ChartLayout extends AbstractLayout {
|
|
14
14
|
chart: Chart;
|
|
@@ -33,6 +33,14 @@ export class ChartLayout extends AbstractLayout {
|
|
|
33
33
|
if (!this.chart.session.ready) {
|
|
34
34
|
opts.debounce = false;
|
|
35
35
|
}
|
|
36
|
+
// Don't debounce if the chart is inside a tile that is being dragged so the state is correct immediately when it is dropped
|
|
37
|
+
if (this.chart.findParent(Tile)?.$container.hasClass('dragged')) {
|
|
38
|
+
opts.debounce = false;
|
|
39
|
+
}
|
|
40
|
+
// Ensure chart has the correct size right after the layout.
|
|
41
|
+
if (this.chart.chartRenderer instanceof ChartJsRenderer) {
|
|
42
|
+
this.chart.chartRenderer.chartJs?.resize();
|
|
43
|
+
}
|
|
36
44
|
this.chart.updateChart(opts);
|
|
37
45
|
}
|
|
38
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010,
|
|
2
|
+
* Copyright (c) 2010, 2024 BSI Business Systems Integration AG
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -788,7 +788,9 @@ export class ChartTableControl extends TableControl implements ChartTableControl
|
|
|
788
788
|
let label,
|
|
789
789
|
keyX = xAxis[x];
|
|
790
790
|
if (xAxis.column instanceof NumberColumn) {
|
|
791
|
-
|
|
791
|
+
// the axis will format numbers as two digit decimals and null/undefined as the text '-empty-' or something similar
|
|
792
|
+
// only pass null/undefined to the axis as we want to leave the number format to the chart but need the '-empty-' string
|
|
793
|
+
label = objects.isNullOrUndefined(keyX) ? xAxis.format(keyX) : keyX;
|
|
792
794
|
} else {
|
|
793
795
|
label = this._handleIconLabel(xAxis.format(keyX), xAxis, iconClasses);
|
|
794
796
|
}
|