@oliasoft-open-source/charts-library 3.4.6 → 3.4.7
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/declaration.d.ts +2 -0
- package/dist/index.js +658 -611
- package/dist/index.js.map +1 -1
- package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +30 -26
- package/dist/src/components/bar-chart/bar-chart.interface.d.ts +37 -70
- package/dist/src/components/bar-chart/get-bar-chart-data-labels.d.ts +11 -14
- package/dist/src/components/bar-chart/get-bar-chart-scales.d.ts +3 -2
- package/dist/src/components/bar-chart/get-bar-chart-tooltips.d.ts +3 -16
- package/dist/src/components/common/common.interface.d.ts +139 -0
- package/dist/src/components/common/helpers/chart-border-plugin.d.ts +8 -0
- package/dist/src/{helpers → components/common/helpers}/enums.d.ts +2 -1
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +27 -0
- package/dist/src/components/common/helpers/get-draggableData.d.ts +18 -0
- package/dist/src/{helpers → components/common/helpers}/range/range.d.ts +6 -6
- package/dist/src/components/line-chart/controls/axes-options/axes-options-form-state.d.ts +8 -3
- package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +52 -0
- package/dist/src/components/{controls → line-chart/controls}/axes-options/axes-options.d.ts +1 -1
- package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +18 -32
- package/dist/src/components/line-chart/controls/controls-portal.d.ts +6 -1
- package/dist/src/components/line-chart/controls/controls.d.ts +1 -1
- package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +5 -5
- package/dist/src/components/line-chart/controls/line-options.d.ts +9 -1
- package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +28 -6
- package/dist/src/components/line-chart/{state → hooks}/use-chart-state.d.ts +13 -1
- package/dist/src/components/line-chart/hooks/use-toggle-handler.d.ts +2 -1
- package/dist/src/components/line-chart/initialize/config.d.ts +2 -2
- package/dist/src/components/line-chart/legend/legend-interface.d.ts +24 -18
- package/dist/src/components/line-chart/legend/legend-panel.d.ts +2 -2
- package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +38 -30
- package/dist/src/components/line-chart/line-chart.interface.d.ts +48 -61
- package/dist/src/components/line-chart/plugins/chart-area-text-plugin.d.ts +14 -1
- package/dist/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.d.ts +5 -4
- package/dist/src/components/line-chart/plugins/plugins.interface.d.ts +2 -2
- package/dist/src/components/line-chart/state/initial-state.d.ts +20 -2
- package/dist/src/components/line-chart/state/line-chart-reducer.d.ts +2 -1
- package/dist/src/components/line-chart/state/manage-state-in-local-storage.d.ts +3 -2
- package/dist/src/components/line-chart/state/state.interfaces.d.ts +32 -7
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +1 -1
- package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +3 -1
- package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +9 -2
- package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +3 -2
- package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +4 -4
- package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +2 -2
- package/dist/src/components/line-chart/utils/translations/get-translations.d.ts +2 -1
- package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +12 -8
- package/dist/src/components/pie-chart/pie-chart.d.ts +1 -2
- package/dist/src/components/pie-chart/pie-chart.interface.d.ts +52 -51
- package/dist/src/components/scatter-chart/scatter-chart.d.ts +1 -1
- package/dist/src/components/scatter-chart/scatter-chart.intefrace.d.ts +6 -16
- package/package.json +1 -1
- package/dist/src/components/controls/axes-options/axes-options-interfaces.d.ts +0 -19
- package/dist/src/components/line-chart/hooks/hooks.interface.d.ts +0 -13
- package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +0 -37
- package/dist/src/components/pie-chart/pie-chart-utils.d.ts +0 -2
- package/dist/src/helpers/chart-border-plugin.d.ts +0 -7
- package/dist/src/helpers/chart-interface.d.ts +0 -85
- package/dist/src/helpers/get-chart-annotation.d.ts +0 -12
- package/dist/src/helpers/get-draggableData.d.ts +0 -18
- /package/dist/src/{helpers → components/common/helpers}/chart-consts.d.ts +0 -0
- /package/dist/src/{helpers → components/common/helpers}/range/estimate-data-series-have-close-values.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -576,7 +576,7 @@ let Color$1 = class Color {
|
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
578
|
/*!
|
|
579
|
-
* Chart.js v4.3.
|
|
579
|
+
* Chart.js v4.3.2
|
|
580
580
|
* https://www.chartjs.org
|
|
581
581
|
* (c) 2023 Chart.js Contributors
|
|
582
582
|
* Released under the MIT License
|
|
@@ -1048,7 +1048,7 @@ function _getStartAndCountOfVisiblePoints$1(meta, points, animationsDisabled) {
|
|
|
1048
1048
|
if (minDefined) {
|
|
1049
1049
|
start = _limitValue$1(Math.min(
|
|
1050
1050
|
// @ts-expect-error Need to type _parsed
|
|
1051
|
-
_lookupByKey$1(_parsed,
|
|
1051
|
+
_lookupByKey$1(_parsed, axis, min).lo,
|
|
1052
1052
|
// @ts-expect-error Need to fix types on _lookupByKey
|
|
1053
1053
|
animationsDisabled ? pointCount : _lookupByKey$1(points, axis, iScale.getPixelForValue(min)).lo
|
|
1054
1054
|
), 0, pointCount - 1);
|
|
@@ -1170,7 +1170,7 @@ const numbers$1 = [
|
|
|
1170
1170
|
"radius",
|
|
1171
1171
|
"tension"
|
|
1172
1172
|
];
|
|
1173
|
-
const colors$
|
|
1173
|
+
const colors$1 = [
|
|
1174
1174
|
"color",
|
|
1175
1175
|
"borderColor",
|
|
1176
1176
|
"backgroundColor"
|
|
@@ -1194,7 +1194,7 @@ function applyAnimationsDefaults(defaults2) {
|
|
|
1194
1194
|
defaults2.set("animations", {
|
|
1195
1195
|
colors: {
|
|
1196
1196
|
type: "color",
|
|
1197
|
-
properties: colors$
|
|
1197
|
+
properties: colors$1
|
|
1198
1198
|
},
|
|
1199
1199
|
numbers: {
|
|
1200
1200
|
type: "number",
|
|
@@ -2891,7 +2891,7 @@ function styleChanged$1(style, prevStyle) {
|
|
|
2891
2891
|
return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
|
|
2892
2892
|
}
|
|
2893
2893
|
/*!
|
|
2894
|
-
* Chart.js v4.3.
|
|
2894
|
+
* Chart.js v4.3.2
|
|
2895
2895
|
* https://www.chartjs.org
|
|
2896
2896
|
* (c) 2023 Chart.js Contributors
|
|
2897
2897
|
* Released under the MIT License
|
|
@@ -4825,7 +4825,7 @@ let LineController$1 = (_d = class extends DatasetController$1 {
|
|
|
4825
4825
|
line._chart = this.chart;
|
|
4826
4826
|
line._datasetIndex = this.index;
|
|
4827
4827
|
line._decimated = !!_dataset._decimated;
|
|
4828
|
-
line.points = points;
|
|
4828
|
+
line.points = points.slice(Math.max(this._drawStart - 1, 0), this._drawStart + this._drawCount);
|
|
4829
4829
|
const options = this.resolveDatasetElementOptions(mode);
|
|
4830
4830
|
if (!this.options.showLine) {
|
|
4831
4831
|
options.borderWidth = 0;
|
|
@@ -4939,6 +4939,9 @@ let ScatterController$1 = (_f = class extends DatasetController$1 {
|
|
|
4939
4939
|
count = points.length;
|
|
4940
4940
|
}
|
|
4941
4941
|
if (this.options.showLine) {
|
|
4942
|
+
if (!this.datasetElementType) {
|
|
4943
|
+
this.addElements();
|
|
4944
|
+
}
|
|
4942
4945
|
const { dataset: line, _dataset } = meta;
|
|
4943
4946
|
line._chart = this.chart;
|
|
4944
4947
|
line._datasetIndex = this.index;
|
|
@@ -4950,6 +4953,9 @@ let ScatterController$1 = (_f = class extends DatasetController$1 {
|
|
|
4950
4953
|
animated: !animationsDisabled,
|
|
4951
4954
|
options
|
|
4952
4955
|
}, mode);
|
|
4956
|
+
} else if (this.datasetElementType) {
|
|
4957
|
+
delete meta.dataset;
|
|
4958
|
+
this.datasetElementType = false;
|
|
4953
4959
|
}
|
|
4954
4960
|
this.updateElements(points, start, count, mode);
|
|
4955
4961
|
}
|
|
@@ -7956,7 +7962,7 @@ function needContext$1(proxy, names2) {
|
|
|
7956
7962
|
}
|
|
7957
7963
|
return false;
|
|
7958
7964
|
}
|
|
7959
|
-
var version$3 = "4.3.
|
|
7965
|
+
var version$3 = "4.3.2";
|
|
7960
7966
|
const KNOWN_POSITIONS$1 = [
|
|
7961
7967
|
"top",
|
|
7962
7968
|
"bottom",
|
|
@@ -10563,7 +10569,7 @@ let Legend$1 = class Legend extends Element$2 {
|
|
|
10563
10569
|
cursor.x += width + padding;
|
|
10564
10570
|
} else if (typeof legendItem2.text !== "string") {
|
|
10565
10571
|
const fontLineHeight = labelFont.lineHeight;
|
|
10566
|
-
cursor.y += calculateLegendItemHeight(legendItem2, fontLineHeight);
|
|
10572
|
+
cursor.y += calculateLegendItemHeight(legendItem2, fontLineHeight) + padding;
|
|
10567
10573
|
} else {
|
|
10568
10574
|
cursor.y += lineHeight;
|
|
10569
10575
|
}
|
|
@@ -10677,7 +10683,7 @@ function calculateItemHeight(_itemHeight, legendItem2, fontLineHeight) {
|
|
|
10677
10683
|
return itemHeight;
|
|
10678
10684
|
}
|
|
10679
10685
|
function calculateLegendItemHeight(legendItem2, fontLineHeight) {
|
|
10680
|
-
const labelHeight = legendItem2.text ? legendItem2.text.length
|
|
10686
|
+
const labelHeight = legendItem2.text ? legendItem2.text.length : 0;
|
|
10681
10687
|
return fontLineHeight * labelHeight;
|
|
10682
10688
|
}
|
|
10683
10689
|
function isListened(type, opts) {
|
|
@@ -12724,7 +12730,7 @@ let TimeScale$1 = (_q = class extends Scale$1 {
|
|
|
12724
12730
|
if (time === max || options.bounds === "ticks" || count === 1) {
|
|
12725
12731
|
addTick$1(ticks, time, timestamps);
|
|
12726
12732
|
}
|
|
12727
|
-
return Object.keys(ticks).sort(
|
|
12733
|
+
return Object.keys(ticks).sort(sorter$1).map((x2) => +x2);
|
|
12728
12734
|
}
|
|
12729
12735
|
getLabelForValue(value) {
|
|
12730
12736
|
const adapter = this._adapter;
|
|
@@ -12922,6 +12928,18 @@ let TimeSeriesScale$1 = (_r = class extends TimeScale$1 {
|
|
|
12922
12928
|
}
|
|
12923
12929
|
return table2;
|
|
12924
12930
|
}
|
|
12931
|
+
_generate() {
|
|
12932
|
+
const min = this.min;
|
|
12933
|
+
const max = this.max;
|
|
12934
|
+
let timestamps = super.getDataTimestamps();
|
|
12935
|
+
if (!timestamps.includes(min) || !timestamps.length) {
|
|
12936
|
+
timestamps.splice(0, 0, min);
|
|
12937
|
+
}
|
|
12938
|
+
if (!timestamps.includes(max) || timestamps.length === 1) {
|
|
12939
|
+
timestamps.push(max);
|
|
12940
|
+
}
|
|
12941
|
+
return timestamps.sort((a2, b2) => a2 - b2);
|
|
12942
|
+
}
|
|
12925
12943
|
_getTimestampsForTable() {
|
|
12926
12944
|
let timestamps = this._cache.all || [];
|
|
12927
12945
|
if (timestamps.length) {
|
|
@@ -13086,12 +13104,15 @@ const Pie = /* @__PURE__ */ createTypedChart("pie", PieController$1);
|
|
|
13086
13104
|
const Scatter = /* @__PURE__ */ createTypedChart("scatter", ScatterController$1);
|
|
13087
13105
|
const MINOR_TICKS_PER_MAJOR = 10;
|
|
13088
13106
|
const getLargestMajorTickWidth = (majorTickPositions) => {
|
|
13089
|
-
return majorTickPositions.reduce(
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13107
|
+
return majorTickPositions.reduce(
|
|
13108
|
+
(acc, curr, index2) => {
|
|
13109
|
+
if (index2 === 0)
|
|
13110
|
+
return acc;
|
|
13111
|
+
const gap = Math.abs(curr - majorTickPositions[index2 - 1]);
|
|
13112
|
+
return Math.max(gap, acc);
|
|
13113
|
+
},
|
|
13114
|
+
0
|
|
13115
|
+
);
|
|
13095
13116
|
};
|
|
13096
13117
|
const isValidPosition = (minorTickPosition, majorTickPositions, scale) => {
|
|
13097
13118
|
const { axis, left: left2, top: top2, right: right2, bottom: bottom2 } = scale;
|
|
@@ -13119,16 +13140,18 @@ const getMinorTickPositions = (majorTickPositions, scale) => {
|
|
|
13119
13140
|
return positions2;
|
|
13120
13141
|
};
|
|
13121
13142
|
const drawMinorTicksForScale = (scale) => {
|
|
13143
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
13122
13144
|
const { chart: chart2, ctx } = scale;
|
|
13123
|
-
|
|
13145
|
+
const config2 = chart2.config;
|
|
13146
|
+
if (!((_d2 = (_c2 = (_b2 = (_a2 = config2 == null ? void 0 : config2.options) == null ? void 0 : _a2.scales) == null ? void 0 : _b2[scale.id]) == null ? void 0 : _c2.grid) == null ? void 0 : _d2.drawOnChartArea))
|
|
13124
13147
|
return;
|
|
13125
|
-
if (
|
|
13148
|
+
if (config2.options.indexAxis === scale.axis)
|
|
13126
13149
|
return;
|
|
13127
13150
|
const isHorizontal = scale.axis === "x";
|
|
13128
13151
|
const majorTickPositions = scale.ticks.map((_2, index2) => scale.getPixelForTick(index2)).sort((a2, b2) => a2 - b2);
|
|
13129
13152
|
const minorTickPositions = getMinorTickPositions(majorTickPositions, scale);
|
|
13130
13153
|
ctx.save();
|
|
13131
|
-
ctx.strokeStyle =
|
|
13154
|
+
ctx.strokeStyle = ((_i2 = (_h2 = (_g2 = (_f2 = (_e2 = config2 == null ? void 0 : config2._config) == null ? void 0 : _e2.options) == null ? void 0 : _f2.scales) == null ? void 0 : _g2[scale.id]) == null ? void 0 : _h2.grid) == null ? void 0 : _i2.color) || "rgba(0,0,0,0.06)";
|
|
13132
13155
|
ctx.lineWidth = 0.5;
|
|
13133
13156
|
minorTickPositions.forEach((minorTickPosition) => {
|
|
13134
13157
|
ctx.beginPath();
|
|
@@ -13267,6 +13290,7 @@ var PanZoomMode = /* @__PURE__ */ ((PanZoomMode2) => {
|
|
|
13267
13290
|
PanZoomMode2["X"] = "x";
|
|
13268
13291
|
PanZoomMode2["Y"] = "y";
|
|
13269
13292
|
PanZoomMode2["XY"] = "xy";
|
|
13293
|
+
PanZoomMode2["Z"] = "z";
|
|
13270
13294
|
return PanZoomMode2;
|
|
13271
13295
|
})(PanZoomMode || {});
|
|
13272
13296
|
var Key = /* @__PURE__ */ ((Key2) => {
|
|
@@ -13284,7 +13308,7 @@ var Events = /* @__PURE__ */ ((Events2) => {
|
|
|
13284
13308
|
})(Events || {});
|
|
13285
13309
|
const chartAreaBorderPlugin = {
|
|
13286
13310
|
id: "chartAreaBorder",
|
|
13287
|
-
beforeDraw(chart2,
|
|
13311
|
+
beforeDraw(chart2, _args, options) {
|
|
13288
13312
|
const {
|
|
13289
13313
|
ctx,
|
|
13290
13314
|
chartArea: { left: left2, top: top2, width, height }
|
|
@@ -13299,6 +13323,7 @@ const chartAreaBorderPlugin = {
|
|
|
13299
13323
|
}
|
|
13300
13324
|
};
|
|
13301
13325
|
const getPlugins = (graph, legend2) => {
|
|
13326
|
+
var _a2;
|
|
13302
13327
|
let plugins = [];
|
|
13303
13328
|
if (graph.showMinorGridlines) {
|
|
13304
13329
|
plugins.push(chartMinorGridlinesPlugin);
|
|
@@ -13307,25 +13332,25 @@ const getPlugins = (graph, legend2) => {
|
|
|
13307
13332
|
if ((customLegend == null ? void 0 : customLegend.customLegendPlugin) && (customLegend == null ? void 0 : customLegend.customLegendContainerID)) {
|
|
13308
13333
|
plugins.push({
|
|
13309
13334
|
id: CUSTOM_LEGEND_PLUGIN_NAME,
|
|
13310
|
-
...legend2.customLegend.customLegendPlugin
|
|
13335
|
+
...(_a2 = legend2 == null ? void 0 : legend2.customLegend) == null ? void 0 : _a2.customLegendPlugin
|
|
13311
13336
|
});
|
|
13312
13337
|
}
|
|
13313
13338
|
plugins.push(chartAreaBorderPlugin);
|
|
13314
13339
|
return plugins;
|
|
13315
13340
|
};
|
|
13316
|
-
const generateRandomColor
|
|
13341
|
+
const generateRandomColor = (colors2) => {
|
|
13317
13342
|
const color2 = `#${Math.floor(Math.random() * WHITE_COLOR_AS_DECIMAL).toString(
|
|
13318
13343
|
16
|
|
13319
13344
|
)}`;
|
|
13320
13345
|
if (colors2.includes(color2)) {
|
|
13321
|
-
return generateRandomColor
|
|
13346
|
+
return generateRandomColor(colors2);
|
|
13322
13347
|
} else {
|
|
13323
13348
|
colors2.push(color2);
|
|
13324
|
-
return
|
|
13349
|
+
return colors2;
|
|
13325
13350
|
}
|
|
13326
13351
|
};
|
|
13327
13352
|
const setAnnotations = (annotationsData) => {
|
|
13328
|
-
return (annotationsData == null ? void 0 : annotationsData.length) ? annotationsData.map((
|
|
13353
|
+
return (annotationsData == null ? void 0 : annotationsData.length) ? annotationsData.map((_v, i2) => i2) : [];
|
|
13329
13354
|
};
|
|
13330
13355
|
const getTitle = (options) => {
|
|
13331
13356
|
return options.title !== "" ? {
|
|
@@ -13351,16 +13376,16 @@ const getClassName = (chartStyling, styles2) => {
|
|
|
13351
13376
|
}
|
|
13352
13377
|
return cx(styles2.chart, heightStyles, squareAspectRatioStyle);
|
|
13353
13378
|
};
|
|
13354
|
-
const getLegend = (options, clickHandler
|
|
13355
|
-
const { legend: legend2 } = options;
|
|
13379
|
+
const getLegend = (options, clickHandler) => {
|
|
13380
|
+
const { legend: legend2 } = options || {};
|
|
13356
13381
|
return {
|
|
13357
|
-
position: legend2.position || Position.Top,
|
|
13358
|
-
display: legend2.display,
|
|
13359
|
-
align: legend2.align,
|
|
13382
|
+
position: (legend2 == null ? void 0 : legend2.position) || Position.Top,
|
|
13383
|
+
display: legend2 == null ? void 0 : legend2.display,
|
|
13384
|
+
align: legend2 == null ? void 0 : legend2.align,
|
|
13360
13385
|
labels: {
|
|
13361
13386
|
boxHeight: LEGEND_LABEL_BOX_SIZE,
|
|
13362
|
-
boxWidth: legend2.usePointStyle ? LEGEND_LABEL_BOX_SIZE : void 0,
|
|
13363
|
-
usePointStyle: legend2.usePointStyle
|
|
13387
|
+
boxWidth: (legend2 == null ? void 0 : legend2.usePointStyle) ? LEGEND_LABEL_BOX_SIZE : void 0,
|
|
13388
|
+
usePointStyle: legend2 == null ? void 0 : legend2.usePointStyle
|
|
13364
13389
|
},
|
|
13365
13390
|
onClick: clickHandler
|
|
13366
13391
|
};
|
|
@@ -13381,7 +13406,7 @@ const getChartFileName = (axes) => {
|
|
|
13381
13406
|
}
|
|
13382
13407
|
const axesLabels = axes.reduce((acc, cur, index2) => {
|
|
13383
13408
|
var _a2;
|
|
13384
|
-
const labelWithNoSpace = ((_a2 = cur.label) == null ? void 0 : _a2.replace(/\s/g, "_")) || index2;
|
|
13409
|
+
const labelWithNoSpace = ((_a2 = cur.label) == null ? void 0 : _a2.replace(/\s/g, "_")) || String(index2);
|
|
13385
13410
|
return [...acc, labelWithNoSpace];
|
|
13386
13411
|
}, []);
|
|
13387
13412
|
return axesLabels.join("_");
|
|
@@ -13398,7 +13423,7 @@ const styles$5 = {
|
|
|
13398
13423
|
};
|
|
13399
13424
|
const ScatterChart = (props) => {
|
|
13400
13425
|
setDefaultTheme();
|
|
13401
|
-
const { data, options, testId = null } = props.chart;
|
|
13426
|
+
const { data = { datasets: [] }, options, testId = null } = props.chart;
|
|
13402
13427
|
return /* @__PURE__ */ jsx("div", { className: styles$5.chart, children: /* @__PURE__ */ jsx(Scatter, { options, data, "data-testid": testId }) });
|
|
13403
13428
|
};
|
|
13404
13429
|
function getDefaultExportFromCjs(x2) {
|
|
@@ -22073,6 +22098,7 @@ const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
|
|
|
22073
22098
|
const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
|
|
22074
22099
|
const reducer$1 = (state, action) => {
|
|
22075
22100
|
return produce(state, (draft) => {
|
|
22101
|
+
var _a2;
|
|
22076
22102
|
switch (action.type) {
|
|
22077
22103
|
case TOGGLE_ZOOM: {
|
|
22078
22104
|
draft.zoomEnabled = !draft.zoomEnabled;
|
|
@@ -22130,11 +22156,11 @@ const reducer$1 = (state, action) => {
|
|
|
22130
22156
|
}
|
|
22131
22157
|
case TOGGLE_ANNOTATION: {
|
|
22132
22158
|
const { annotationIndex } = action.payload;
|
|
22133
|
-
const updatedIndexes = draft.showAnnotationLineIndex.includes(
|
|
22159
|
+
const updatedIndexes = ((_a2 = draft == null ? void 0 : draft.showAnnotationLineIndex) == null ? void 0 : _a2.includes(
|
|
22134
22160
|
annotationIndex
|
|
22135
|
-
) ? draft.showAnnotationLineIndex.filter(
|
|
22161
|
+
)) ? draft.showAnnotationLineIndex.filter(
|
|
22136
22162
|
(v2) => v2 !== annotationIndex
|
|
22137
|
-
) : [...draft.showAnnotationLineIndex, annotationIndex];
|
|
22163
|
+
) : [...(draft == null ? void 0 : draft.showAnnotationLineIndex) ?? [], annotationIndex];
|
|
22138
22164
|
draft.showAnnotationLineIndex = updatedIndexes;
|
|
22139
22165
|
break;
|
|
22140
22166
|
}
|
|
@@ -22171,7 +22197,7 @@ const generateAxisId = (axisType, index2 = 0, hasMultiAxes = false) => {
|
|
|
22171
22197
|
};
|
|
22172
22198
|
const getAxisTypeFromKey = (string) => {
|
|
22173
22199
|
var _a2;
|
|
22174
|
-
return ((_a2 = string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0])
|
|
22200
|
+
return ((_a2 = string == null ? void 0 : string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0]) ?? "";
|
|
22175
22201
|
};
|
|
22176
22202
|
const generateKey = (values) => {
|
|
22177
22203
|
const key = values.join("");
|
|
@@ -22194,7 +22220,7 @@ const removeExpiredChartStates = (maxAgeInHours = 72) => {
|
|
|
22194
22220
|
const maxAgeInMilliseconds = maxAgeInHours * 60 * 60 * 1e3;
|
|
22195
22221
|
for (let i2 = 0; i2 < localStorage.length; i2++) {
|
|
22196
22222
|
const key = localStorage.key(i2);
|
|
22197
|
-
if (key.includes("line-chart-state-")) {
|
|
22223
|
+
if (key == null ? void 0 : key.includes("line-chart-state-")) {
|
|
22198
22224
|
const chartStateObjectJSON = localStorage.getItem(key);
|
|
22199
22225
|
if (chartStateObjectJSON) {
|
|
22200
22226
|
const chartStateObject = JSON.parse(chartStateObjectJSON);
|
|
@@ -22223,38 +22249,40 @@ const storeChartStateInStorage = (state, persistenceId) => {
|
|
|
22223
22249
|
};
|
|
22224
22250
|
const initialState = ({ options, persistenceId }) => {
|
|
22225
22251
|
const {
|
|
22226
|
-
additionalAxesOptions: { range: customAxesRange },
|
|
22227
|
-
annotations: { annotationsData },
|
|
22252
|
+
additionalAxesOptions: { range: customAxesRange = {} },
|
|
22253
|
+
annotations: { annotationsData = [] },
|
|
22228
22254
|
axes,
|
|
22229
22255
|
chartOptions: { enableZoom, enablePan, showPoints, showLine },
|
|
22230
22256
|
legend: { display },
|
|
22231
22257
|
dragData
|
|
22232
22258
|
} = options;
|
|
22233
22259
|
const getStateAxesByType = (axisType, customAxesRange2) => {
|
|
22234
|
-
var _a2, _b2, _c2;
|
|
22260
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
22235
22261
|
if (!axes[axisType]) {
|
|
22236
22262
|
return [];
|
|
22237
22263
|
}
|
|
22238
22264
|
if (((_a2 = axes[axisType]) == null ? void 0 : _a2.length) > 1) {
|
|
22239
|
-
return axes[axisType].map(
|
|
22240
|
-
|
|
22241
|
-
|
|
22242
|
-
|
|
22243
|
-
|
|
22244
|
-
|
|
22245
|
-
|
|
22246
|
-
|
|
22247
|
-
|
|
22248
|
-
|
|
22249
|
-
|
|
22250
|
-
|
|
22251
|
-
|
|
22252
|
-
|
|
22265
|
+
return axes[axisType].map(
|
|
22266
|
+
(axisObj, index2) => {
|
|
22267
|
+
var _a3, _b3;
|
|
22268
|
+
const id = generateAxisId(axisType, index2, axes[axisType].length > 1);
|
|
22269
|
+
const customMin = (_a3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _a3.min;
|
|
22270
|
+
const customMax = (_b3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b3.max;
|
|
22271
|
+
const { unit } = axisObj;
|
|
22272
|
+
return {
|
|
22273
|
+
id,
|
|
22274
|
+
//only add custom axis ranges if defined:
|
|
22275
|
+
...customMin ? { min: customMin } : {},
|
|
22276
|
+
...customMax ? { max: customMax } : {},
|
|
22277
|
+
...unit ? { unit } : {}
|
|
22278
|
+
};
|
|
22279
|
+
}
|
|
22280
|
+
);
|
|
22253
22281
|
} else {
|
|
22254
22282
|
const id = generateAxisId(axisType);
|
|
22255
22283
|
const customMin = (_b2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b2.min;
|
|
22256
22284
|
const customMax = (_c2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _c2.max;
|
|
22257
|
-
const unit = axes == null ? void 0 : axes[id][0].unit;
|
|
22285
|
+
const unit = (_e2 = (_d2 = axes == null ? void 0 : axes[id]) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.unit;
|
|
22258
22286
|
return [
|
|
22259
22287
|
{
|
|
22260
22288
|
id,
|
|
@@ -22421,15 +22449,15 @@ const LineOptions = ({
|
|
|
22421
22449
|
}
|
|
22422
22450
|
];
|
|
22423
22451
|
const selectedOption = options.find((option) => option.selected);
|
|
22424
|
-
return /* @__PURE__ */ jsx(Tooltip$2, { text: selectedOption.label, placement: "bottom", children: /* @__PURE__ */ jsx(
|
|
22452
|
+
return /* @__PURE__ */ jsx(Tooltip$2, { text: selectedOption == null ? void 0 : selectedOption.label, placement: "bottom", children: /* @__PURE__ */ jsx(
|
|
22425
22453
|
Button,
|
|
22426
22454
|
{
|
|
22427
22455
|
small: true,
|
|
22428
22456
|
basic: true,
|
|
22429
22457
|
colored: "muted",
|
|
22430
22458
|
round: true,
|
|
22431
|
-
icon: selectedOption.icon,
|
|
22432
|
-
onClick: selectedOption.onClick
|
|
22459
|
+
icon: selectedOption == null ? void 0 : selectedOption.icon,
|
|
22460
|
+
onClick: selectedOption == null ? void 0 : selectedOption.onClick
|
|
22433
22461
|
}
|
|
22434
22462
|
) });
|
|
22435
22463
|
};
|
|
@@ -22522,8 +22550,8 @@ const DragOptions = ({
|
|
|
22522
22550
|
colored: "muted",
|
|
22523
22551
|
basic: true,
|
|
22524
22552
|
small: true,
|
|
22525
|
-
label: selectedOption.buttonLabel || selectedOption.label,
|
|
22526
|
-
icon: selectedOption.icon
|
|
22553
|
+
label: (selectedOption == null ? void 0 : selectedOption.buttonLabel) || (selectedOption == null ? void 0 : selectedOption.label),
|
|
22554
|
+
icon: selectedOption == null ? void 0 : selectedOption.icon
|
|
22527
22555
|
}
|
|
22528
22556
|
)
|
|
22529
22557
|
}
|
|
@@ -23503,15 +23531,19 @@ const useChartFunctions = ({
|
|
|
23503
23531
|
}) => {
|
|
23504
23532
|
const {
|
|
23505
23533
|
annotations,
|
|
23506
|
-
interactions: {
|
|
23534
|
+
interactions: {
|
|
23535
|
+
onLegendClick,
|
|
23536
|
+
onHover: onPointHover,
|
|
23537
|
+
onUnhover: onPointUnhover
|
|
23538
|
+
},
|
|
23507
23539
|
additionalAxesOptions,
|
|
23508
23540
|
axes
|
|
23509
23541
|
} = options;
|
|
23510
23542
|
const legendClick = useCallback(
|
|
23511
|
-
(
|
|
23543
|
+
(_e2, legendItem2) => {
|
|
23512
23544
|
const { datasetIndex } = legendItem2;
|
|
23513
|
-
const chartInstance = chartRef.current;
|
|
23514
|
-
const { datasets } = chartInstance.data;
|
|
23545
|
+
const chartInstance = chartRef == null ? void 0 : chartRef.current;
|
|
23546
|
+
const { datasets } = (chartInstance == null ? void 0 : chartInstance.data) || {};
|
|
23515
23547
|
const dataset = datasets[datasetIndex];
|
|
23516
23548
|
const meta = chartInstance.getDatasetMeta(datasetIndex);
|
|
23517
23549
|
meta.hidden = meta.hidden === null ? !dataset.hidden : null;
|
|
@@ -23520,7 +23552,7 @@ const useChartFunctions = ({
|
|
|
23520
23552
|
dispatch({ type: "TOGGLE_ANNOTATION", payload: { annotationIndex } });
|
|
23521
23553
|
}
|
|
23522
23554
|
if (dataset.displayGroup) {
|
|
23523
|
-
datasets.forEach((ds, ix) => {
|
|
23555
|
+
datasets == null ? void 0 : datasets.forEach((ds, ix) => {
|
|
23524
23556
|
if (ds.displayGroup !== dataset.displayGroup)
|
|
23525
23557
|
return;
|
|
23526
23558
|
chartInstance.getDatasetMeta(ix).hidden = meta.hidden;
|
|
@@ -23529,13 +23561,13 @@ const useChartFunctions = ({
|
|
|
23529
23561
|
if (onLegendClick) {
|
|
23530
23562
|
onLegendClick(legendItem2 == null ? void 0 : legendItem2.text, legendItem2.hidden);
|
|
23531
23563
|
}
|
|
23532
|
-
chartInstance.update();
|
|
23564
|
+
chartInstance == null ? void 0 : chartInstance.update();
|
|
23533
23565
|
},
|
|
23534
23566
|
[onLegendClick, annotations]
|
|
23535
23567
|
);
|
|
23536
23568
|
const resetZoom2 = useCallback(() => {
|
|
23537
|
-
const chartInstance = chartRef.current;
|
|
23538
|
-
chartInstance.resetZoom();
|
|
23569
|
+
const chartInstance = chartRef == null ? void 0 : chartRef.current;
|
|
23570
|
+
chartInstance == null ? void 0 : chartInstance.resetZoom();
|
|
23539
23571
|
dispatch({ type: "RESET_AXES_RANGES" });
|
|
23540
23572
|
}, [chartRef]);
|
|
23541
23573
|
const onHover = useCallback((hoveredPoint, setHoveredPoint) => {
|
|
@@ -23575,22 +23607,30 @@ const useChartFunctions = ({
|
|
|
23575
23607
|
}, [chartRef, state.axes]);
|
|
23576
23608
|
const handleKeyDown = useCallback(
|
|
23577
23609
|
(evt) => {
|
|
23610
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
23578
23611
|
if (evt.key === Key.Shift) {
|
|
23579
23612
|
const chart2 = chartRef.current;
|
|
23580
|
-
chart2.config.options.plugins
|
|
23581
|
-
|
|
23582
|
-
|
|
23613
|
+
const zoom2 = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.config) == null ? void 0 : _a2.options) == null ? void 0 : _b2.plugins) == null ? void 0 : _c2.zoom;
|
|
23614
|
+
if (((_d2 = zoom2 == null ? void 0 : zoom2.zoom) == null ? void 0 : _d2.mode) && ((_e2 = zoom2 == null ? void 0 : zoom2.pan) == null ? void 0 : _e2.mode)) {
|
|
23615
|
+
zoom2.zoom.mode = PanZoomMode.Y;
|
|
23616
|
+
zoom2.pan.mode = PanZoomMode.Y;
|
|
23617
|
+
chart2 == null ? void 0 : chart2.update();
|
|
23618
|
+
}
|
|
23583
23619
|
}
|
|
23584
23620
|
},
|
|
23585
23621
|
[chartRef]
|
|
23586
23622
|
);
|
|
23587
23623
|
const handleKeyUp = useCallback(
|
|
23588
23624
|
(evt) => {
|
|
23625
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
23589
23626
|
if (evt.key === Key.Shift) {
|
|
23590
23627
|
const chart2 = chartRef.current;
|
|
23591
|
-
chart2.config.options.plugins
|
|
23592
|
-
|
|
23593
|
-
|
|
23628
|
+
const zoom2 = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.config) == null ? void 0 : _a2.options) == null ? void 0 : _b2.plugins) == null ? void 0 : _c2.zoom;
|
|
23629
|
+
if (((_d2 = zoom2 == null ? void 0 : zoom2.zoom) == null ? void 0 : _d2.mode) && ((_e2 = zoom2 == null ? void 0 : zoom2.pan) == null ? void 0 : _e2.mode)) {
|
|
23630
|
+
zoom2.zoom.mode = PanZoomMode.XY;
|
|
23631
|
+
zoom2.pan.mode = PanZoomMode.XY;
|
|
23632
|
+
chart2 == null ? void 0 : chart2.update();
|
|
23633
|
+
}
|
|
23594
23634
|
}
|
|
23595
23635
|
},
|
|
23596
23636
|
[chartRef]
|
|
@@ -23636,13 +23676,15 @@ const useChartFunctions = ({
|
|
|
23636
23676
|
);
|
|
23637
23677
|
const updateAxesRangesFromChart = useCallback(() => {
|
|
23638
23678
|
const { scales = {} } = (chartRef == null ? void 0 : chartRef.current) || {};
|
|
23639
|
-
const axes2 = Object.entries(scales).map(
|
|
23640
|
-
|
|
23641
|
-
|
|
23642
|
-
|
|
23643
|
-
|
|
23644
|
-
|
|
23645
|
-
|
|
23679
|
+
const axes2 = Object.entries(scales).map(
|
|
23680
|
+
([key, { min, max }]) => {
|
|
23681
|
+
return {
|
|
23682
|
+
id: key,
|
|
23683
|
+
min: min ?? 0,
|
|
23684
|
+
max: max ?? 0
|
|
23685
|
+
};
|
|
23686
|
+
}
|
|
23687
|
+
);
|
|
23646
23688
|
dispatch({
|
|
23647
23689
|
type: UPDATE_AXES_RANGES,
|
|
23648
23690
|
payload: { axes: axes2 }
|
|
@@ -23674,8 +23716,11 @@ var actionTypes = /* @__PURE__ */ ((actionTypes2) => {
|
|
|
23674
23716
|
actionTypes2["UnitUpdated"] = "unitUpdated";
|
|
23675
23717
|
return actionTypes2;
|
|
23676
23718
|
})(actionTypes || {});
|
|
23677
|
-
const initializeFormState = ({
|
|
23678
|
-
|
|
23719
|
+
const initializeFormState = ({
|
|
23720
|
+
initialAxesRanges,
|
|
23721
|
+
axes = []
|
|
23722
|
+
}) => {
|
|
23723
|
+
return (initialAxesRanges == null ? void 0 : initialAxesRanges.map((initialAxisRange) => {
|
|
23679
23724
|
const currentAxisRange = axes.find((a2) => a2.id === initialAxisRange.id);
|
|
23680
23725
|
return {
|
|
23681
23726
|
id: initialAxisRange.id,
|
|
@@ -23683,7 +23728,7 @@ const initializeFormState = ({ initialAxesRanges, axes = [] }) => {
|
|
|
23683
23728
|
max: (currentAxisRange == null ? void 0 : currentAxisRange.max) ?? (initialAxisRange == null ? void 0 : initialAxisRange.max),
|
|
23684
23729
|
unit: currentAxisRange == null ? void 0 : currentAxisRange.unit
|
|
23685
23730
|
};
|
|
23686
|
-
});
|
|
23731
|
+
})) || [];
|
|
23687
23732
|
};
|
|
23688
23733
|
const isEmptyString = (value) => value === "";
|
|
23689
23734
|
const createErrorMessages = (value, compareTo, type) => {
|
|
@@ -23701,11 +23746,12 @@ const validateAxes = (formState) => {
|
|
|
23701
23746
|
return formState.reduce(
|
|
23702
23747
|
(acc, { id, min, max }) => {
|
|
23703
23748
|
return produce(acc, (draft) => {
|
|
23749
|
+
var _a2;
|
|
23704
23750
|
const errors = {
|
|
23705
|
-
min: createErrorMessages(min, max, "min"),
|
|
23706
|
-
max: createErrorMessages(max, min, "max")
|
|
23751
|
+
min: createErrorMessages(String(min), String(max), "min"),
|
|
23752
|
+
max: createErrorMessages(String(max), String(min), "max")
|
|
23707
23753
|
};
|
|
23708
|
-
draft.errors.push({
|
|
23754
|
+
(_a2 = draft == null ? void 0 : draft.errors) == null ? void 0 : _a2.push({
|
|
23709
23755
|
id,
|
|
23710
23756
|
...errors
|
|
23711
23757
|
});
|
|
@@ -23725,13 +23771,17 @@ const reducer = (state, action) => {
|
|
|
23725
23771
|
return produce(state, (draft) => {
|
|
23726
23772
|
const { name: name2, value, id } = action.payload;
|
|
23727
23773
|
const axis = draft.find((a2) => a2.id === id);
|
|
23728
|
-
axis
|
|
23774
|
+
if (axis) {
|
|
23775
|
+
axis[name2] = value;
|
|
23776
|
+
}
|
|
23729
23777
|
});
|
|
23730
23778
|
case actionTypes.UnitUpdated:
|
|
23731
23779
|
return produce(state, (draft) => {
|
|
23732
23780
|
const { name: name2, value, id } = action.payload;
|
|
23733
23781
|
const axis = draft.find((a2) => a2.id === id);
|
|
23734
|
-
axis
|
|
23782
|
+
if (axis) {
|
|
23783
|
+
axis.unit[name2] = value;
|
|
23784
|
+
}
|
|
23735
23785
|
});
|
|
23736
23786
|
default:
|
|
23737
23787
|
return state;
|
|
@@ -23784,54 +23834,55 @@ const AxesOptionsPopover = (optionsPopover) => {
|
|
|
23784
23834
|
onUpdateAxes({
|
|
23785
23835
|
axes: sanitizedFormState
|
|
23786
23836
|
});
|
|
23787
|
-
sanitizedFormState.
|
|
23837
|
+
sanitizedFormState.map((el, i2) => {
|
|
23788
23838
|
var _a3, _b2, _c2;
|
|
23789
23839
|
const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
|
|
23790
23840
|
if (selectedUnit) {
|
|
23791
23841
|
(_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
|
|
23792
23842
|
}
|
|
23793
23843
|
});
|
|
23794
|
-
if (depthType) {
|
|
23795
|
-
depthType.setSelectedDepthType(depthTypeState);
|
|
23844
|
+
if (depthType && (depthType == null ? void 0 : depthType.setSelectedDepthType)) {
|
|
23845
|
+
depthType == null ? void 0 : depthType.setSelectedDepthType(depthTypeState);
|
|
23796
23846
|
}
|
|
23797
23847
|
}
|
|
23798
|
-
close();
|
|
23848
|
+
close == null ? void 0 : close();
|
|
23799
23849
|
};
|
|
23800
23850
|
const onReset = () => {
|
|
23801
23851
|
dispatch({
|
|
23802
23852
|
type: actionTypes.Reset,
|
|
23803
23853
|
payload: { axes, initialAxesRanges }
|
|
23804
23854
|
});
|
|
23805
|
-
initialAxesRanges.
|
|
23855
|
+
initialAxesRanges.map((el, i2) => {
|
|
23806
23856
|
var _a3, _b2, _c2;
|
|
23807
|
-
const selectedUnit = (_a3 = el
|
|
23857
|
+
const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
|
|
23808
23858
|
if (selectedUnit) {
|
|
23809
23859
|
(_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
|
|
23810
23860
|
}
|
|
23811
23861
|
});
|
|
23812
23862
|
onResetAxes();
|
|
23813
|
-
close();
|
|
23863
|
+
close == null ? void 0 : close();
|
|
23814
23864
|
};
|
|
23815
23865
|
const isCustomValue = axes.filter((axis) => axis.max || axis.min).length > 0;
|
|
23816
23866
|
const handleInputFocus = (e2) => e2.target.select();
|
|
23817
23867
|
return /* @__PURE__ */ jsxs("form", { onSubmit: onDone, children: [
|
|
23818
23868
|
axes.map((axis, i2) => {
|
|
23819
|
-
var _a3, _b2, _c2
|
|
23820
|
-
const
|
|
23869
|
+
var _a3, _b2, _c2;
|
|
23870
|
+
const axisControl = controlsAxesLabels.find(
|
|
23821
23871
|
(el) => el.id === axis.id
|
|
23822
|
-
)
|
|
23823
|
-
const
|
|
23824
|
-
const
|
|
23825
|
-
const
|
|
23826
|
-
const
|
|
23827
|
-
const
|
|
23872
|
+
);
|
|
23873
|
+
const axisLabel = axisControl == null ? void 0 : axisControl.label;
|
|
23874
|
+
const axisState = formState.find((a2) => a2.id === axis.id);
|
|
23875
|
+
const axisErrors = errors == null ? void 0 : errors.find((a2) => a2.id === axis.id);
|
|
23876
|
+
const { min, max, unit } = axisState || {};
|
|
23877
|
+
const minErrorMsg = ((_a3 = axisErrors == null ? void 0 : axisErrors.min) == null ? void 0 : _a3[0]) ? translations[axisErrors.min[0]] : null;
|
|
23878
|
+
const maxErrorMsg = ((_b2 = axisErrors == null ? void 0 : axisErrors.max) == null ? void 0 : _b2[0]) ? translations[axisErrors.max[0]] : null;
|
|
23828
23879
|
return /* @__PURE__ */ jsx(Field, { label: axisLabel || axis.id || "", children: /* @__PURE__ */ jsxs(InputGroup, { small: true, width: "300px", children: [
|
|
23829
23880
|
/* @__PURE__ */ jsx(
|
|
23830
23881
|
NumberInput,
|
|
23831
23882
|
{
|
|
23832
23883
|
name: "min",
|
|
23833
23884
|
value: min,
|
|
23834
|
-
error:
|
|
23885
|
+
error: minErrorMsg,
|
|
23835
23886
|
size: 5,
|
|
23836
23887
|
width: "100%",
|
|
23837
23888
|
onChange: (evt) => onEditValue({
|
|
@@ -23848,7 +23899,7 @@ const AxesOptionsPopover = (optionsPopover) => {
|
|
|
23848
23899
|
{
|
|
23849
23900
|
name: "max",
|
|
23850
23901
|
value: max,
|
|
23851
|
-
error:
|
|
23902
|
+
error: maxErrorMsg,
|
|
23852
23903
|
size: 5,
|
|
23853
23904
|
width: "100%",
|
|
23854
23905
|
onChange: (evt) => onEditValue({
|
|
@@ -23863,7 +23914,7 @@ const AxesOptionsPopover = (optionsPopover) => {
|
|
|
23863
23914
|
Select,
|
|
23864
23915
|
{
|
|
23865
23916
|
name: "selectedUnit",
|
|
23866
|
-
options: (
|
|
23917
|
+
options: (_c2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _c2.options,
|
|
23867
23918
|
value: unit == null ? void 0 : unit.selectedUnit,
|
|
23868
23919
|
onChange: (e2) => {
|
|
23869
23920
|
onEditUnit({
|
|
@@ -23959,14 +24010,19 @@ const AxesOptions = (optionsPopover) => {
|
|
|
23959
24010
|
}
|
|
23960
24011
|
);
|
|
23961
24012
|
};
|
|
23962
|
-
const ControlsPortal = ({
|
|
24013
|
+
const ControlsPortal = ({
|
|
24014
|
+
children,
|
|
24015
|
+
controlsPortalId
|
|
24016
|
+
}) => {
|
|
23963
24017
|
if (controlsPortalId && document.getElementById(controlsPortalId)) {
|
|
23964
24018
|
return /* @__PURE__ */ jsx(Portal, { id: controlsPortalId, children });
|
|
23965
24019
|
}
|
|
23966
24020
|
return children;
|
|
23967
24021
|
};
|
|
23968
24022
|
const Controls = ({
|
|
23969
|
-
|
|
24023
|
+
headerComponent,
|
|
24024
|
+
subheaderComponent,
|
|
24025
|
+
table: table2,
|
|
23970
24026
|
chartRef,
|
|
23971
24027
|
state,
|
|
23972
24028
|
options,
|
|
@@ -23984,7 +24040,7 @@ const Controls = ({
|
|
|
23984
24040
|
showTable,
|
|
23985
24041
|
zoomEnabled
|
|
23986
24042
|
} = state;
|
|
23987
|
-
const { dragData } = options;
|
|
24043
|
+
const { dragData, depthType } = options;
|
|
23988
24044
|
const {
|
|
23989
24045
|
onToggleLine,
|
|
23990
24046
|
onTogglePan,
|
|
@@ -24011,7 +24067,7 @@ const Controls = ({
|
|
|
24011
24067
|
/* @__PURE__ */ jsxs("div", { className: styles$3.controls, children: [
|
|
24012
24068
|
!!options.title && /* @__PURE__ */ jsx(Text, { bold: true, children: options.title }),
|
|
24013
24069
|
headerComponent,
|
|
24014
|
-
/* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId, children: /* @__PURE__ */ jsxs("div", { className: styles$3.buttons, children: [
|
|
24070
|
+
/* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId: controlsPortalId ?? "", children: /* @__PURE__ */ jsxs("div", { className: styles$3.buttons, children: [
|
|
24015
24071
|
!showTable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24016
24072
|
/* @__PURE__ */ jsx(
|
|
24017
24073
|
AxesOptions,
|
|
@@ -24021,7 +24077,7 @@ const Controls = ({
|
|
|
24021
24077
|
controlsAxesLabels,
|
|
24022
24078
|
onUpdateAxes,
|
|
24023
24079
|
onResetAxes,
|
|
24024
|
-
depthType
|
|
24080
|
+
depthType,
|
|
24025
24081
|
translations
|
|
24026
24082
|
}
|
|
24027
24083
|
),
|
|
@@ -24204,7 +24260,7 @@ const LegendItemLine = ({ dataset }) => {
|
|
|
24204
24260
|
) });
|
|
24205
24261
|
};
|
|
24206
24262
|
const LegendItemPoint = ({ dataset }) => {
|
|
24207
|
-
const { pointBackgroundColor, pointRadius, pointStyle } = dataset;
|
|
24263
|
+
const { pointBackgroundColor, pointRadius, pointStyle = "" } = dataset;
|
|
24208
24264
|
if (!pointRadius)
|
|
24209
24265
|
return null;
|
|
24210
24266
|
const size = pointRadius * 2;
|
|
@@ -24291,12 +24347,12 @@ const LegendPanel = forwardRef((props, ref) => {
|
|
|
24291
24347
|
const { data, chartArea, height = 0, width = 0 } = chart2;
|
|
24292
24348
|
const { datasets } = data;
|
|
24293
24349
|
const { top: top2, left: left2, bottom: bottom2, right: right2 } = chartArea;
|
|
24294
|
-
const items = ((_d2 = (_c2 = (_b2 = (_a2 = chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.legend) == null ? void 0 : _c2.labels) == null ? void 0 : _d2.generateLabels(chart2)) ?? [];
|
|
24350
|
+
const items = ((_d2 = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.legend) == null ? void 0 : _c2.labels) == null ? void 0 : _d2.generateLabels(chart2)) ?? [];
|
|
24295
24351
|
const style = {
|
|
24296
|
-
left: legendPosition.includes("left") ? left2 :
|
|
24297
|
-
right: legendPosition.includes("right") ? width - right2 :
|
|
24298
|
-
top: legendPosition.includes("top") ? top2 :
|
|
24299
|
-
bottom: legendPosition.includes("bottom") ? height - bottom2 :
|
|
24352
|
+
left: legendPosition.includes("left") ? left2 : void 0,
|
|
24353
|
+
right: legendPosition.includes("right") ? width - right2 : void 0,
|
|
24354
|
+
top: legendPosition.includes("top") ? top2 : void 0,
|
|
24355
|
+
bottom: legendPosition.includes("bottom") ? height - bottom2 : void 0,
|
|
24300
24356
|
maxHeight: 0.5 * (bottom2 - top2 - LEGEND_MARGIN * 2),
|
|
24301
24357
|
maxWidth: 0.5 * (right2 - left2 - LEGEND_MARGIN * 2),
|
|
24302
24358
|
margin: LEGEND_MARGIN
|
|
@@ -24447,7 +24503,7 @@ const Legend2 = ({
|
|
|
24447
24503
|
LegendDropZones,
|
|
24448
24504
|
{
|
|
24449
24505
|
chartArea,
|
|
24450
|
-
setLegendPosition,
|
|
24506
|
+
setLegendPosition: (position) => setLegendPosition(position),
|
|
24451
24507
|
isDragging: isDragging2,
|
|
24452
24508
|
placeholderSize: panelSize
|
|
24453
24509
|
}
|
|
@@ -24465,116 +24521,122 @@ const TextLabelPosition = {
|
|
|
24465
24521
|
BOTTOM_CENTER: "bottom-center",
|
|
24466
24522
|
BOTTOM_RIGHT: "bottom-right"
|
|
24467
24523
|
};
|
|
24468
|
-
const
|
|
24524
|
+
const defaultAxes$1 = (axes) => ({
|
|
24525
|
+
x: (axes == null ? void 0 : axes.x) || [],
|
|
24526
|
+
y: (axes == null ? void 0 : axes.y) || []
|
|
24527
|
+
});
|
|
24528
|
+
const defaultAdditionalAxesOptions$1 = (options) => ({
|
|
24529
|
+
chartScaleType: (options == null ? void 0 : options.chartScaleType) || "linear",
|
|
24530
|
+
reverse: (options == null ? void 0 : options.reverse) || false,
|
|
24531
|
+
beginAtZero: (options == null ? void 0 : options.beginAtZero) ?? false,
|
|
24532
|
+
stepSize: options == null ? void 0 : options.stepSize,
|
|
24533
|
+
suggestedMin: options == null ? void 0 : options.suggestedMin,
|
|
24534
|
+
suggestedMax: options == null ? void 0 : options.suggestedMax,
|
|
24535
|
+
range: (options == null ? void 0 : options.range) || {},
|
|
24536
|
+
autoAxisPadding: (options == null ? void 0 : options.autoAxisPadding) ?? false
|
|
24537
|
+
});
|
|
24538
|
+
const defaultChartStyling$2 = (options) => ({
|
|
24539
|
+
width: options == null ? void 0 : options.width,
|
|
24540
|
+
height: options == null ? void 0 : options.height,
|
|
24541
|
+
maintainAspectRatio: (options == null ? void 0 : options.maintainAspectRatio) ?? false,
|
|
24542
|
+
staticChartHeight: (options == null ? void 0 : options.staticChartHeight) ?? false,
|
|
24543
|
+
performanceMode: (options == null ? void 0 : options.performanceMode) ?? true,
|
|
24544
|
+
squareAspectRatio: options == null ? void 0 : options.squareAspectRatio,
|
|
24545
|
+
layoutPadding: (options == null ? void 0 : options.layoutPadding) || {
|
|
24546
|
+
top: 0,
|
|
24547
|
+
bottom: 20,
|
|
24548
|
+
left: 0,
|
|
24549
|
+
right: 0
|
|
24550
|
+
}
|
|
24551
|
+
});
|
|
24552
|
+
const defaultTooltip$2 = (tooltip) => ({
|
|
24553
|
+
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
24554
|
+
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) ?? false,
|
|
24555
|
+
hideSimulationName: (tooltip == null ? void 0 : tooltip.hideSimulationName) ?? false
|
|
24556
|
+
});
|
|
24557
|
+
const defaultGraph$2 = (graph) => ({
|
|
24558
|
+
lineTension: (graph == null ? void 0 : graph.lineTension) ?? 0.01,
|
|
24559
|
+
spanGaps: (graph == null ? void 0 : graph.spanGaps) ?? false,
|
|
24560
|
+
showDataLabels: (graph == null ? void 0 : graph.showDataLabels) ?? false,
|
|
24561
|
+
showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) ?? false
|
|
24562
|
+
});
|
|
24563
|
+
const defaultAnnotations$1 = (annotations) => {
|
|
24469
24564
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
24470
|
-
|
|
24471
|
-
|
|
24472
|
-
|
|
24473
|
-
|
|
24474
|
-
|
|
24475
|
-
|
|
24476
|
-
|
|
24477
|
-
|
|
24478
|
-
|
|
24479
|
-
|
|
24480
|
-
|
|
24481
|
-
|
|
24482
|
-
|
|
24483
|
-
|
|
24484
|
-
|
|
24485
|
-
|
|
24486
|
-
|
|
24565
|
+
return {
|
|
24566
|
+
labelAnnotation: {
|
|
24567
|
+
showLabel: ((_a2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _a2.showLabel) ?? false,
|
|
24568
|
+
text: ((_b2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _b2.text) ?? "",
|
|
24569
|
+
position: ((_c2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _c2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
|
|
24570
|
+
fontSize: ((_d2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _d2.fontSize) ?? 12,
|
|
24571
|
+
xOffset: ((_e2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _e2.xOffset) ?? 5,
|
|
24572
|
+
yOffset: ((_f2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _f2.yOffset) ?? 5,
|
|
24573
|
+
maxWidth: ((_g2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _g2.maxWidth) ?? 300,
|
|
24574
|
+
lineHeight: ((_h2 = annotations == null ? void 0 : annotations.labelAnnotation) == null ? void 0 : _h2.lineHeight) ?? 12
|
|
24575
|
+
},
|
|
24576
|
+
showAnnotations: (annotations == null ? void 0 : annotations.showAnnotations) ?? false,
|
|
24577
|
+
controlAnnotation: (annotations == null ? void 0 : annotations.controlAnnotation) ?? false,
|
|
24578
|
+
annotationsData: (annotations == null ? void 0 : annotations.annotationsData) ?? []
|
|
24579
|
+
};
|
|
24580
|
+
};
|
|
24581
|
+
const defaultLegend$2 = (legend2) => ({
|
|
24582
|
+
display: (legend2 == null ? void 0 : legend2.display) ?? true,
|
|
24583
|
+
position: (legend2 == null ? void 0 : legend2.position) ?? Position.BottomLeft,
|
|
24584
|
+
align: (legend2 == null ? void 0 : legend2.align) ?? AlignOptions.Center,
|
|
24585
|
+
customLegend: (legend2 == null ? void 0 : legend2.customLegend) ?? {
|
|
24586
|
+
customLegendPlugin: null,
|
|
24587
|
+
customLegendContainerID: ""
|
|
24588
|
+
},
|
|
24589
|
+
usePointStyle: (legend2 == null ? void 0 : legend2.usePointStyle) ?? true
|
|
24590
|
+
});
|
|
24591
|
+
const defaultChartOptions$2 = (options) => ({
|
|
24592
|
+
showPoints: (options == null ? void 0 : options.showPoints) ?? true,
|
|
24593
|
+
enableZoom: (options == null ? void 0 : options.enableZoom) ?? true,
|
|
24594
|
+
enablePan: (options == null ? void 0 : options.enablePan) ?? false,
|
|
24595
|
+
showLine: (options == null ? void 0 : options.showLine) ?? true,
|
|
24596
|
+
closeOnOutsideClick: (options == null ? void 0 : options.closeOnOutsideClick) ?? false
|
|
24597
|
+
});
|
|
24598
|
+
const defaultInteractions$2 = (interactions) => ({
|
|
24599
|
+
onLegendClick: interactions == null ? void 0 : interactions.onLegendClick,
|
|
24600
|
+
onHover: interactions == null ? void 0 : interactions.onHover,
|
|
24601
|
+
onUnhover: interactions == null ? void 0 : interactions.onUnhover,
|
|
24602
|
+
onAnimationComplete: interactions == null ? void 0 : interactions.onAnimationComplete
|
|
24603
|
+
});
|
|
24604
|
+
const defaultDragData$1 = (dragData) => ({
|
|
24605
|
+
enableDragData: (dragData == null ? void 0 : dragData.enableDragData) ?? false,
|
|
24606
|
+
showTooltip: (dragData == null ? void 0 : dragData.showTooltip) ?? true,
|
|
24607
|
+
roundPoints: (dragData == null ? void 0 : dragData.roundPoints) ?? true,
|
|
24608
|
+
dragX: (dragData == null ? void 0 : dragData.dragX) ?? true,
|
|
24609
|
+
dragY: (dragData == null ? void 0 : dragData.dragY) ?? true,
|
|
24610
|
+
onDragStart: dragData == null ? void 0 : dragData.onDragStart,
|
|
24611
|
+
onDrag: dragData == null ? void 0 : dragData.onDrag,
|
|
24612
|
+
onDragEnd: dragData == null ? void 0 : dragData.onDragEnd
|
|
24613
|
+
});
|
|
24614
|
+
const getDefaultProps$2 = (props) => {
|
|
24615
|
+
const chart2 = (props == null ? void 0 : props.chart) || {};
|
|
24616
|
+
const options = (chart2 == null ? void 0 : chart2.options) || {};
|
|
24617
|
+
return {
|
|
24618
|
+
persistenceId: (chart2 == null ? void 0 : chart2.persistenceId) ?? "",
|
|
24619
|
+
controlsPortalId: (chart2 == null ? void 0 : chart2.controlsPortalId) ?? "",
|
|
24620
|
+
testId: (chart2 == null ? void 0 : chart2.testId) ?? null,
|
|
24621
|
+
data: chart2 == null ? void 0 : chart2.data,
|
|
24487
24622
|
options: {
|
|
24488
|
-
title:
|
|
24489
|
-
scales:
|
|
24490
|
-
axes:
|
|
24491
|
-
|
|
24492
|
-
|
|
24493
|
-
|
|
24494
|
-
|
|
24495
|
-
|
|
24496
|
-
|
|
24497
|
-
|
|
24498
|
-
|
|
24499
|
-
|
|
24500
|
-
|
|
24501
|
-
|
|
24502
|
-
|
|
24503
|
-
},
|
|
24504
|
-
chartStyling: {
|
|
24505
|
-
width: props.chart.options.chartStyling.width,
|
|
24506
|
-
height: props.chart.options.chartStyling.height,
|
|
24507
|
-
maintainAspectRatio: props.chart.options.chartStyling.maintainAspectRatio || false,
|
|
24508
|
-
staticChartHeight: props.chart.options.chartStyling.staticChartHeight || false,
|
|
24509
|
-
performanceMode: props.chart.options.chartStyling.performanceMode ?? true,
|
|
24510
|
-
squareAspectRatio: props.chart.options.chartStyling.squareAspectRatio || false,
|
|
24511
|
-
layoutPadding: props.chart.options.chartStyling.layoutPadding || {
|
|
24512
|
-
top: 0,
|
|
24513
|
-
bottom: 20,
|
|
24514
|
-
left: 0,
|
|
24515
|
-
right: 0
|
|
24516
|
-
}
|
|
24517
|
-
},
|
|
24518
|
-
tooltip: {
|
|
24519
|
-
tooltips: props.chart.options.tooltip.tooltips ?? true,
|
|
24520
|
-
showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false,
|
|
24521
|
-
hideSimulationName: props.chart.options.tooltip.hideSimulationName || false
|
|
24522
|
-
},
|
|
24523
|
-
graph: {
|
|
24524
|
-
lineTension: props.chart.options.graph.lineTension || 0.01,
|
|
24525
|
-
spanGaps: props.chart.options.graph.spanGaps || false,
|
|
24526
|
-
showDataLabels: props.chart.options.graph.showDataLabels || false,
|
|
24527
|
-
showMinorGridlines: props.chart.options.graph.showMinorGridlines || false
|
|
24528
|
-
},
|
|
24529
|
-
annotations: {
|
|
24530
|
-
labelAnnotation: {
|
|
24531
|
-
showLabel: ((_a2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _a2.showLabel) ?? false,
|
|
24532
|
-
text: ((_b2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _b2.text) ?? "",
|
|
24533
|
-
position: ((_c2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _c2.position) ?? TextLabelPosition.BOTTOM_RIGHT,
|
|
24534
|
-
fontSize: ((_d2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _d2.fontSize) ?? 12,
|
|
24535
|
-
xOffset: ((_e2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _e2.xOffset) ?? 5,
|
|
24536
|
-
yOffset: ((_f2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _f2.yOffset) ?? 5,
|
|
24537
|
-
maxWidth: ((_g2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _g2.maxWidth) ?? 300,
|
|
24538
|
-
lineHeight: ((_h2 = props.chart.options.annotations.labelAnnotation) == null ? void 0 : _h2.lineHeight) ?? 12
|
|
24539
|
-
},
|
|
24540
|
-
showAnnotations: props.chart.options.annotations.showAnnotations ?? false,
|
|
24541
|
-
controlAnnotation: props.chart.options.annotations.controlAnnotation || false,
|
|
24542
|
-
annotationsData: props.chart.options.annotations.annotationsData || []
|
|
24543
|
-
},
|
|
24544
|
-
legend: {
|
|
24545
|
-
display: props.chart.options.legend.display ?? true,
|
|
24546
|
-
position: props.chart.options.legend.position || "bottom-left",
|
|
24547
|
-
align: props.chart.options.legend.align || "center",
|
|
24548
|
-
customLegend: props.chart.options.legend.customLegend,
|
|
24549
|
-
usePointStyle: props.chart.options.legend.usePointStyle ?? true
|
|
24550
|
-
},
|
|
24551
|
-
chartOptions: {
|
|
24552
|
-
showPoints: props.chart.options.chartOptions.showPoints ?? true,
|
|
24553
|
-
enableZoom: props.chart.options.chartOptions.enableZoom || true,
|
|
24554
|
-
enablePan: props.chart.options.chartOptions.enablePan || false,
|
|
24555
|
-
showLine: props.chart.options.chartOptions.showLine ?? true,
|
|
24556
|
-
closeOnOutsideClick: props.chart.options.chartOptions.closeOnOutsideClick || false
|
|
24557
|
-
},
|
|
24558
|
-
interactions: {
|
|
24559
|
-
onLegendClick: props.chart.options.interactions.onLegendClick,
|
|
24560
|
-
onPointHover: props.chart.options.interactions.onPointHover,
|
|
24561
|
-
onPointUnhover: props.chart.options.interactions.onPointUnhover,
|
|
24562
|
-
onAnimationComplete: props.chart.options.interactions.onAnimationComplete
|
|
24563
|
-
},
|
|
24564
|
-
depthType: props.chart.options.depthType,
|
|
24565
|
-
dragData: {
|
|
24566
|
-
enableDragData: props.chart.options.dragData.enableDragData ?? false,
|
|
24567
|
-
showTooltip: props.chart.options.dragData.showTooltip ?? true,
|
|
24568
|
-
roundPoints: props.chart.options.dragData.roundPoints ?? true,
|
|
24569
|
-
dragX: props.chart.options.dragData.dragX ?? true,
|
|
24570
|
-
dragY: props.chart.options.dragData.dragY ?? true,
|
|
24571
|
-
onDragStart: props.chart.options.dragData.onDragStart,
|
|
24572
|
-
onDrag: props.chart.options.dragData.onDrag,
|
|
24573
|
-
onDragEnd: props.chart.options.dragData.onDragEnd
|
|
24574
|
-
}
|
|
24623
|
+
title: (options == null ? void 0 : options.title) ?? "",
|
|
24624
|
+
scales: (options == null ? void 0 : options.scales) ?? {},
|
|
24625
|
+
axes: defaultAxes$1(options == null ? void 0 : options.axes),
|
|
24626
|
+
additionalAxesOptions: defaultAdditionalAxesOptions$1(
|
|
24627
|
+
options == null ? void 0 : options.additionalAxesOptions
|
|
24628
|
+
),
|
|
24629
|
+
chartStyling: defaultChartStyling$2(options == null ? void 0 : options.chartStyling),
|
|
24630
|
+
tooltip: defaultTooltip$2(options == null ? void 0 : options.tooltip),
|
|
24631
|
+
graph: defaultGraph$2(options == null ? void 0 : options.graph),
|
|
24632
|
+
annotations: defaultAnnotations$1(options == null ? void 0 : options.annotations),
|
|
24633
|
+
legend: defaultLegend$2(options == null ? void 0 : options.legend),
|
|
24634
|
+
chartOptions: defaultChartOptions$2(options == null ? void 0 : options.chartOptions),
|
|
24635
|
+
interactions: defaultInteractions$2(options == null ? void 0 : options.interactions),
|
|
24636
|
+
dragData: defaultDragData$1(options == null ? void 0 : options.dragData),
|
|
24637
|
+
depthType: (options == null ? void 0 : options.depthType) ?? {}
|
|
24575
24638
|
}
|
|
24576
24639
|
};
|
|
24577
|
-
return chart2;
|
|
24578
24640
|
};
|
|
24579
24641
|
const DEFAULT_POINT_RADIUS = 2;
|
|
24580
24642
|
const DEFAULT_HOVER_RADIUS = 5;
|
|
@@ -24636,7 +24698,7 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
|
|
|
24636
24698
|
if (formation) {
|
|
24637
24699
|
const axesMin = (_a2 = axes[0]) == null ? void 0 : _a2.min;
|
|
24638
24700
|
const axesMax = (_b2 = axes[0]) == null ? void 0 : _b2.max;
|
|
24639
|
-
const [startPoint,
|
|
24701
|
+
const [startPoint, endPoint] = data;
|
|
24640
24702
|
if (axesMin && (startPoint == null ? void 0 : startPoint.x)) {
|
|
24641
24703
|
data[0].x = Math.max(axesMin, startPoint.x);
|
|
24642
24704
|
}
|
|
@@ -24658,9 +24720,9 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
|
|
|
24658
24720
|
borderWidth: parseFloat(borderWidth) || DEFAULT_BORDER_WIDTH,
|
|
24659
24721
|
borderDash: borderDash || [],
|
|
24660
24722
|
borderJoinStyle: BORDER_JOIN_STYLE,
|
|
24661
|
-
borderColor: borderColor ?? indexedColor ?? generateRandomColor
|
|
24723
|
+
borderColor: borderColor ?? indexedColor ?? generateRandomColor(COLORS),
|
|
24662
24724
|
backgroundColor: backgroundColor ?? DEFAULT_BACKGROUND_COLOR,
|
|
24663
|
-
pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor
|
|
24725
|
+
pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor(COLORS),
|
|
24664
24726
|
pointRadius: pointsEnabled ? linePointRadius : DEFAULT_LINE_POINT_RADIUS,
|
|
24665
24727
|
pointHoverRadius: hoverRadius,
|
|
24666
24728
|
pointHitRadius: line.pointHitRadius ?? hoverRadius
|
|
@@ -24700,8 +24762,8 @@ const formatAxisLabelNumbers = (tickValue, ticks, locale = "en-gb") => {
|
|
|
24700
24762
|
};
|
|
24701
24763
|
const getLineChartAxis = (options, axisType, state, currentScales, i2 = 0) => {
|
|
24702
24764
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
24703
|
-
const axisData = currentScales || options.axes[axisType][0];
|
|
24704
|
-
const stateAxis = state.axes.filter(
|
|
24765
|
+
const axisData = currentScales || options.axes[axisType][0] || {};
|
|
24766
|
+
const stateAxis = state == null ? void 0 : state.axes.filter(
|
|
24705
24767
|
(axis) => axis.id.startsWith(axisType)
|
|
24706
24768
|
)[i2];
|
|
24707
24769
|
const ticksConfigFromProps = (_b2 = (_a2 = options == null ? void 0 : options.scales) == null ? void 0 : _a2[`${i2 === 0 ? axisType : axisType + i2}`]) == null ? void 0 : _b2.ticks;
|
|
@@ -24748,14 +24810,17 @@ const getLineChartAxis = (options, axisType, state, currentScales, i2 = 0) => {
|
|
|
24748
24810
|
};
|
|
24749
24811
|
const getLineChartAxes = (options, axisType, state) => {
|
|
24750
24812
|
const axesData = options.axes[axisType];
|
|
24751
|
-
const axes = axesData.reduce(
|
|
24752
|
-
|
|
24753
|
-
|
|
24754
|
-
|
|
24755
|
-
|
|
24756
|
-
|
|
24757
|
-
|
|
24758
|
-
|
|
24813
|
+
const axes = axesData.reduce(
|
|
24814
|
+
(acc, curr, i2) => {
|
|
24815
|
+
const axisData = curr;
|
|
24816
|
+
axisData.color = curr.color || COLORS[i2] || generateRandomColor(COLORS);
|
|
24817
|
+
axisData.position = curr.position || getAxisPosition(axisType, i2);
|
|
24818
|
+
const axis = getLineChartAxis(options, axisType, state, axisData, i2);
|
|
24819
|
+
const axisId = generateAxisId(axisType, i2, true);
|
|
24820
|
+
return { ...acc, [axisId]: axis };
|
|
24821
|
+
},
|
|
24822
|
+
{}
|
|
24823
|
+
);
|
|
24759
24824
|
return axes;
|
|
24760
24825
|
};
|
|
24761
24826
|
const getLineChartScales = (options, state) => {
|
|
@@ -24804,11 +24869,9 @@ const estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
|
|
|
24804
24869
|
}
|
|
24805
24870
|
return acc;
|
|
24806
24871
|
}, {});
|
|
24807
|
-
return Object.values(axesFirstLast).some(
|
|
24808
|
-
(
|
|
24809
|
-
|
|
24810
|
-
}
|
|
24811
|
-
);
|
|
24872
|
+
return Object.values(axesFirstLast).some(({ xFirst, xLast, yFirst, yLast }) => {
|
|
24873
|
+
return isCloseTo(xFirst, xLast, { absoluteDiff: MAX_DECIMAL_DIFF }) || isCloseTo(yFirst, yLast, { absoluteDiff: MAX_DECIMAL_DIFF });
|
|
24874
|
+
});
|
|
24812
24875
|
};
|
|
24813
24876
|
const whiteSpacePercentage = 0.05;
|
|
24814
24877
|
const defaultRange = { min: -1, max: 1 };
|
|
@@ -24880,13 +24943,20 @@ const getAxesDataFromMetasets = (chartRef, scalesKeys, annotationsData) => {
|
|
|
24880
24943
|
}, {}));
|
|
24881
24944
|
};
|
|
24882
24945
|
const autoScale = (options, state, generatedDatasets, chartRef) => {
|
|
24883
|
-
const {
|
|
24946
|
+
const {
|
|
24947
|
+
additionalAxesOptions = {},
|
|
24948
|
+
annotations: { annotationsData = [] } = {}
|
|
24949
|
+
} = options || {};
|
|
24884
24950
|
const scales = getLineChartScales(options, state) || {};
|
|
24885
24951
|
if (!(additionalAxesOptions == null ? void 0 : additionalAxesOptions.autoAxisPadding) && !estimateDataSeriesHaveCloseValues(generatedDatasets)) {
|
|
24886
24952
|
return scales;
|
|
24887
24953
|
}
|
|
24888
24954
|
const scalesKeys = Object.keys(scales) ?? [];
|
|
24889
|
-
const data = getAxesDataFromMetasets(
|
|
24955
|
+
const data = getAxesDataFromMetasets(
|
|
24956
|
+
chartRef,
|
|
24957
|
+
scalesKeys,
|
|
24958
|
+
annotationsData
|
|
24959
|
+
);
|
|
24890
24960
|
const adjustedScales = data && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
|
|
24891
24961
|
const { min: propMin = void 0, max: propMax = void 0 } = scales[key];
|
|
24892
24962
|
const { min, max } = getSuggestedAxisRange({
|
|
@@ -24964,7 +25034,7 @@ const annotationLeave = ({ element }, { chart: chart2 }) => {
|
|
|
24964
25034
|
chart2.canvas.style.cursor = CursorStyle.Initial;
|
|
24965
25035
|
};
|
|
24966
25036
|
const generateAnnotations = (options, state) => {
|
|
24967
|
-
const { annotationsData } = options.annotations;
|
|
25037
|
+
const { annotationsData } = (options == null ? void 0 : options.annotations) || {};
|
|
24968
25038
|
const annotations = annotationsData == null ? void 0 : annotationsData.reduce((acc, curr, i2) => {
|
|
24969
25039
|
var _a2;
|
|
24970
25040
|
if (!((_a2 = state == null ? void 0 : state.showAnnotationLineIndex) == null ? void 0 : _a2.includes(i2))) {
|
|
@@ -25016,9 +25086,9 @@ const generateAnnotations = (options, state) => {
|
|
|
25016
25086
|
return annotations;
|
|
25017
25087
|
};
|
|
25018
25088
|
const getAnnotation = (options, state) => {
|
|
25019
|
-
const { showAnnotations, annotationsData } = options.annotations || {};
|
|
25089
|
+
const { showAnnotations, annotationsData } = (options == null ? void 0 : options.annotations) || {};
|
|
25020
25090
|
const shouldGenerateAnnotations = showAnnotations && (annotationsData == null ? void 0 : annotationsData.length);
|
|
25021
|
-
const annotations = shouldGenerateAnnotations ? generateAnnotations(options, state) :
|
|
25091
|
+
const annotations = shouldGenerateAnnotations ? generateAnnotations(options, state) : {};
|
|
25022
25092
|
return { annotations };
|
|
25023
25093
|
};
|
|
25024
25094
|
const getUnitsFromLabel = (label) => {
|
|
@@ -25028,12 +25098,12 @@ const getUnitsFromLabel = (label) => {
|
|
|
25028
25098
|
};
|
|
25029
25099
|
const getLineChartToolTips = (options) => {
|
|
25030
25100
|
const getTooltipLabels = (dataset) => {
|
|
25031
|
-
var _a2, _b2;
|
|
25101
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
25032
25102
|
const xIndex = ((_a2 = dataset.xAxisID) == null ? void 0 : _a2.length) > 1 ? dataset.xAxisID[1] - 1 : 0;
|
|
25033
25103
|
const yIndex = ((_b2 = dataset.yAxisID) == null ? void 0 : _b2.length) > 1 ? dataset.yAxisID[1] - 1 : 0;
|
|
25034
25104
|
const xAxis = options.axes.x[xIndex];
|
|
25035
25105
|
const yAxis = options.axes.y[yIndex];
|
|
25036
|
-
if (options.axes.x[0].position === Position.Top) {
|
|
25106
|
+
if (((_e2 = (_d2 = (_c2 = options == null ? void 0 : options.axes) == null ? void 0 : _c2.x) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.position) === Position.Top) {
|
|
25037
25107
|
return {
|
|
25038
25108
|
titleAxisLabel: (yAxis == null ? void 0 : yAxis.label) || "",
|
|
25039
25109
|
valueAxisLabel: (xAxis == null ? void 0 : xAxis.label) || "",
|
|
@@ -25126,6 +25196,7 @@ const useChartOptions = ({
|
|
|
25126
25196
|
dispatch,
|
|
25127
25197
|
generatedDatasets
|
|
25128
25198
|
}) => {
|
|
25199
|
+
var _a2, _b2;
|
|
25129
25200
|
const {
|
|
25130
25201
|
interactions: { onAnimationComplete },
|
|
25131
25202
|
annotations: {
|
|
@@ -25138,7 +25209,7 @@ const useChartOptions = ({
|
|
|
25138
25209
|
yOffset,
|
|
25139
25210
|
maxWidth,
|
|
25140
25211
|
lineHeight
|
|
25141
|
-
}
|
|
25212
|
+
} = {}
|
|
25142
25213
|
},
|
|
25143
25214
|
chartStyling: { layoutPadding }
|
|
25144
25215
|
} = options;
|
|
@@ -25167,7 +25238,7 @@ const useChartOptions = ({
|
|
|
25167
25238
|
[showAnnotationLineIndex, legendClick]
|
|
25168
25239
|
);
|
|
25169
25240
|
const legend2 = useMemo(
|
|
25170
|
-
() => getLegend(options, legendClick
|
|
25241
|
+
() => getLegend(options, legendClick),
|
|
25171
25242
|
[legendEnabled]
|
|
25172
25243
|
);
|
|
25173
25244
|
const scales = useMemo(
|
|
@@ -25182,8 +25253,8 @@ const useChartOptions = ({
|
|
|
25182
25253
|
() => ({
|
|
25183
25254
|
enabled: panEnabled,
|
|
25184
25255
|
mode: PanZoomMode.XY,
|
|
25185
|
-
onPanComplete(
|
|
25186
|
-
updateAxesRangesFromChart(
|
|
25256
|
+
onPanComplete() {
|
|
25257
|
+
updateAxesRangesFromChart();
|
|
25187
25258
|
}
|
|
25188
25259
|
}),
|
|
25189
25260
|
[panEnabled]
|
|
@@ -25198,8 +25269,8 @@ const useChartOptions = ({
|
|
|
25198
25269
|
borderColor: BORDER_COLOR,
|
|
25199
25270
|
borderWidth: 1
|
|
25200
25271
|
},
|
|
25201
|
-
onZoomComplete(
|
|
25202
|
-
updateAxesRangesFromChart(
|
|
25272
|
+
onZoomComplete() {
|
|
25273
|
+
updateAxesRangesFromChart();
|
|
25203
25274
|
}
|
|
25204
25275
|
}),
|
|
25205
25276
|
[zoomEnabled]
|
|
@@ -25211,8 +25282,8 @@ const useChartOptions = ({
|
|
|
25211
25282
|
tooltip,
|
|
25212
25283
|
legend: { ...legend2, display: false },
|
|
25213
25284
|
// hide default legend for line chart only
|
|
25214
|
-
[CUSTOM_LEGEND_PLUGIN_NAME]: options.legend.customLegend.customLegendPlugin && {
|
|
25215
|
-
containerID: options.legend.customLegend.customLegendContainerID
|
|
25285
|
+
[CUSTOM_LEGEND_PLUGIN_NAME]: ((_a2 = options.legend.customLegend) == null ? void 0 : _a2.customLegendPlugin) && {
|
|
25286
|
+
containerID: (_b2 = options.legend.customLegend) == null ? void 0 : _b2.customLegendContainerID
|
|
25216
25287
|
},
|
|
25217
25288
|
chartAreaBorder: {
|
|
25218
25289
|
borderColor: BORDER_COLOR
|
|
@@ -25236,7 +25307,7 @@ const useChartOptions = ({
|
|
|
25236
25307
|
},
|
|
25237
25308
|
onHover: onHover(hoveredPoint, setHoveredPoint),
|
|
25238
25309
|
maintainAspectRatio: options.chartStyling.maintainAspectRatio,
|
|
25239
|
-
aspectRatio: options.chartStyling.squareAspectRatio ? 1 :
|
|
25310
|
+
aspectRatio: options.chartStyling.squareAspectRatio ? 1 : 0,
|
|
25240
25311
|
animation: options.chartStyling.performanceMode ? false : {
|
|
25241
25312
|
duration: ANIMATION_DURATION.FAST,
|
|
25242
25313
|
onComplete: onAnimationComplete
|
|
@@ -25258,10 +25329,7 @@ const useChartOptions = ({
|
|
|
25258
25329
|
[state, options]
|
|
25259
25330
|
);
|
|
25260
25331
|
};
|
|
25261
|
-
const useChartPlugins = ({
|
|
25262
|
-
options,
|
|
25263
|
-
resetZoom: resetZoom2
|
|
25264
|
-
}) => {
|
|
25332
|
+
const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
|
|
25265
25333
|
const { graph, legend: legend2 } = options;
|
|
25266
25334
|
const debouncedResetZoom = useCallback(
|
|
25267
25335
|
debounce$3(() => {
|
|
@@ -25271,7 +25339,7 @@ const useChartPlugins = ({
|
|
|
25271
25339
|
[resetZoom2]
|
|
25272
25340
|
);
|
|
25273
25341
|
const handleDoubleClick = useCallback(
|
|
25274
|
-
(
|
|
25342
|
+
(_chart, args) => {
|
|
25275
25343
|
const { event } = args;
|
|
25276
25344
|
if (event.type === DOUBLE_CLICK) {
|
|
25277
25345
|
debouncedResetZoom();
|
|
@@ -25304,15 +25372,19 @@ const getAxesRangesFromChart = (chartRef, axes) => {
|
|
|
25304
25372
|
});
|
|
25305
25373
|
};
|
|
25306
25374
|
const useToggleCustomLegendVisibility = (memoState, memoOptions) => {
|
|
25375
|
+
var _a2, _b2;
|
|
25307
25376
|
useEffect(() => {
|
|
25308
|
-
|
|
25377
|
+
var _a3, _b3;
|
|
25378
|
+
if ((_b3 = (_a3 = memoOptions == null ? void 0 : memoOptions.legend) == null ? void 0 : _a3.customLegend) == null ? void 0 : _b3.customLegendPlugin) {
|
|
25309
25379
|
const parent = document.getElementById(
|
|
25310
25380
|
memoOptions.legend.customLegend.customLegendContainerID
|
|
25311
25381
|
);
|
|
25312
|
-
parent
|
|
25382
|
+
if (parent !== null) {
|
|
25383
|
+
parent.style.visibility = memoState.legendEnabled ? "visible" : "hidden";
|
|
25384
|
+
}
|
|
25313
25385
|
}
|
|
25314
25386
|
}, [
|
|
25315
|
-
memoOptions.legend.customLegend.customLegendPlugin,
|
|
25387
|
+
(_b2 = (_a2 = memoOptions == null ? void 0 : memoOptions.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendPlugin,
|
|
25316
25388
|
memoState.legendEnabled
|
|
25317
25389
|
]);
|
|
25318
25390
|
};
|
|
@@ -25329,7 +25401,7 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
|
|
|
25329
25401
|
]);
|
|
25330
25402
|
};
|
|
25331
25403
|
const useUpdateAxesRanges = (range, dispatch) => {
|
|
25332
|
-
const prevRange = useRef();
|
|
25404
|
+
const prevRange = useRef(null);
|
|
25333
25405
|
const updateAxesRanges = useCallback(() => {
|
|
25334
25406
|
if (range && range.x && range.y && !isEqual(range, prevRange.current)) {
|
|
25335
25407
|
const axes = Object.entries(range).map(([key, { min, max }]) => ({
|
|
@@ -25513,9 +25585,9 @@ const chartAreaTextPlugin = {
|
|
|
25513
25585
|
maxWidth: initialMaxWidth,
|
|
25514
25586
|
position
|
|
25515
25587
|
} = options;
|
|
25516
|
-
const { ctx, chartArea } = chart2;
|
|
25517
25588
|
if (!showLabel || !text)
|
|
25518
25589
|
return;
|
|
25590
|
+
const { ctx, chartArea } = chart2;
|
|
25519
25591
|
const maxWidth = calculateMaxWidth(initialMaxWidth, chartArea.width);
|
|
25520
25592
|
const [x2, y2] = getPositionCoordinates(position, chart2, xOffset, yOffset);
|
|
25521
25593
|
renderWrappedText(ctx, {
|
|
@@ -25593,7 +25665,7 @@ const LineChart = (props) => {
|
|
|
25593
25665
|
const { translations, languageKey } = getConfig();
|
|
25594
25666
|
const chart2 = getDefaultProps$2(props);
|
|
25595
25667
|
const {
|
|
25596
|
-
data: { datasets },
|
|
25668
|
+
data: { datasets } = { datasets: [] },
|
|
25597
25669
|
options,
|
|
25598
25670
|
testId,
|
|
25599
25671
|
persistenceId,
|
|
@@ -25651,7 +25723,7 @@ const LineChart = (props) => {
|
|
|
25651
25723
|
/* @__PURE__ */ jsx(
|
|
25652
25724
|
Controls,
|
|
25653
25725
|
{
|
|
25654
|
-
props,
|
|
25726
|
+
...props,
|
|
25655
25727
|
chartRef,
|
|
25656
25728
|
state,
|
|
25657
25729
|
options,
|
|
@@ -25676,7 +25748,6 @@ const LineChart = (props) => {
|
|
|
25676
25748
|
showCustomLegend && /* @__PURE__ */ jsx(
|
|
25677
25749
|
Legend2,
|
|
25678
25750
|
{
|
|
25679
|
-
props,
|
|
25680
25751
|
chartRef,
|
|
25681
25752
|
state,
|
|
25682
25753
|
options,
|
|
@@ -25723,84 +25794,59 @@ const styles$1 = {
|
|
|
25723
25794
|
help: help$1,
|
|
25724
25795
|
autoWeight: autoWeight$1
|
|
25725
25796
|
};
|
|
25726
|
-
const
|
|
25727
|
-
|
|
25728
|
-
|
|
25729
|
-
|
|
25730
|
-
|
|
25731
|
-
|
|
25732
|
-
|
|
25733
|
-
|
|
25734
|
-
|
|
25735
|
-
|
|
25736
|
-
|
|
25737
|
-
|
|
25738
|
-
|
|
25739
|
-
|
|
25740
|
-
|
|
25741
|
-
|
|
25742
|
-
|
|
25743
|
-
|
|
25744
|
-
|
|
25745
|
-
|
|
25746
|
-
|
|
25747
|
-
|
|
25748
|
-
const
|
|
25749
|
-
|
|
25750
|
-
|
|
25751
|
-
|
|
25752
|
-
|
|
25753
|
-
|
|
25754
|
-
|
|
25755
|
-
|
|
25797
|
+
const defaultChartStyling$1 = (styling) => ({
|
|
25798
|
+
width: styling == null ? void 0 : styling.width,
|
|
25799
|
+
height: styling == null ? void 0 : styling.height,
|
|
25800
|
+
maintainAspectRatio: (styling == null ? void 0 : styling.maintainAspectRatio) || false,
|
|
25801
|
+
staticChartHeight: (styling == null ? void 0 : styling.staticChartHeight) || false,
|
|
25802
|
+
performanceMode: (styling == null ? void 0 : styling.performanceMode) ?? true
|
|
25803
|
+
});
|
|
25804
|
+
const defaultTooltip$1 = (tooltip) => ({
|
|
25805
|
+
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
25806
|
+
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
|
|
25807
|
+
});
|
|
25808
|
+
const defaultGraph$1 = (graph) => ({
|
|
25809
|
+
showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
|
|
25810
|
+
stacked: (graph == null ? void 0 : graph.stacked) || false,
|
|
25811
|
+
cutout: (graph == null ? void 0 : graph.cutout) || 0
|
|
25812
|
+
});
|
|
25813
|
+
const defaultLegend$1 = (legend2) => ({
|
|
25814
|
+
display: (legend2 == null ? void 0 : legend2.display) ?? true,
|
|
25815
|
+
useDataset: (legend2 == null ? void 0 : legend2.useDataset) || false,
|
|
25816
|
+
position: (legend2 == null ? void 0 : legend2.position) || Position.Bottom,
|
|
25817
|
+
align: (legend2 == null ? void 0 : legend2.align) || AlignOptions.Center
|
|
25818
|
+
});
|
|
25819
|
+
const defaultChartOptions$1 = (options) => ({
|
|
25820
|
+
enableZoom: (options == null ? void 0 : options.enableZoom) || false,
|
|
25821
|
+
enablePan: (options == null ? void 0 : options.enablePan) || false
|
|
25822
|
+
});
|
|
25823
|
+
const defaultInteractions$1 = (interactions) => ({
|
|
25824
|
+
onLegendClick: interactions == null ? void 0 : interactions.onLegendClick,
|
|
25825
|
+
onHover: interactions == null ? void 0 : interactions.onHover,
|
|
25826
|
+
onUnhover: interactions == null ? void 0 : interactions.onUnhover
|
|
25827
|
+
});
|
|
25828
|
+
const defaultChartData = (data) => {
|
|
25829
|
+
return {
|
|
25830
|
+
labels: (data == null ? void 0 : data.labels) || [],
|
|
25831
|
+
datasets: (data == null ? void 0 : data.datasets) || []
|
|
25832
|
+
};
|
|
25756
25833
|
};
|
|
25757
25834
|
const getDefaultProps$1 = (props) => {
|
|
25758
|
-
|
|
25759
|
-
|
|
25760
|
-
|
|
25761
|
-
|
|
25762
|
-
|
|
25763
|
-
props.chart.options.chartOptions = props.chart.options.chartOptions || {};
|
|
25764
|
-
props.chart.options.interactions = props.chart.options.interactions || {};
|
|
25765
|
-
const chart2 = {
|
|
25766
|
-
testId: props.chart.testId ?? null,
|
|
25767
|
-
data: props.chart.data,
|
|
25835
|
+
const chart2 = (props == null ? void 0 : props.chart) || {};
|
|
25836
|
+
const options = (chart2 == null ? void 0 : chart2.options) || {};
|
|
25837
|
+
return {
|
|
25838
|
+
testId: (chart2 == null ? void 0 : chart2.testId) ?? null,
|
|
25839
|
+
data: defaultChartData(chart2 == null ? void 0 : chart2.data),
|
|
25768
25840
|
options: {
|
|
25769
|
-
title:
|
|
25770
|
-
chartStyling:
|
|
25771
|
-
|
|
25772
|
-
|
|
25773
|
-
|
|
25774
|
-
|
|
25775
|
-
|
|
25776
|
-
},
|
|
25777
|
-
tooltip: {
|
|
25778
|
-
tooltips: props.chart.options.tooltip.tooltips != null ? props.chart.options.tooltip.tooltips : true,
|
|
25779
|
-
showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false
|
|
25780
|
-
},
|
|
25781
|
-
graph: {
|
|
25782
|
-
showDataLabels: props.chart.options.graph.showDataLabels || false,
|
|
25783
|
-
stacked: props.chart.options.graph.stacked || false,
|
|
25784
|
-
cutout: props.chart.options.graph.cutout || 0
|
|
25785
|
-
},
|
|
25786
|
-
legend: {
|
|
25787
|
-
display: props.chart.options.legend.display != null ? props.chart.options.legend.display : true,
|
|
25788
|
-
useDataset: props.chart.options.legend.useDataset || false,
|
|
25789
|
-
position: props.chart.options.legend.position || "bottom",
|
|
25790
|
-
align: props.chart.options.legend.align || "center"
|
|
25791
|
-
},
|
|
25792
|
-
chartOptions: {
|
|
25793
|
-
enableZoom: props.chart.options.chartOptions.enableZoom || false,
|
|
25794
|
-
enablePan: props.chart.options.chartOptions.enablePan || false
|
|
25795
|
-
},
|
|
25796
|
-
interactions: {
|
|
25797
|
-
onLegendClick: props.chart.options.interactions.onLegendClick,
|
|
25798
|
-
onPieHover: props.chart.options.interactions.onPieHover,
|
|
25799
|
-
onPieUnhover: props.chart.options.interactions.onPieUnhover
|
|
25800
|
-
}
|
|
25841
|
+
title: (options == null ? void 0 : options.title) || "",
|
|
25842
|
+
chartStyling: defaultChartStyling$1(options == null ? void 0 : options.chartStyling),
|
|
25843
|
+
tooltip: defaultTooltip$1(options == null ? void 0 : options.tooltip),
|
|
25844
|
+
graph: defaultGraph$1(options == null ? void 0 : options.graph),
|
|
25845
|
+
legend: defaultLegend$1(options == null ? void 0 : options.legend),
|
|
25846
|
+
chartOptions: defaultChartOptions$1(options == null ? void 0 : options.chartOptions),
|
|
25847
|
+
interactions: defaultInteractions$1(options == null ? void 0 : options.interactions)
|
|
25801
25848
|
}
|
|
25802
25849
|
};
|
|
25803
|
-
return chart2;
|
|
25804
25850
|
};
|
|
25805
25851
|
Chart$2.register(
|
|
25806
25852
|
LinearScale$1,
|
|
@@ -25821,25 +25867,25 @@ const PieChart = (props) => {
|
|
|
25821
25867
|
const [pointHover, setPointHover] = useState(false);
|
|
25822
25868
|
const { data, options, testId } = chart2;
|
|
25823
25869
|
const generateDatasets = (datasets) => {
|
|
25824
|
-
const copyDataset =
|
|
25870
|
+
const copyDataset = [...datasets];
|
|
25825
25871
|
if (options.graph.stacked) {
|
|
25826
25872
|
const generatedDataset = {
|
|
25827
25873
|
label: copyDataset[0].label,
|
|
25828
25874
|
backgroundColor: [],
|
|
25829
25875
|
borderColor: [],
|
|
25830
|
-
borderWidth:
|
|
25876
|
+
borderWidth: Number(copyDataset[0].borderWidth) || 1,
|
|
25831
25877
|
data: []
|
|
25832
25878
|
};
|
|
25833
|
-
data.labels.map((
|
|
25879
|
+
data.labels.map((_label, labelIndex) => {
|
|
25834
25880
|
copyDataset.map((arc, arcIndex) => {
|
|
25835
25881
|
generatedDataset.data.push(arc.data[labelIndex]);
|
|
25836
25882
|
const { backgroundColor } = arc;
|
|
25837
25883
|
const { borderColor } = arc;
|
|
25838
25884
|
generatedDataset.backgroundColor.push(
|
|
25839
|
-
(Array.isArray(backgroundColor) ? backgroundColor[labelIndex % borderColor.length] : backgroundColor) ||
|
|
25885
|
+
(Array.isArray(backgroundColor) ? backgroundColor[labelIndex % ((borderColor == null ? void 0 : borderColor.length) || 1)] : backgroundColor) || COLORS[labelIndex] + `${99 - 10 * arcIndex}`
|
|
25840
25886
|
);
|
|
25841
25887
|
generatedDataset.borderColor.push(
|
|
25842
|
-
(Array.isArray(borderColor) ? borderColor[labelIndex % borderColor.length] : borderColor) ||
|
|
25888
|
+
(Array.isArray(borderColor) ? borderColor[labelIndex % borderColor.length] : borderColor) || COLORS[labelIndex]
|
|
25843
25889
|
);
|
|
25844
25890
|
});
|
|
25845
25891
|
});
|
|
@@ -25848,9 +25894,7 @@ const PieChart = (props) => {
|
|
|
25848
25894
|
const generatedDatasets2 = copyDataset.map(
|
|
25849
25895
|
(pieDataset, index2) => {
|
|
25850
25896
|
const borderWidth = parseFloat(pieDataset.borderWidth) || "1";
|
|
25851
|
-
const color2 = pieDataset.data.map(
|
|
25852
|
-
(_pie, i2) => colors$1[i2] || generateRandomColor()
|
|
25853
|
-
);
|
|
25897
|
+
const color2 = pieDataset.data.map((_pie, i2) => COLORS[i2]) || generateRandomColor(COLORS);
|
|
25854
25898
|
const borderColor = pieDataset.borderColor || color2;
|
|
25855
25899
|
const backgroundColor = pieDataset.backgroundColor || color2.map((col) => col + `${99 - 11 * index2}`);
|
|
25856
25900
|
return {
|
|
@@ -25870,10 +25914,10 @@ const PieChart = (props) => {
|
|
|
25870
25914
|
text: chart2.options.title
|
|
25871
25915
|
} : {};
|
|
25872
25916
|
};
|
|
25873
|
-
const legendClick = (
|
|
25917
|
+
const legendClick = (_e2, legendItem2, legend2) => {
|
|
25874
25918
|
const chartInstance = legend2.chart;
|
|
25875
25919
|
const { datasets } = chartInstance.data;
|
|
25876
|
-
const { index: index2 } = legendItem2;
|
|
25920
|
+
const { index: index2 = 0, text = "", hidden = false } = legendItem2 || {};
|
|
25877
25921
|
if (options.graph.stacked) {
|
|
25878
25922
|
if (options.legend.useDataset) {
|
|
25879
25923
|
for (let i2 = 0; i2 < chartInstance.config._config.data.datasets[0].data.length; i2++) {
|
|
@@ -25885,7 +25929,7 @@ const PieChart = (props) => {
|
|
|
25885
25929
|
}
|
|
25886
25930
|
} else {
|
|
25887
25931
|
for (let i2 = 0; i2 < chartInstance.config._config.data.datasets[0].data.length; i2++) {
|
|
25888
|
-
if (parseInt(i2 / data.datasets.length) === index2) {
|
|
25932
|
+
if (parseInt(String(i2 / data.datasets.length)) === index2) {
|
|
25889
25933
|
const meta = chartInstance.getDatasetMeta(0);
|
|
25890
25934
|
const arc = meta.data[i2];
|
|
25891
25935
|
arc.hidden = !arc.hidden;
|
|
@@ -25911,25 +25955,25 @@ const PieChart = (props) => {
|
|
|
25911
25955
|
}
|
|
25912
25956
|
}
|
|
25913
25957
|
if (options.interactions.onLegendClick)
|
|
25914
|
-
options.interactions.onLegendClick(
|
|
25958
|
+
options.interactions.onLegendClick(text, hidden);
|
|
25915
25959
|
chartInstance.update();
|
|
25916
25960
|
};
|
|
25917
|
-
const onClick = (
|
|
25961
|
+
const onClick = (_evt, _elements, chartInstance) => {
|
|
25918
25962
|
chartInstance.resetZoom();
|
|
25919
25963
|
};
|
|
25920
25964
|
const onHover = (evt, hoveredItems) => {
|
|
25921
25965
|
if (pointHover && !(hoveredItems == null ? void 0 : hoveredItems.length)) {
|
|
25922
25966
|
setPointHover(false);
|
|
25923
|
-
if (options.interactions.
|
|
25924
|
-
options.interactions.
|
|
25967
|
+
if (options.interactions.onUnhover) {
|
|
25968
|
+
options.interactions.onUnhover(evt);
|
|
25925
25969
|
}
|
|
25926
25970
|
}
|
|
25927
25971
|
if (!pointHover && (hoveredItems == null ? void 0 : hoveredItems.length)) {
|
|
25928
25972
|
setPointHover(true);
|
|
25929
|
-
if (options.interactions.
|
|
25973
|
+
if (options.interactions.onHover) {
|
|
25930
25974
|
const { index: index2, datasetIndex } = hoveredItems[0];
|
|
25931
25975
|
const generatedDataset = generatedDatasets;
|
|
25932
|
-
options.interactions.
|
|
25976
|
+
options.interactions.onHover(
|
|
25933
25977
|
evt,
|
|
25934
25978
|
datasetIndex,
|
|
25935
25979
|
index2,
|
|
@@ -25943,7 +25987,7 @@ const PieChart = (props) => {
|
|
|
25943
25987
|
display: "auto",
|
|
25944
25988
|
align: "center",
|
|
25945
25989
|
anchor: "center",
|
|
25946
|
-
formatter: (
|
|
25990
|
+
formatter: (_value, context) => {
|
|
25947
25991
|
if (context.chart.getDatasetMeta(
|
|
25948
25992
|
options.graph.stacked ? 0 : context.datasetIndex
|
|
25949
25993
|
).data[context.dataIndex].hidden)
|
|
@@ -25962,85 +26006,74 @@ const PieChart = (props) => {
|
|
|
25962
26006
|
};
|
|
25963
26007
|
};
|
|
25964
26008
|
const getLegend2 = () => {
|
|
26009
|
+
const generateLabels = (chartInstance) => {
|
|
26010
|
+
const meta = chartInstance.getDatasetMeta(0);
|
|
26011
|
+
const getStyles = (dataset, i2) => {
|
|
26012
|
+
const dataPoint = dataset.data[i2 % dataset.data.length];
|
|
26013
|
+
const { label } = dataPoint;
|
|
26014
|
+
const arc = meta.data[i2];
|
|
26015
|
+
const text = arc.hidden ? "-".repeat(label.length) : label;
|
|
26016
|
+
const backgroundColor = dataPoint == null ? void 0 : dataPoint.backgroundColor;
|
|
26017
|
+
const borderColor = dataPoint == null ? void 0 : dataPoint.borderColor;
|
|
26018
|
+
return {
|
|
26019
|
+
text,
|
|
26020
|
+
fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || COLORS[0] + `${99 - 20 * i2}`,
|
|
26021
|
+
strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || COLORS[0],
|
|
26022
|
+
index: i2
|
|
26023
|
+
};
|
|
26024
|
+
};
|
|
26025
|
+
let mappedData;
|
|
26026
|
+
if (options.graph.stacked) {
|
|
26027
|
+
if (options.legend.useDataset) {
|
|
26028
|
+
mappedData = data.datasets.map(getStyles);
|
|
26029
|
+
} else {
|
|
26030
|
+
mappedData = data.labels.map((label, i2) => {
|
|
26031
|
+
var _a2, _b2;
|
|
26032
|
+
const arc = meta.data[parseInt(String(i2 * data.datasets.length))];
|
|
26033
|
+
const text = arc.hidden ? "-".repeat(label.length) : label;
|
|
26034
|
+
const backgroundColor = (_a2 = data.datasets[0]) == null ? void 0 : _a2.backgroundColor;
|
|
26035
|
+
const borderColor = (_b2 = data.datasets[0]) == null ? void 0 : _b2.borderColor;
|
|
26036
|
+
return {
|
|
26037
|
+
text,
|
|
26038
|
+
fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || COLORS[i2] + "99",
|
|
26039
|
+
strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % ((backgroundColor == null ? void 0 : backgroundColor.length) ?? 0)] : borderColor) || COLORS[i2],
|
|
26040
|
+
index: i2
|
|
26041
|
+
};
|
|
26042
|
+
});
|
|
26043
|
+
}
|
|
26044
|
+
} else if (options.legend.useDataset) {
|
|
26045
|
+
mappedData = data.datasets.map(getStyles);
|
|
26046
|
+
} else {
|
|
26047
|
+
mappedData = data.labels.map((label, i2) => {
|
|
26048
|
+
var _a2, _b2;
|
|
26049
|
+
const arc = meta.data[i2];
|
|
26050
|
+
const text = arc.hidden ? "-".repeat(label.length) : label;
|
|
26051
|
+
const backgroundColor = (_a2 = data.datasets[0]) == null ? void 0 : _a2.backgroundColor;
|
|
26052
|
+
const borderColor = (_b2 = data.datasets[0]) == null ? void 0 : _b2.borderColor;
|
|
26053
|
+
return {
|
|
26054
|
+
text,
|
|
26055
|
+
fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || COLORS[i2] + "99",
|
|
26056
|
+
strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % ((backgroundColor == null ? void 0 : backgroundColor.length) ?? 0)] : borderColor) || COLORS[i2],
|
|
26057
|
+
index: i2
|
|
26058
|
+
};
|
|
26059
|
+
});
|
|
26060
|
+
}
|
|
26061
|
+
return mappedData;
|
|
26062
|
+
};
|
|
25965
26063
|
return {
|
|
25966
26064
|
position: options.legend.position,
|
|
25967
26065
|
display: options.legend.display,
|
|
25968
26066
|
align: options.legend.align,
|
|
25969
26067
|
labels: {
|
|
25970
|
-
generateLabels
|
|
25971
|
-
if (options.graph.stacked) {
|
|
25972
|
-
const meta = chartInstance.getDatasetMeta(0);
|
|
25973
|
-
if (options.legend.useDataset) {
|
|
25974
|
-
return data.datasets.map((data2, i2) => {
|
|
25975
|
-
var _a2, _b2;
|
|
25976
|
-
const { label } = data2.datasets[i2 % data2.datasets.length];
|
|
25977
|
-
const arc = meta.data[i2];
|
|
25978
|
-
const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
|
|
25979
|
-
const backgroundColor = (_a2 = data2.datasets[i2]) == null ? void 0 : _a2.backgroundColor;
|
|
25980
|
-
const borderColor = (_b2 = data2.datasets[i2]) == null ? void 0 : _b2.borderColor;
|
|
25981
|
-
return {
|
|
25982
|
-
text,
|
|
25983
|
-
fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || colors$1[0] + `${99 - 20 * i2}`,
|
|
25984
|
-
strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || colors$1[0],
|
|
25985
|
-
index: i2
|
|
25986
|
-
};
|
|
25987
|
-
});
|
|
25988
|
-
} else {
|
|
25989
|
-
return data.labels.map((data2, i2) => {
|
|
25990
|
-
var _a2, _b2;
|
|
25991
|
-
const label = data2.labels[i2];
|
|
25992
|
-
const arc = meta.data[parseInt(i2 * data2.datasets.length)];
|
|
25993
|
-
const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
|
|
25994
|
-
const backgroundColor = (_a2 = data2.datasets[0]) == null ? void 0 : _a2.backgroundColor;
|
|
25995
|
-
const borderColor = (_b2 = data2.datasets[0]) == null ? void 0 : _b2.borderColor;
|
|
25996
|
-
return {
|
|
25997
|
-
text,
|
|
25998
|
-
fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || colors$1[i2] + "99",
|
|
25999
|
-
strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % backgroundColor.length] : borderColor) || colors$1[i2],
|
|
26000
|
-
index: i2
|
|
26001
|
-
};
|
|
26002
|
-
});
|
|
26003
|
-
}
|
|
26004
|
-
}
|
|
26005
|
-
if (options.legend.useDataset) {
|
|
26006
|
-
return data.datasets.map((dataset, i2) => {
|
|
26007
|
-
var _a2, _b2;
|
|
26008
|
-
const meta = chartInstance.getDatasetMeta(i2);
|
|
26009
|
-
const text = meta.hidden ? dataset.label.split("").reduce((acc, curr) => acc + "-", "") : dataset.label;
|
|
26010
|
-
const backgroundColor = (_a2 = data.datasets[i2]) == null ? void 0 : _a2.backgroundColor;
|
|
26011
|
-
const borderColor = (_b2 = data.datasets[i2]) == null ? void 0 : _b2.borderColor;
|
|
26012
|
-
return {
|
|
26013
|
-
text,
|
|
26014
|
-
fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[0] : backgroundColor) || colors$1[0] + `${99 - 20 * i2}`,
|
|
26015
|
-
strokeStyle: (Array.isArray(borderColor) ? borderColor[0] : borderColor) || colors$1[0],
|
|
26016
|
-
index: i2
|
|
26017
|
-
};
|
|
26018
|
-
});
|
|
26019
|
-
} else {
|
|
26020
|
-
return data.labels.map((label, i2) => {
|
|
26021
|
-
var _a2, _b2;
|
|
26022
|
-
const meta = chartInstance.getDatasetMeta(0);
|
|
26023
|
-
const arc = meta.data[i2];
|
|
26024
|
-
const text = arc.hidden ? label.split("").reduce((acc, curr) => acc + "-", "") : label;
|
|
26025
|
-
const backgroundColor = (_a2 = data.datasets[0]) == null ? void 0 : _a2.backgroundColor;
|
|
26026
|
-
const borderColor = (_b2 = data.datasets[0]) == null ? void 0 : _b2.borderColor;
|
|
26027
|
-
return {
|
|
26028
|
-
text,
|
|
26029
|
-
fillStyle: (Array.isArray(backgroundColor) ? backgroundColor[i2 % backgroundColor.length] : backgroundColor) || colors$1[i2] + "99",
|
|
26030
|
-
strokeStyle: (Array.isArray(borderColor) ? borderColor[i2 % backgroundColor.length] : borderColor) || colors$1[i2],
|
|
26031
|
-
index: i2
|
|
26032
|
-
};
|
|
26033
|
-
});
|
|
26034
|
-
}
|
|
26035
|
-
},
|
|
26068
|
+
generateLabels,
|
|
26036
26069
|
boxHeight: 6,
|
|
26037
26070
|
boxWidth: 6,
|
|
26038
26071
|
usePointStyle: true,
|
|
26039
|
-
filter: (item
|
|
26072
|
+
filter: (item) => {
|
|
26040
26073
|
var _a2;
|
|
26041
26074
|
if (!options.legend.useDataset)
|
|
26042
26075
|
return true;
|
|
26043
|
-
return !((_a2 =
|
|
26076
|
+
return !((_a2 = data.datasets[item.index]) == null ? void 0 : _a2.hideLegend);
|
|
26044
26077
|
}
|
|
26045
26078
|
},
|
|
26046
26079
|
onClick: legendClick
|
|
@@ -26051,7 +26084,7 @@ const PieChart = (props) => {
|
|
|
26051
26084
|
callbacks: {
|
|
26052
26085
|
title: (tooltipItem) => {
|
|
26053
26086
|
const { dataIndex } = tooltipItem[0];
|
|
26054
|
-
const index2 = options.graph.stacked ? parseInt(dataIndex / data.labels.length) : dataIndex;
|
|
26087
|
+
const index2 = options.graph.stacked ? parseInt(String(dataIndex / data.labels.length)) : dataIndex;
|
|
26055
26088
|
const label = data.labels[index2];
|
|
26056
26089
|
return `${label}`;
|
|
26057
26090
|
},
|
|
@@ -26063,7 +26096,7 @@ const PieChart = (props) => {
|
|
|
26063
26096
|
const value = tooltipItem.dataset.data[dataIndex];
|
|
26064
26097
|
const labelValue = typeof value === "object" ? `${value.value || ""} ${options.tooltip.showLabelsInTooltips && value.label ? "(" + value.label + ")" : ""}` : value;
|
|
26065
26098
|
const unit = (data == null ? void 0 : data.yUnit) ? `[${data == null ? void 0 : data.yUnit}]` : "";
|
|
26066
|
-
const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue,
|
|
26099
|
+
const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, 3) : round$2(labelValue, 3);
|
|
26067
26100
|
return `${dataLabel} ${formattedValue} ${unit}`;
|
|
26068
26101
|
}
|
|
26069
26102
|
},
|
|
@@ -26105,32 +26138,14 @@ const PieChart = (props) => {
|
|
|
26105
26138
|
},
|
|
26106
26139
|
hover: {
|
|
26107
26140
|
mode: "nearest",
|
|
26108
|
-
intersect:
|
|
26141
|
+
intersect: true
|
|
26109
26142
|
},
|
|
26110
26143
|
onHover,
|
|
26111
|
-
elements: {
|
|
26112
|
-
pie: {
|
|
26113
|
-
pointStyle: "circle"
|
|
26114
|
-
}
|
|
26115
|
-
},
|
|
26116
26144
|
plugins: {
|
|
26117
26145
|
annotation: false,
|
|
26118
26146
|
// Disable globally-registered annotation plugin
|
|
26119
26147
|
title: getTitle2(),
|
|
26120
26148
|
datalabels: getDatalabels(),
|
|
26121
|
-
// zoom: {
|
|
26122
|
-
// pan: {
|
|
26123
|
-
// enabled: ,
|
|
26124
|
-
// mode: ,
|
|
26125
|
-
// },
|
|
26126
|
-
// zoom: {
|
|
26127
|
-
// drag: {
|
|
26128
|
-
// enabled:,
|
|
26129
|
-
// },
|
|
26130
|
-
// mode: ,
|
|
26131
|
-
// speed: ,
|
|
26132
|
-
// },
|
|
26133
|
-
// },
|
|
26134
26149
|
tooltip: getToolTips(),
|
|
26135
26150
|
legend: getLegend2()
|
|
26136
26151
|
}
|
|
@@ -38516,93 +38531,102 @@ const styles = {
|
|
|
38516
38531
|
help,
|
|
38517
38532
|
autoWeight
|
|
38518
38533
|
};
|
|
38534
|
+
const defaultAxes = (axes) => ({
|
|
38535
|
+
x: (axes == null ? void 0 : axes.x) || [{}],
|
|
38536
|
+
y: (axes == null ? void 0 : axes.y) || [{}]
|
|
38537
|
+
});
|
|
38538
|
+
const defaultAdditionalAxesOptions = (options) => ({
|
|
38539
|
+
chartScaleType: (options == null ? void 0 : options.chartScaleType) || "linear",
|
|
38540
|
+
reverse: (options == null ? void 0 : options.reverse) || false,
|
|
38541
|
+
stacked: (options == null ? void 0 : options.stacked) || false,
|
|
38542
|
+
beginAtZero: (options == null ? void 0 : options.beginAtZero) ?? true,
|
|
38543
|
+
stepSize: options == null ? void 0 : options.stepSize,
|
|
38544
|
+
suggestedMin: options == null ? void 0 : options.suggestedMin,
|
|
38545
|
+
suggestedMax: options == null ? void 0 : options.suggestedMax,
|
|
38546
|
+
min: options == null ? void 0 : options.min,
|
|
38547
|
+
max: options == null ? void 0 : options.max
|
|
38548
|
+
});
|
|
38549
|
+
const defaultChartStyling = (styling) => ({
|
|
38550
|
+
width: styling == null ? void 0 : styling.width,
|
|
38551
|
+
height: styling == null ? void 0 : styling.height,
|
|
38552
|
+
maintainAspectRatio: (styling == null ? void 0 : styling.maintainAspectRatio) || false,
|
|
38553
|
+
staticChartHeight: (styling == null ? void 0 : styling.staticChartHeight) || false,
|
|
38554
|
+
performanceMode: (styling == null ? void 0 : styling.performanceMode) ?? true
|
|
38555
|
+
});
|
|
38556
|
+
const defaultTooltip = (tooltip) => ({
|
|
38557
|
+
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
38558
|
+
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
|
|
38559
|
+
});
|
|
38560
|
+
const defaultGraph = (graph) => ({
|
|
38561
|
+
showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
|
|
38562
|
+
showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) || false
|
|
38563
|
+
});
|
|
38564
|
+
const defaultAnnotations = (annotations) => ({
|
|
38565
|
+
showAnnotations: (annotations == null ? void 0 : annotations.showAnnotations) ?? true,
|
|
38566
|
+
controlAnnotation: (annotations == null ? void 0 : annotations.controlAnnotation) || false,
|
|
38567
|
+
annotationsData: (annotations == null ? void 0 : annotations.annotationsData) || []
|
|
38568
|
+
});
|
|
38569
|
+
const defaultLegend = (legend2) => ({
|
|
38570
|
+
display: (legend2 == null ? void 0 : legend2.display) ?? true,
|
|
38571
|
+
position: (legend2 == null ? void 0 : legend2.position) || Position.Bottom,
|
|
38572
|
+
align: (legend2 == null ? void 0 : legend2.align) || AlignOptions.Center,
|
|
38573
|
+
customLegend: (legend2 == null ? void 0 : legend2.customLegend) || {
|
|
38574
|
+
customLegendPlugin: null,
|
|
38575
|
+
customLegendContainerID: ""
|
|
38576
|
+
}
|
|
38577
|
+
});
|
|
38578
|
+
const defaultChartOptions = (options) => ({
|
|
38579
|
+
enableZoom: (options == null ? void 0 : options.enableZoom) || false,
|
|
38580
|
+
enablePan: (options == null ? void 0 : options.enablePan) || false
|
|
38581
|
+
});
|
|
38582
|
+
const defaultInteractions = (interactions) => ({
|
|
38583
|
+
onLegendClick: interactions == null ? void 0 : interactions.onLegendClick,
|
|
38584
|
+
onHover: interactions == null ? void 0 : interactions.onHover,
|
|
38585
|
+
onUnhover: interactions == null ? void 0 : interactions.onUnhover
|
|
38586
|
+
});
|
|
38587
|
+
const defaultDragData = (dragData) => ({
|
|
38588
|
+
enableDragData: (dragData == null ? void 0 : dragData.enableDragData) || false,
|
|
38589
|
+
showTooltip: (dragData == null ? void 0 : dragData.showTooltip) ?? true,
|
|
38590
|
+
roundPoints: (dragData == null ? void 0 : dragData.roundPoints) ?? true,
|
|
38591
|
+
dragX: (dragData == null ? void 0 : dragData.dragX) ?? true,
|
|
38592
|
+
dragY: (dragData == null ? void 0 : dragData.dragY) ?? true,
|
|
38593
|
+
onDragStart: dragData == null ? void 0 : dragData.onDragStart,
|
|
38594
|
+
onDrag: dragData == null ? void 0 : dragData.onDrag,
|
|
38595
|
+
onDragEnd: dragData == null ? void 0 : dragData.onDragEnd
|
|
38596
|
+
});
|
|
38519
38597
|
const getDefaultProps = (props) => {
|
|
38520
|
-
|
|
38521
|
-
|
|
38522
|
-
|
|
38523
|
-
|
|
38524
|
-
|
|
38525
|
-
props.chart.options.graph = props.chart.options.graph || {};
|
|
38526
|
-
props.chart.options.annotations = props.chart.options.annotations || {};
|
|
38527
|
-
props.chart.options.legend = props.chart.options.legend || {};
|
|
38528
|
-
props.chart.options.legend.customLegend = props.chart.options.legend.customLegend || { customLegendPlugin: null, customLegendContainerID: "" };
|
|
38529
|
-
props.chart.options.chartOptions = props.chart.options.chartOptions || {};
|
|
38530
|
-
props.chart.options.interactions = props.chart.options.interactions || {};
|
|
38531
|
-
props.chart.options.dragData = props.chart.options.dragData || {};
|
|
38532
|
-
const chart2 = {
|
|
38533
|
-
testId: props.chart.testId ?? null,
|
|
38534
|
-
data: props.chart.data,
|
|
38598
|
+
const chart2 = (props == null ? void 0 : props.chart) || {};
|
|
38599
|
+
const options = (chart2 == null ? void 0 : chart2.options) || {};
|
|
38600
|
+
return {
|
|
38601
|
+
testId: (chart2 == null ? void 0 : chart2.testId) ?? "",
|
|
38602
|
+
data: chart2 == null ? void 0 : chart2.data,
|
|
38535
38603
|
options: {
|
|
38536
|
-
title:
|
|
38537
|
-
direction:
|
|
38538
|
-
axes:
|
|
38539
|
-
|
|
38540
|
-
|
|
38541
|
-
|
|
38542
|
-
|
|
38543
|
-
|
|
38544
|
-
|
|
38545
|
-
|
|
38546
|
-
|
|
38547
|
-
|
|
38548
|
-
|
|
38549
|
-
|
|
38550
|
-
|
|
38551
|
-
|
|
38552
|
-
|
|
38553
|
-
|
|
38554
|
-
|
|
38555
|
-
|
|
38556
|
-
|
|
38557
|
-
|
|
38558
|
-
|
|
38559
|
-
|
|
38560
|
-
tooltip: {
|
|
38561
|
-
tooltips: props.chart.options.tooltip.tooltips != null ? props.chart.options.tooltip.tooltips : true,
|
|
38562
|
-
showLabelsInTooltips: props.chart.options.tooltip.showLabelsInTooltips || false
|
|
38563
|
-
},
|
|
38564
|
-
graph: {
|
|
38565
|
-
showDataLabels: props.chart.options.graph.showDataLabels || false,
|
|
38566
|
-
showMinorGridlines: props.chart.options.graph.showMinorGridlines || false
|
|
38567
|
-
},
|
|
38568
|
-
annotations: {
|
|
38569
|
-
showAnnotations: props.chart.options.annotations.showAnnotations != null ? props.chart.options.annotations.showAnnotations : true,
|
|
38570
|
-
controlAnnotation: props.chart.options.annotations.controlAnnotation || false,
|
|
38571
|
-
annotationsData: props.chart.options.annotations.annotationsData || []
|
|
38572
|
-
},
|
|
38573
|
-
legend: {
|
|
38574
|
-
display: props.chart.options.legend.display != null ? props.chart.options.legend.display : true,
|
|
38575
|
-
position: props.chart.options.legend.position || "bottom",
|
|
38576
|
-
align: props.chart.options.legend.align || "center",
|
|
38577
|
-
customLegend: props.chart.options.legend.customLegend
|
|
38578
|
-
},
|
|
38579
|
-
chartOptions: {
|
|
38580
|
-
enableZoom: props.chart.options.chartOptions.enableZoom || false,
|
|
38581
|
-
enablePan: props.chart.options.chartOptions.enablePan || false
|
|
38582
|
-
},
|
|
38583
|
-
interactions: {
|
|
38584
|
-
onLegendClick: props.chart.options.interactions.onLegendClick,
|
|
38585
|
-
onBarHover: props.chart.options.interactions.onBarHover,
|
|
38586
|
-
onBarUnhover: props.chart.options.interactions.onBarUnhover
|
|
38587
|
-
},
|
|
38588
|
-
dragData: {
|
|
38589
|
-
enableDragData: props.chart.options.dragData.enableDragData || false,
|
|
38590
|
-
showTooltip: props.chart.options.dragData.showTooltip || true,
|
|
38591
|
-
roundPoints: props.chart.options.dragData.roundPoints || true,
|
|
38592
|
-
dragX: props.chart.options.dragData.dragX || true,
|
|
38593
|
-
dragY: props.chart.options.dragData.dragY || true,
|
|
38594
|
-
onDragStart: props.chart.options.dragData.onDragStart,
|
|
38595
|
-
onDrag: props.chart.options.dragData.onDrag,
|
|
38596
|
-
onDragEnd: props.chart.options.dragData.onDragEnd
|
|
38597
|
-
}
|
|
38598
|
-
}
|
|
38599
|
-
};
|
|
38600
|
-
return chart2;
|
|
38601
|
-
};
|
|
38602
|
-
const getBarChartAxis = (chart2, axisType, currentScales, i2) => {
|
|
38603
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
|
|
38604
|
+
title: (options == null ? void 0 : options.title) || "",
|
|
38605
|
+
direction: (options == null ? void 0 : options.direction) || "vertical",
|
|
38606
|
+
axes: defaultAxes(options == null ? void 0 : options.axes),
|
|
38607
|
+
additionalAxesOptions: defaultAdditionalAxesOptions(
|
|
38608
|
+
options == null ? void 0 : options.additionalAxesOptions
|
|
38609
|
+
),
|
|
38610
|
+
chartStyling: defaultChartStyling(options == null ? void 0 : options.chartStyling),
|
|
38611
|
+
tooltip: defaultTooltip(options == null ? void 0 : options.tooltip),
|
|
38612
|
+
graph: defaultGraph(options == null ? void 0 : options.graph),
|
|
38613
|
+
annotations: defaultAnnotations(options == null ? void 0 : options.annotations),
|
|
38614
|
+
legend: defaultLegend(options == null ? void 0 : options.legend),
|
|
38615
|
+
chartOptions: defaultChartOptions(options == null ? void 0 : options.chartOptions),
|
|
38616
|
+
interactions: defaultInteractions(options == null ? void 0 : options.interactions),
|
|
38617
|
+
dragData: defaultDragData(options == null ? void 0 : options.dragData)
|
|
38618
|
+
}
|
|
38619
|
+
};
|
|
38620
|
+
};
|
|
38621
|
+
const getBarChartAxis = ({
|
|
38622
|
+
chart: chart2,
|
|
38623
|
+
axisType = AxisType.X,
|
|
38624
|
+
currentScale,
|
|
38625
|
+
i: i2
|
|
38626
|
+
}) => {
|
|
38627
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
38604
38628
|
const isDirectionVertical = isVertical(chart2.options.direction);
|
|
38605
|
-
const axisData =
|
|
38629
|
+
const axisData = currentScale || chart2.options.axes[axisType][0];
|
|
38606
38630
|
const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
|
|
38607
38631
|
const grid = (axisData == null ? void 0 : axisData.gridLines) || {};
|
|
38608
38632
|
const getScaleType = () => {
|
|
@@ -38623,7 +38647,7 @@ const getBarChartAxis = (chart2, axisType, currentScales, i2) => {
|
|
|
38623
38647
|
return isLogarithmic ? LOGARITHMIC_STEPS.includes(tick) ? formatAxisLabelNumbers(tick, ticks2) : "" : formatAxisLabelNumbers(tick, ticks2);
|
|
38624
38648
|
};
|
|
38625
38649
|
const stepSize = !isLogarithmic ? {
|
|
38626
|
-
stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions.stepSize : null)
|
|
38650
|
+
stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions == null ? void 0 : additionalAxesOptions.stepSize : null)
|
|
38627
38651
|
} : {};
|
|
38628
38652
|
const ticks = {
|
|
38629
38653
|
...stepSize,
|
|
@@ -38639,56 +38663,68 @@ const getBarChartAxis = (chart2, axisType, currentScales, i2) => {
|
|
|
38639
38663
|
};
|
|
38640
38664
|
return {
|
|
38641
38665
|
type: getScaleType(),
|
|
38642
|
-
position: axisData.position,
|
|
38643
|
-
beginAtZero: chart2.options.additionalAxesOptions.beginAtZero,
|
|
38666
|
+
position: axisData == null ? void 0 : axisData.position,
|
|
38667
|
+
beginAtZero: (_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.additionalAxesOptions) == null ? void 0 : _b2.beginAtZero,
|
|
38644
38668
|
reverse: getReverse(),
|
|
38645
|
-
suggestedMax: (
|
|
38646
|
-
suggestedMin: (
|
|
38647
|
-
min: isDirectionCompatibleWithAxisType ? (
|
|
38648
|
-
max: isDirectionCompatibleWithAxisType ? (
|
|
38669
|
+
suggestedMax: (_d2 = (_c2 = chart2.options) == null ? void 0 : _c2.additionalAxesOptions) == null ? void 0 : _d2.suggestedMax,
|
|
38670
|
+
suggestedMin: (_f2 = (_e2 = chart2.options) == null ? void 0 : _e2.additionalAxesOptions) == null ? void 0 : _f2.suggestedMin,
|
|
38671
|
+
min: isDirectionCompatibleWithAxisType ? (_h2 = (_g2 = chart2.options) == null ? void 0 : _g2.additionalAxesOptions) == null ? void 0 : _h2.min : void 0,
|
|
38672
|
+
max: isDirectionCompatibleWithAxisType ? (_j2 = (_i2 = chart2.options) == null ? void 0 : _i2.additionalAxesOptions) == null ? void 0 : _j2.max : void 0,
|
|
38649
38673
|
title: {
|
|
38650
|
-
display: ((
|
|
38651
|
-
text: axisData.label || axisData.unit,
|
|
38674
|
+
display: ((_k2 = axisData == null ? void 0 : axisData.label) == null ? void 0 : _k2.length) || ((_l2 = axisData == null ? void 0 : axisData.unit) == null ? void 0 : _l2.length),
|
|
38675
|
+
text: (axisData == null ? void 0 : axisData.label) || (axisData == null ? void 0 : axisData.unit),
|
|
38652
38676
|
padding: 0
|
|
38653
38677
|
},
|
|
38654
38678
|
ticks: getTicks(),
|
|
38655
38679
|
grid: {
|
|
38656
38680
|
...grid
|
|
38657
38681
|
},
|
|
38658
|
-
stacked: chart2.options.additionalAxesOptions.stacked
|
|
38682
|
+
stacked: (_n2 = (_m2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _m2.additionalAxesOptions) == null ? void 0 : _n2.stacked
|
|
38659
38683
|
};
|
|
38660
38684
|
};
|
|
38661
38685
|
const getBarChartAxes = (chart2, axisType) => {
|
|
38662
|
-
|
|
38663
|
-
const
|
|
38664
|
-
|
|
38665
|
-
|
|
38666
|
-
|
|
38667
|
-
|
|
38668
|
-
|
|
38669
|
-
|
|
38670
|
-
|
|
38671
|
-
|
|
38686
|
+
var _a2, _b2;
|
|
38687
|
+
const axesData = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.axes) == null ? void 0 : _b2[axisType]) || [];
|
|
38688
|
+
const axes = axesData.reduce(
|
|
38689
|
+
(acc, curr, i2) => {
|
|
38690
|
+
const axisData = curr;
|
|
38691
|
+
const color2 = curr.color || COLORS[i2] || generateRandomColor(COLORS);
|
|
38692
|
+
axisData.color = color2;
|
|
38693
|
+
axisData.position = curr.position || getAxisPosition(axisType, i2);
|
|
38694
|
+
const axis = getBarChartAxis({ chart: chart2, axisType, currentScale: axisData });
|
|
38695
|
+
const axisId = i2 === 0 ? axisType : `${axisType}${i2 + 1}`;
|
|
38696
|
+
return { ...acc, [axisId]: axis };
|
|
38697
|
+
},
|
|
38698
|
+
{}
|
|
38699
|
+
);
|
|
38672
38700
|
return axes;
|
|
38673
38701
|
};
|
|
38674
38702
|
const getBarChartScales = (chart2) => {
|
|
38675
38703
|
var _a2, _b2;
|
|
38676
38704
|
const hasMultipleXAxes = ((_a2 = chart2.options.axes.x) == null ? void 0 : _a2.length) > 1;
|
|
38677
38705
|
const hasMultipleYAxes = ((_b2 = chart2.options.axes.y) == null ? void 0 : _b2.length) > 1;
|
|
38678
|
-
const xAxesScales = hasMultipleXAxes ? getBarChartAxes(chart2, AxisType.X) : { x: getBarChartAxis(chart2, AxisType.X) };
|
|
38679
|
-
const yAxesScales = hasMultipleYAxes ? getBarChartAxes(chart2, AxisType.Y) : { y: getBarChartAxis(chart2, AxisType.Y) };
|
|
38706
|
+
const xAxesScales = hasMultipleXAxes ? getBarChartAxes(chart2, AxisType.X) : { x: getBarChartAxis({ chart: chart2, axisType: AxisType.X }) };
|
|
38707
|
+
const yAxesScales = hasMultipleYAxes ? getBarChartAxes(chart2, AxisType.Y) : { y: getBarChartAxis({ chart: chart2, axisType: AxisType.Y }) };
|
|
38680
38708
|
return {
|
|
38681
38709
|
...xAxesScales,
|
|
38682
38710
|
...yAxesScales
|
|
38683
38711
|
};
|
|
38684
38712
|
};
|
|
38685
38713
|
const getBarChartToolTips = (options) => {
|
|
38714
|
+
var _a2;
|
|
38686
38715
|
const getTooltipLabels = (dataset) => {
|
|
38687
|
-
var
|
|
38716
|
+
var _a3, _b2;
|
|
38688
38717
|
const isDirectionVertical = isVertical(options.direction);
|
|
38689
|
-
const
|
|
38690
|
-
const
|
|
38691
|
-
const
|
|
38718
|
+
const x2 = ((_a3 = options.axes) == null ? void 0 : _a3.x) || [];
|
|
38719
|
+
const y2 = ((_b2 = options.axes) == null ? void 0 : _b2.y) || [];
|
|
38720
|
+
const getAxisIndex = (axisID) => {
|
|
38721
|
+
if (!axisID)
|
|
38722
|
+
return 0;
|
|
38723
|
+
const match = axisID.match(/\d+$/);
|
|
38724
|
+
return match ? parseInt(match[0], 10) - 1 : 0;
|
|
38725
|
+
};
|
|
38726
|
+
const xIndex = getAxisIndex(dataset == null ? void 0 : dataset.xAxisID);
|
|
38727
|
+
const yIndex = getAxisIndex(dataset == null ? void 0 : dataset.yAxisID);
|
|
38692
38728
|
const xAxis = isDirectionVertical ? x2[xIndex] : y2[yIndex];
|
|
38693
38729
|
const yAxis = isDirectionVertical ? y2[yIndex] : x2[xIndex];
|
|
38694
38730
|
return {
|
|
@@ -38700,18 +38736,18 @@ const getBarChartToolTips = (options) => {
|
|
|
38700
38736
|
valueUnit: (yAxis == null ? void 0 : yAxis.unit) || ""
|
|
38701
38737
|
};
|
|
38702
38738
|
};
|
|
38703
|
-
const titleCallback = (
|
|
38704
|
-
var
|
|
38705
|
-
const barLabel = ((
|
|
38706
|
-
const labels = getTooltipLabels(
|
|
38739
|
+
const titleCallback = (tooltipItems, _data) => {
|
|
38740
|
+
var _a3, _b2;
|
|
38741
|
+
const barLabel = ((_a3 = tooltipItems == null ? void 0 : tooltipItems[0]) == null ? void 0 : _a3.label) || "";
|
|
38742
|
+
const labels = getTooltipLabels((_b2 = tooltipItems == null ? void 0 : tooltipItems[0]) == null ? void 0 : _b2.dataset);
|
|
38707
38743
|
const { titleAxisLabel, titleUnit } = labels;
|
|
38708
38744
|
const axisLabel = !titleAxisLabel && !titleUnit ? "" : `${titleAxisLabel || titleUnit}: `;
|
|
38709
38745
|
return axisLabel + barLabel;
|
|
38710
38746
|
};
|
|
38711
38747
|
const labelCallback = (tooltipItem) => {
|
|
38712
|
-
var
|
|
38713
|
-
const { showLabelsInTooltips } = options.tooltip;
|
|
38714
|
-
let label = ((
|
|
38748
|
+
var _a3;
|
|
38749
|
+
const { showLabelsInTooltips = false } = (options == null ? void 0 : options.tooltip) || {};
|
|
38750
|
+
let label = ((_a3 = tooltipItem.dataset) == null ? void 0 : _a3.label) || "";
|
|
38715
38751
|
const labels = getTooltipLabels(tooltipItem.dataset);
|
|
38716
38752
|
const { valueUnit, valueAxisLabel } = labels;
|
|
38717
38753
|
const getTooltipItemValue = () => {
|
|
@@ -38729,9 +38765,12 @@ const getBarChartToolTips = (options) => {
|
|
|
38729
38765
|
tooltipItemValue2 = labelNumberFormatted;
|
|
38730
38766
|
}
|
|
38731
38767
|
if (Array.isArray(tooltipItem.raw)) {
|
|
38732
|
-
tooltipItemValue2 = tooltipItem.raw.reduce(
|
|
38733
|
-
|
|
38734
|
-
|
|
38768
|
+
tooltipItemValue2 = tooltipItem.raw.reduce(
|
|
38769
|
+
(acc, curr, i2) => {
|
|
38770
|
+
return i2 === 0 ? `${acc} ${curr}` : `${acc}, ${curr}`;
|
|
38771
|
+
},
|
|
38772
|
+
""
|
|
38773
|
+
);
|
|
38735
38774
|
}
|
|
38736
38775
|
if (typeof tooltipItem.raw === "object") {
|
|
38737
38776
|
tooltipItemValue2 = formattedValue;
|
|
@@ -38746,7 +38785,7 @@ const getBarChartToolTips = (options) => {
|
|
|
38746
38785
|
return `${label}: ${tooltipItemValue} ${unit}${valAxisLabel}${tooltipLabel}`;
|
|
38747
38786
|
};
|
|
38748
38787
|
return {
|
|
38749
|
-
enabled: options.tooltip.tooltips,
|
|
38788
|
+
enabled: (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.tooltips,
|
|
38750
38789
|
mode: ChartHoverMode.Nearest,
|
|
38751
38790
|
intersect: true,
|
|
38752
38791
|
padding: TOOLTIP_PADDING,
|
|
@@ -38761,9 +38800,11 @@ const getBarChartToolTips = (options) => {
|
|
|
38761
38800
|
};
|
|
38762
38801
|
};
|
|
38763
38802
|
const getBarChartDataLabels = (options) => {
|
|
38764
|
-
|
|
38765
|
-
const
|
|
38766
|
-
|
|
38803
|
+
var _a2;
|
|
38804
|
+
const { beginAtZero, reverse } = (options == null ? void 0 : options.additionalAxesOptions) || {};
|
|
38805
|
+
const formatterCallback = (_value, context) => {
|
|
38806
|
+
const { datasetIndex, dataIndex } = context;
|
|
38807
|
+
const dataset = context.chart.data.datasets[datasetIndex];
|
|
38767
38808
|
const dataElement = dataset.data[dataIndex];
|
|
38768
38809
|
let dataLabel = "";
|
|
38769
38810
|
if (typeof dataElement === "number") {
|
|
@@ -38778,7 +38819,7 @@ const getBarChartDataLabels = (options) => {
|
|
|
38778
38819
|
};
|
|
38779
38820
|
const beginAtNotZeroAlign = reverse ? AlignOptions.End : AlignOptions.Start;
|
|
38780
38821
|
const beginAtNotZeroAnchor = reverse ? AlignOptions.Start : AlignOptions.End;
|
|
38781
|
-
return options.graph.showDataLabels ? {
|
|
38822
|
+
return ((_a2 = options == null ? void 0 : options.graph) == null ? void 0 : _a2.showDataLabels) ? {
|
|
38782
38823
|
display: AUTO,
|
|
38783
38824
|
align: beginAtZero ? AlignOptions.Center : beginAtNotZeroAlign,
|
|
38784
38825
|
anchor: beginAtZero ? AlignOptions.Center : beginAtNotZeroAnchor,
|
|
@@ -38800,6 +38841,7 @@ Chart$2.register(
|
|
|
38800
38841
|
Ht
|
|
38801
38842
|
);
|
|
38802
38843
|
const BarChart = (props) => {
|
|
38844
|
+
var _a2, _b2, _c2;
|
|
38803
38845
|
setDefaultTheme();
|
|
38804
38846
|
const chartRef = useRef(null);
|
|
38805
38847
|
const [pointHover, setPointHover] = useState(false);
|
|
@@ -38810,42 +38852,44 @@ const BarChart = (props) => {
|
|
|
38810
38852
|
setAnnotations(annotations.annotationsData)
|
|
38811
38853
|
);
|
|
38812
38854
|
const generateBarChartDatasets = (datasets) => {
|
|
38813
|
-
var
|
|
38855
|
+
var _a3;
|
|
38814
38856
|
const barDatasetsCopy = [...datasets];
|
|
38815
|
-
if (annotations.controlAnnotation && annotations.showAnnotations && ((
|
|
38816
|
-
annotations.annotationsData.forEach(
|
|
38817
|
-
|
|
38818
|
-
|
|
38819
|
-
|
|
38820
|
-
|
|
38821
|
-
|
|
38822
|
-
|
|
38823
|
-
|
|
38824
|
-
|
|
38825
|
-
|
|
38826
|
-
|
|
38857
|
+
if (annotations.controlAnnotation && annotations.showAnnotations && ((_a3 = annotations.annotationsData) == null ? void 0 : _a3.length)) {
|
|
38858
|
+
annotations.annotationsData.forEach(
|
|
38859
|
+
(annotation2, index2) => {
|
|
38860
|
+
barDatasetsCopy.push({
|
|
38861
|
+
isAnnotation: true,
|
|
38862
|
+
label: annotation2.label,
|
|
38863
|
+
annotationIndex: index2,
|
|
38864
|
+
backgroundColor: annotation2.color || COLORS[index2],
|
|
38865
|
+
borderColor: annotation2.color || COLORS[index2],
|
|
38866
|
+
data: [],
|
|
38867
|
+
type: ChartType.Bar
|
|
38868
|
+
});
|
|
38869
|
+
}
|
|
38870
|
+
);
|
|
38827
38871
|
}
|
|
38828
38872
|
const generatedDatasets2 = barDatasetsCopy.map((barDataset, index2) => {
|
|
38829
38873
|
const colorSchema = COLORS;
|
|
38830
38874
|
const colors2 = barDataset.data.map((_2, i2) => {
|
|
38831
38875
|
const colorSelectionIndex = datasets.length > 1 ? index2 : i2;
|
|
38832
|
-
return colorSchema[colorSelectionIndex] || generateRandomColor
|
|
38876
|
+
return colorSchema[colorSelectionIndex] || generateRandomColor(COLORS);
|
|
38833
38877
|
});
|
|
38834
38878
|
const backgroundColors = barDataset.backgroundColor || colors2.map((color2) => color2 + ALPHA_CHANEL);
|
|
38835
38879
|
return {
|
|
38836
38880
|
...barDataset,
|
|
38837
|
-
borderWidth: parseFloat(barDataset.borderWidth)
|
|
38838
|
-
borderColor: barDataset.borderColor || colors2,
|
|
38881
|
+
borderWidth: parseFloat(String(barDataset.borderWidth)) ?? 1,
|
|
38882
|
+
borderColor: barDataset.borderColor || colors2[index2],
|
|
38839
38883
|
backgroundColor: backgroundColors
|
|
38840
38884
|
};
|
|
38841
38885
|
});
|
|
38842
|
-
return generatedDatasets2;
|
|
38886
|
+
return generatedDatasets2 || [];
|
|
38843
38887
|
};
|
|
38844
|
-
const generatedDatasets = generateBarChartDatasets(chart2.data.datasets);
|
|
38845
|
-
const legendClick = (
|
|
38846
|
-
const index2 = legendItem2.datasetIndex;
|
|
38888
|
+
const generatedDatasets = generateBarChartDatasets((_a2 = chart2 == null ? void 0 : chart2.data) == null ? void 0 : _a2.datasets);
|
|
38889
|
+
const legendClick = (_e2, legendItem2) => {
|
|
38890
|
+
const index2 = (legendItem2 == null ? void 0 : legendItem2.datasetIndex) ?? null;
|
|
38847
38891
|
const chartInstance = chartRef.current;
|
|
38848
|
-
if (chartInstance) {
|
|
38892
|
+
if (chartInstance && index2 !== null) {
|
|
38849
38893
|
const { datasets } = chartInstance.data;
|
|
38850
38894
|
const dataset = datasets[index2];
|
|
38851
38895
|
const meta = chartInstance.getDatasetMeta(index2);
|
|
@@ -38872,27 +38916,30 @@ const BarChart = (props) => {
|
|
|
38872
38916
|
});
|
|
38873
38917
|
}
|
|
38874
38918
|
if (interactions.onLegendClick) {
|
|
38875
|
-
interactions.onLegendClick(
|
|
38919
|
+
interactions.onLegendClick(
|
|
38920
|
+
legendItem2 == null ? void 0 : legendItem2.text,
|
|
38921
|
+
(legendItem2 == null ? void 0 : legendItem2.hidden) ?? false
|
|
38922
|
+
);
|
|
38876
38923
|
}
|
|
38877
38924
|
chartInstance.update();
|
|
38878
38925
|
}
|
|
38879
38926
|
};
|
|
38880
|
-
const onClick = (
|
|
38927
|
+
const onClick = (_evt, _elements, chartInstance) => {
|
|
38881
38928
|
chartInstance.resetZoom();
|
|
38882
38929
|
};
|
|
38883
|
-
const onHover = (evt, hoveredItems
|
|
38930
|
+
const onHover = (evt, hoveredItems) => {
|
|
38884
38931
|
if (pointHover && !(hoveredItems == null ? void 0 : hoveredItems.length)) {
|
|
38885
38932
|
setPointHover(false);
|
|
38886
|
-
if (interactions.
|
|
38887
|
-
interactions.
|
|
38933
|
+
if (interactions.onUnhover) {
|
|
38934
|
+
interactions.onUnhover(evt);
|
|
38888
38935
|
}
|
|
38889
38936
|
}
|
|
38890
38937
|
if (!pointHover && (hoveredItems == null ? void 0 : hoveredItems.length)) {
|
|
38891
38938
|
setPointHover(true);
|
|
38892
|
-
if (interactions.
|
|
38939
|
+
if (interactions.onHover) {
|
|
38893
38940
|
const { index: index2, datasetIndex } = hoveredItems[0];
|
|
38894
38941
|
const generatedDataset = generatedDatasets;
|
|
38895
|
-
interactions.
|
|
38942
|
+
interactions.onHover(evt, datasetIndex, index2, generatedDataset);
|
|
38896
38943
|
}
|
|
38897
38944
|
}
|
|
38898
38945
|
};
|
|
@@ -38910,7 +38957,7 @@ const BarChart = (props) => {
|
|
|
38910
38957
|
{
|
|
38911
38958
|
ref: chartRef,
|
|
38912
38959
|
data: {
|
|
38913
|
-
labels: chart2.data.labels.length ? chart2.data.labels : [""],
|
|
38960
|
+
labels: ((_c2 = (_b2 = chart2 == null ? void 0 : chart2.data) == null ? void 0 : _b2.labels) == null ? void 0 : _c2.length) ? chart2.data.labels : [""],
|
|
38914
38961
|
datasets: generatedDatasets
|
|
38915
38962
|
},
|
|
38916
38963
|
options: {
|
|
@@ -38925,9 +38972,9 @@ const BarChart = (props) => {
|
|
|
38925
38972
|
mode: ChartHoverMode.Nearest,
|
|
38926
38973
|
intersect: true
|
|
38927
38974
|
},
|
|
38928
|
-
elements: {
|
|
38929
|
-
|
|
38930
|
-
},
|
|
38975
|
+
// elements: {
|
|
38976
|
+
// bar: { pointStyle: PointStyle.Circle },
|
|
38977
|
+
// },
|
|
38931
38978
|
scales: getBarChartScales(chart2),
|
|
38932
38979
|
plugins: {
|
|
38933
38980
|
title: getTitle(options),
|