@eclipse-scout/chart 24.1.6 → 24.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-scout/chart",
3
- "version": "24.1.6",
3
+ "version": "24.1.12",
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.1.6",
29
+ "@eclipse-scout/cli": "24.1.12",
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.1.6",
39
+ "@eclipse-scout/core": "24.1.12",
40
40
  "jquery": "3.7.1",
41
41
  "chart.js": "4.4.0",
42
42
  "chartjs-plugin-datalabels": "2.2.0"
@@ -10,7 +10,7 @@
10
10
  import {AbstractChartRenderer, ChartEventMap, ChartJsRenderer, ChartLayout, ChartModel, FulfillmentChartRenderer, SalesfunnelChartRenderer, SpeedoChartRenderer, VennChartRenderer} from '../index';
11
11
  import {aria, arrays, ColorScheme, colorSchemes, EnumObject, HtmlComponent, InitModelOf, objects, Widget} from '@eclipse-scout/core';
12
12
  import {GreenAreaPosition} from './SpeedoChartRenderer';
13
- import {ChartConfiguration, LinearScaleOptions, RadialLinearScaleOptions} from 'chart.js';
13
+ import {CategoryScaleOptions, ChartConfiguration, ChartOptions, LinearScaleOptions, LogarithmicScaleOptions, RadialLinearScaleOptions, ScaleType, TimeScaleOptions as ChartJsTimeScaleOptions} from 'chart.js';
14
14
  import $ from 'jquery';
15
15
 
