@refinitiv-ui/elements 7.0.0-next.2 → 7.0.0-next.4

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.
@@ -112,6 +112,13 @@ export declare class Chart extends BasicElement {
112
112
  * @returns {void}
113
113
  */
114
114
  protected decorateColors: (chart: ChartJS) => void;
115
+ /**
116
+ * Generates the legend labels specify on Arc chart (Pie and Doughnut).
117
+ * @param legends Array of legend labels
118
+ * @param chart Chart.js instance
119
+ * @returns Array of label configurations
120
+ */
121
+ private generateArcLegendLabels;
115
122
  /**
116
123
  * Generates the legend labels on a given chart
117
124
  * @param chart Chart.js instance
@@ -115,6 +115,28 @@ let Chart = class Chart extends BasicElement {
115
115
  }
116
116
  });
117
117
  };
118
+ /**
119
+ * Generates the legend labels specify on Arc chart (Pie and Doughnut).
120
+ * @param legends Array of legend labels
121
+ * @param chart Chart.js instance
122
+ * @returns Array of label configurations
123
+ */
124
+ this.generateArcLegendLabels = (legends, chart) => {
125
+ const chartType = chart.config.type;
126
+ if (chartType === 'pie' && ChartJS.overrides.pie.plugins.legend.labels.generateLabels) {
127
+ legends = ChartJS.overrides.pie.plugins.legend.labels.generateLabels(chart);
128
+ }
129
+ if (chartType === 'doughnut' && ChartJS.overrides.doughnut.plugins.legend.labels.generateLabels) {
130
+ legends = ChartJS.overrides.doughnut.plugins.legend.labels.generateLabels(chart);
131
+ }
132
+ // Customize for doughnut chart change border color to background color
133
+ if (this.datasets.length > 1) {
134
+ legends.forEach((label) => {
135
+ label.strokeStyle = label.fillStyle;
136
+ });
137
+ }
138
+ return legends;
139
+ };
118
140
  /**
119
141
  * Generates the legend labels on a given chart
120
142
  * @param chart Chart.js instance
@@ -129,17 +151,9 @@ let Chart = class Chart extends BasicElement {
129
151
  const datasets = chart.config.data.datasets;
130
152
  if (datasets.length
131
153
  && chart?.config?.options?.plugins?.legend
132
- && Array.isArray(datasets[0].backgroundColor)) {
133
- if (ChartJS.overrides.pie.plugins.legend.labels.generateLabels) {
134
- legends = ChartJS.overrides.pie.plugins.legend.labels.generateLabels(chart);
135
- }
136
- // Customize for doughnut chart change border color to background color
137
- if (['pie', 'doughnut'].includes(chartType) && this.datasets.length > 1) {
138
- legends.forEach((label) => {
139
- label.strokeStyle = label.fillStyle;
140
- });
141
- }
142
- return legends;
154
+ && Array.isArray(datasets[0].backgroundColor)
155
+ && ['pie', 'doughnut'].includes(chartType)) {
156
+ return this.generateArcLegendLabels(legends, chart);
143
157
  }
144
158
  if (ChartJS.defaults.plugins.legend.labels.generateLabels) {
145
159
  legends = ChartJS.defaults.plugins.legend.labels.generateLabels(chart);
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line import/extensions
2
- import { Chart } from 'chart.js/auto/auto.js';
2
+ import { Chart } from 'chart.js/auto';
3
3
  import { doughnutCenterLabelPlugin } from './plugins/index.js';
4
4
  Chart.register(doughnutCenterLabelPlugin);
5
5
  export * from './elements/chart.js';
@@ -1,6 +1,6 @@
1
1
  import { Chart as ChartJS } from 'chart.js';
2
2
  // eslint-disable-next-line import/extensions
3
- import { getHoverColor } from 'chart.js/helpers/helpers.js';
3
+ import { getHoverColor } from 'chart.js/helpers';
4
4
  const getPluginConfig = (chart) => {
5
5
  return chart.config.options?.plugins?.centerLabel;
6
6
  };
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '7.0.0-next.2';
1
+ export const VERSION = '7.0.0-next.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refinitiv-ui/elements",
3
- "version": "7.0.0-next.2",
3
+ "version": "7.0.0-next.4",
4
4
  "description": "Element Framework Elements",
5
5
  "author": "LSEG",
6
6
  "license": "Apache-2.0",
@@ -339,8 +339,8 @@
339
339
  },
340
340
  "dependencies": {
341
341
  "@refinitiv-ui/browser-sparkline": "1.1.8",
342
- "@refinitiv-ui/halo-theme": "^7.0.0-next.1",
343
- "@refinitiv-ui/solar-theme": "^7.0.0-next.1",
342
+ "@refinitiv-ui/halo-theme": "^7.0.0-next.2",
343
+ "@refinitiv-ui/solar-theme": "^7.0.0-next.2",
344
344
  "chart.js": "^4.3.0",
345
345
  "chartjs-adapter-date-fns": "^3.0.0",
346
346
  "d3-interpolate": "^3.0.1",
@@ -350,11 +350,11 @@
350
350
  },
351
351
  "devDependencies": {
352
352
  "@refinitiv-ui/core": "^7.0.0-next.1",
353
- "@refinitiv-ui/demo-block": "^7.0.0-next.1",
353
+ "@refinitiv-ui/demo-block": "^7.0.0-next.2",
354
354
  "@refinitiv-ui/i18n": "^7.0.0-next.1",
355
355
  "@refinitiv-ui/phrasebook": "^7.0.0-next.1",
356
356
  "@refinitiv-ui/test-helpers": "^7.0.0-next.1",
357
- "@refinitiv-ui/translate": "^7.0.0-next.1",
357
+ "@refinitiv-ui/translate": "^7.0.0-next.2",
358
358
  "@refinitiv-ui/utils": "^7.0.0-next.1",
359
359
  "@types/d3-interpolate": "^3.0.1"
360
360
  },
@@ -362,11 +362,11 @@
362
362
  "@refinitiv-ui/core": "^7.0.0-next.1",
363
363
  "@refinitiv-ui/i18n": "^7.0.0-next.1",
364
364
  "@refinitiv-ui/phrasebook": "^7.0.0-next.1",
365
- "@refinitiv-ui/translate": "^7.0.0-next.1",
365
+ "@refinitiv-ui/translate": "^7.0.0-next.2",
366
366
  "@refinitiv-ui/utils": "^7.0.0-next.1"
367
367
  },
368
368
  "publishConfig": {
369
369
  "access": "public"
370
370
  },
371
- "gitHead": "11137410c8e0476d79cfa12450c066a425d91770"
371
+ "gitHead": "02dbb152a8c6e4801ef6f5a7f1892eb01a0564f5"
372
372
  }