16
16
  export class Chart extends Widget implements ChartModel {
@@ -414,60 +414,72 @@ export type ChartValueGroup = {
414
414
  cssClass?: string;
415
415
  };
416
416
 
417
- export type ChartConfig = Partial<Omit<ChartConfiguration, 'type'>> & {
417
+ export type ChartConfig = Partial<Omit<ChartConfiguration, 'type' | 'options'>> & {
418
418
  type: ChartType;
419
- options?: {
420
- autoColor?: boolean;
421
- colorScheme?: ColorScheme | string;
422
- transparent?: boolean;
423
- maxSegments?: number;
424
- otherSegmentClickable?: boolean;
425
- adjustGridMaxMin?: boolean;
426
- clickable?: boolean;
427
- checkable?: boolean;
428
- scaleLabelByTypeMap?: Record<ChartType, Record<string, string>>;
429
- numberFormatter?: NumberFormatter;
430
- reformatLabels?: boolean;
431
- handleResize?: boolean;
432
- animation?: {
433
- duration?: number;
434
- };
435
- scales?: {
436
- x?: LinearScaleOptions & {
437
- minSpaceBetweenTicks?: number;
438
- };
439
- y?: LinearScaleOptions & {
440
- minSpaceBetweenTicks?: number;
441
- };
442
- yDiffType?: LinearScaleOptions;
443
- r?: RadialLinearScaleOptions & {
444
- minSpaceBetweenTicks?: number;
445
- };
446
- };
447
- bubble?: {
448
- sizeOfLargestBubble?: number;
449
- minBubbleSize?: number;
450
- };
451
- fulfillment?: {
452
- startValue?: number;
453
- };
454
- salesfunnel?: {
455
- normalized?: boolean;
456
- calcConversionRate?: boolean;
457
- };
458
- speedo?: {
459
- greenAreaPosition?: GreenAreaPosition;
460
- };
461
- venn?: {
462
- numberOfCircles?: 1 | 2 | 3;
463
- };
464
- plugins?: {
465
- legend?: {
466
- clickable?: boolean;
467
- };
419
+ options?: ChartConfigOptions;
420
+ };
421
+
422
+ export type ChartConfigOptions = Omit<ChartOptions, 'scales'> & {
423
+ autoColor?: boolean;
424
+ colorScheme?: ColorScheme | string;
425
+ transparent?: boolean;
426
+ maxSegments?: number;
427
+ otherSegmentClickable?: boolean;
428
+ adjustGridMaxMin?: boolean;
429
+ clickable?: boolean;
430
+ checkable?: boolean;
431
+ scaleLabelByTypeMap?: Record<ChartType, Record<string, string>>;
432
+ numberFormatter?: NumberFormatter;
433
+ reformatLabels?: boolean;
434
+ handleResize?: boolean;
435
+ animation?: {
436
+ duration?: number;
437
+ };
438
+ scales?: {
439
+ x?: CartesianChartScale;
440
+ y?: CartesianChartScale;
441
+ yDiffType?: CartesianChartScale;
442
+ r?: RadialChartScale;
443
+ };
444
+ bubble?: {
445
+ sizeOfLargestBubble?: number;
446
+ minBubbleSize?: number;
447
+ };
448
+ fulfillment?: {
449
+ startValue?: number;
450
+ };
451
+ salesfunnel?: {
452
+ normalized?: boolean;
453
+ calcConversionRate?: boolean;
454
+ };
455
+ speedo?: {
456
+ greenAreaPosition?: GreenAreaPosition;
457
+ };
458
+ venn?: {
459
+ numberOfCircles?: 1 | 2 | 3;
460
+ };
461
+ plugins?: {
462
+ legend?: {
463
+ clickable?: boolean;
468
464
  };
469
465
  };
470
466
  };
467
+
468
+ export type RadialChartScale = DeepPartial<RadialLinearScaleOptions> & {
469
+ type?: ScaleType;
470
+ minSpaceBetweenTicks?: number;
471
+ };
472
+
473
+ export type CartesianChartScale = DeepPartial<LinearScaleOptions | CategoryScaleOptions | TimeScaleOptions | LogarithmicScaleOptions> & {
474
+ type?: ScaleType;
475
+ minSpaceBetweenTicks?: number;
476
+ };
477
+
478
+ export type TimeScaleOptions = Omit<ChartJsTimeScaleOptions, 'min' | 'max'> & {
479
+ min?: string | number | Date | (() => string | number | Date);
480
+ max?: string | number | Date | (() => string | number | Date);
481
+ };
482
+
471
483
  export type ChartType = EnumObject<typeof Chart.Type>;
472
484
  export type ChartPosition = EnumObject<typeof Chart.Position>;
473
485
  export type NumberFormatter = (label: number | string, defaultFormatter: (label: number | string) => string) => string;
@@ -498,3 +510,7 @@ export type UpdateChartOptions = {
498
510
  onlyRefresh?: boolean;
499
511
  enforceRerender?: boolean;
500
512
  };
513
+
514
+ type DeepPartial<T> = T extends object ? {
515
+ [P in keyof T]?: DeepPartial<T[P]>;
516
+ } : T;
@@ -7,10 +7,11 @@
7
7
  *
8
8
  * SPDX-License-Identifier: EPL-2.0
9
9
  */
10
- import {AbstractChartRenderer, Chart, chartJsDateAdapter} from '../index';
10
+ import {AbstractChartRenderer, CartesianChartScale, Chart, chartJsDateAdapter, RadialChartScale} from '../index';
11
11
  import {
12
12
  _adapters as chartJsAdapters, ActiveElement, ArcElement, BarElement, BubbleDataPoint, CartesianScaleOptions, Chart as ChartJs, ChartArea, ChartConfiguration, ChartDataset, ChartEvent, ChartType as ChartJsType, Color, DefaultDataPoint,
13
- FontSpec, LegendElement, LegendItem, LegendOptions, LinearScaleOptions, PointElement, PointHoverOptions, RadialLinearScaleOptions, Scale, ScatterDataPoint, TooltipCallbacks, TooltipItem, TooltipLabelStyle, TooltipModel, TooltipOptions
13
+ FontSpec, LegendElement, LegendItem, LegendOptions, LinearScaleOptions, PointElement, PointHoverOptions, RadialLinearScaleOptions, Scale, ScatterDataPoint, Scriptable, ScriptableContext, TooltipCallbacks, TooltipItem, TooltipLabelStyle,
14
+ TooltipModel, TooltipOptions
14
15
  } from 'chart.js';
15
16
  import 'chart.js/auto'; // Import from auto to register charts
16
17
  import {aria, arrays, colorSchemes, graphics, numbers, objects, Point, scout, strings, styles, Tooltip, tooltips} from '@eclipse-scout/core';
@@ -2802,7 +2803,7 @@ export class ChartJsRenderer extends AbstractChartRenderer {
2802
2803
  });
2803
2804
  }
2804
2805
 
2805
- protected _adjustAxisMaxMin(axis: LinearScaleOptions | RadialLinearScaleOptions, maxTicks: number, maxMinValue: Boundary) {
2806
+ protected _adjustAxisMaxMin(axis: AxisWithMaxMin, maxTicks: number, maxMinValue: Boundary) {
2806
2807
  if (!axis) {
2807
2808
  return;
2808
2809
  }
@@ -2865,6 +2866,12 @@ export type DatasetColors = {
2865
2866
 
2866
2867
  export type Boundary = { maxValue: number; minValue: number };
2867
2868
 
2869
+ export type AxisWithMaxMin = (CartesianChartScale | RadialChartScale) & {
2870
+ ticks?: (CartesianChartScale | RadialChartScale)['ticks'] & {
2871
+ stepSize?: number;
2872
+ };
2873
+ };
2874
+
2868
2875
  // extend chart.js
2869
2876
 
2870
2877
  export type ChartJsChart = Omit<ChartJs, 'config'> & {
@@ -2881,10 +2888,10 @@ declare module 'chart.js' {
2881
2888
  datasetId?: string;
2882
2889
  yAxisID?: 'y' | 'yDiffType';
2883
2890
 
2884
- pointBackgroundColor?: Color;
2885
- pointHoverBackgroundColor?: Color;
2886
- pointRadius?: number;
2887
- legendColor?: Color;
2891
+ pointBackgroundColor?: Scriptable<Color, ScriptableContext<TType>>;
2892
+ pointHoverBackgroundColor?: Scriptable<Color, ScriptableContext<TType>>;
2893
+ pointRadius?: Scriptable<number, ScriptableContext<TType>>;
2894
+ legendColor?: Scriptable<Color, number>;
2888
2895
 
2889
2896
  checkedBackgroundColor?: Color;
2890
2897
  checkedHoverBackgroundColor?: Color;