@oliasoft-open-source/charts-library 5.0.8-beta-2 → 5.0.9
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/assets/{Color-YHDXOIA2-4v8Ep5yA.js → Color-YHDXOIA2-Cf20dAz7.js} +1 -1
- package/dist/assets/{DocsRenderer-CFRXHY34-DuvngF7q.js → DocsRenderer-CFRXHY34-BLg8W1W2.js} +3 -3
- package/dist/assets/{bar-chart.stories-BtoqoUxl.js → bar-chart.stories-BYQyquXm.js} +1 -1
- package/dist/assets/{entry-preview-CuUmUEeH.js → entry-preview-BZo_8q_9.js} +1 -1
- package/dist/assets/{get-draggableData-DpL-PCw1.js → get-draggableData-dkvBi0Bl.js} +1 -1
- package/dist/assets/{iframe-BsL3XxOF.js → iframe-DQBiGpMD.js} +2 -2
- package/dist/assets/{legend-DU0eJsZy.js → legend-Dsh-gS4D.js} +1 -1
- package/dist/assets/{legend-context-BD2-S1C1.js → legend-context-9xqNf4cB.js} +18 -18
- package/dist/assets/line-chart-r9Mg5Qcy.js +1 -0
- package/dist/assets/{line-chart.stories-uy97k1nH.js → line-chart.stories-B40-dAYL.js} +1 -1
- package/dist/assets/{line-chart.test-case.stories-Dvd9yMu2.js → line-chart.test-case.stories-DtULjl6w.js} +1 -1
- package/dist/assets/{pie-chart.stories-DkA8tvR7.js → pie-chart.stories-Birt17VG.js} +1 -1
- package/dist/assets/{preview-CzvgRopp.js → preview-BxIF5cTA.js} +2 -2
- package/dist/assets/{preview-2VwhhXCv.js → preview-C_VJ39RO.js} +1 -1
- package/dist/assets/{scatter-chart.stories-H8K5l3_j.js → scatter-chart.stories-BoOuwmMg.js} +1 -1
- package/dist/bar-chart/utils/use-bar-chart-options.d.ts +1 -1
- package/dist/common/helpers/chart-utils.d.ts +1 -1
- package/dist/iframe.html +1 -1
- package/dist/index.js.js +134 -104
- package/dist/index.js.js.map +1 -1
- package/dist/line-chart/hooks/use-chart-options.d.ts +2 -2
- package/dist/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +1 -1
- package/dist/line-chart/utils/get-line-chart-tooltips.d.ts +14 -0
- package/dist/project.json +1 -1
- package/dist/scatter-chart/hooks/use-scatter-chart-config.d.ts +1 -1
- package/dist/src/components/bar-chart/utils/use-bar-chart-options.d.ts +1 -1
- package/dist/src/components/common/helpers/chart-utils.d.ts +1 -1
- package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +2 -2
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +1 -1
- package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +14 -0
- package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +1 -1
- package/package.json +1 -1
- package/dist/assets/line-chart-DNNbp9dj.js +0 -1
package/dist/index.js.js
CHANGED
|
@@ -22426,17 +22426,17 @@ const HTML5Backend = function createBackend(manager, context, options) {
|
|
|
22426
22426
|
};
|
|
22427
22427
|
const MINOR_TICKS_PER_MAJOR = 10;
|
|
22428
22428
|
const getLargestMajorTickWidth = (majorTickPositions) => {
|
|
22429
|
-
return majorTickPositions.reduce(
|
|
22429
|
+
return majorTickPositions == null ? void 0 : majorTickPositions.reduce(
|
|
22430
22430
|
(acc, curr, index2) => {
|
|
22431
22431
|
if (index2 === 0) return acc;
|
|
22432
|
-
const gap = Math.abs(curr - majorTickPositions[index2 - 1]);
|
|
22432
|
+
const gap = Math.abs(curr - (majorTickPositions == null ? void 0 : majorTickPositions[index2 - 1]));
|
|
22433
22433
|
return Math.max(gap, acc);
|
|
22434
22434
|
},
|
|
22435
22435
|
0
|
|
22436
22436
|
);
|
|
22437
22437
|
};
|
|
22438
22438
|
const isValidPosition = (minorTickPosition, majorTickPositions, scale) => {
|
|
22439
|
-
const { axis, left: left2, top: top2, right: right2, bottom: bottom2 } = scale;
|
|
22439
|
+
const { axis, left: left2, top: top2, right: right2, bottom: bottom2 } = scale ?? {};
|
|
22440
22440
|
const isHorizontal = axis === "x";
|
|
22441
22441
|
const start = isHorizontal ? left2 : top2;
|
|
22442
22442
|
const end = isHorizontal ? right2 : bottom2;
|
|
@@ -22446,52 +22446,56 @@ const isValidPosition = (minorTickPosition, majorTickPositions, scale) => {
|
|
|
22446
22446
|
return isAfterStart && isBeforeEnd && !isDuplicate;
|
|
22447
22447
|
};
|
|
22448
22448
|
const getMinorTickPositions = (majorTickPositions, scale) => {
|
|
22449
|
-
|
|
22449
|
+
var _a2, _b2;
|
|
22450
|
+
const sortedMajorTickPositions = majorTickPositions == null ? void 0 : majorTickPositions.sort((a2, b2) => {
|
|
22450
22451
|
return a2 - b2;
|
|
22451
22452
|
});
|
|
22452
22453
|
const minorTickWidth = getLargestMajorTickWidth(majorTickPositions) / 10;
|
|
22453
22454
|
const startPosition = majorTickPositions[0];
|
|
22454
22455
|
const numMinorTicks = (majorTickPositions.length + 1) * MINOR_TICKS_PER_MAJOR;
|
|
22455
|
-
const positions2 = [...Array(numMinorTicks)].map((_2, index2) => {
|
|
22456
|
+
const positions2 = (_b2 = (_a2 = [...Array(numMinorTicks)]) == null ? void 0 : _a2.map((_2, index2) => {
|
|
22456
22457
|
const minorTickPosition = startPosition + (index2 - MINOR_TICKS_PER_MAJOR + 1) * minorTickWidth;
|
|
22457
|
-
return parseFloat(minorTickPosition.toFixed(1));
|
|
22458
|
-
}).filter(
|
|
22458
|
+
return parseFloat(minorTickPosition == null ? void 0 : minorTickPosition.toFixed(1));
|
|
22459
|
+
})) == null ? void 0 : _b2.filter(
|
|
22459
22460
|
(position) => isValidPosition(position, sortedMajorTickPositions, scale)
|
|
22460
22461
|
);
|
|
22461
22462
|
return positions2;
|
|
22462
22463
|
};
|
|
22463
22464
|
const drawMinorTicksForScale = (scale) => {
|
|
22464
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
22465
|
-
const { chart: chart2, ctx } = scale;
|
|
22466
|
-
|
|
22467
|
-
|
|
22468
|
-
if (config2.options.
|
|
22469
|
-
|
|
22470
|
-
const
|
|
22465
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
22466
|
+
const { chart: chart2, ctx } = scale ?? {};
|
|
22467
|
+
if (!ctx || (ctx == null ? void 0 : ctx.canvas) === null) return;
|
|
22468
|
+
const config2 = chart2 == null ? void 0 : chart2.config;
|
|
22469
|
+
if (!((_d2 = (_c2 = (_b2 = (_a2 = config2 == null ? void 0 : config2.options) == null ? void 0 : _a2.scales) == null ? void 0 : _b2[scale == null ? void 0 : scale.id]) == null ? void 0 : _c2.grid) == null ? void 0 : _d2.drawOnChartArea)) return;
|
|
22470
|
+
if (((_e2 = config2 == null ? void 0 : config2.options) == null ? void 0 : _e2.indexAxis) === (scale == null ? void 0 : scale.axis)) return;
|
|
22471
|
+
const isHorizontal = (scale == null ? void 0 : scale.axis) === "x";
|
|
22472
|
+
const majorTickPositions = (_g2 = (_f2 = scale == null ? void 0 : scale.ticks) == null ? void 0 : _f2.map((_2, index2) => scale == null ? void 0 : scale.getPixelForTick(index2))) == null ? void 0 : _g2.sort((a2, b2) => a2 - b2);
|
|
22471
22473
|
const minorTickPositions = getMinorTickPositions(majorTickPositions, scale);
|
|
22472
|
-
ctx.save();
|
|
22473
|
-
ctx.strokeStyle = ((
|
|
22474
|
+
(_h2 = ctx == null ? void 0 : ctx.save) == null ? void 0 : _h2.call(ctx);
|
|
22475
|
+
ctx.strokeStyle = ((_m2 = (_l2 = (_k2 = (_j2 = (_i2 = config2 == null ? void 0 : config2._config) == null ? void 0 : _i2.options) == null ? void 0 : _j2.scales) == null ? void 0 : _k2[scale.id]) == null ? void 0 : _l2.grid) == null ? void 0 : _m2.color) || "rgba(0,0,0,0.06)";
|
|
22474
22476
|
ctx.lineWidth = 0.5;
|
|
22475
|
-
minorTickPositions.forEach((minorTickPosition) => {
|
|
22477
|
+
minorTickPositions == null ? void 0 : minorTickPositions.forEach((minorTickPosition) => {
|
|
22478
|
+
var _a3, _b3, _c3, _d3, _e3;
|
|
22476
22479
|
ctx.beginPath();
|
|
22477
22480
|
if (isHorizontal) {
|
|
22478
|
-
const { top: top2, bottom: bottom2 } = chart2.chartArea;
|
|
22479
|
-
ctx.moveTo(minorTickPosition, top2);
|
|
22480
|
-
ctx.lineTo(minorTickPosition, bottom2);
|
|
22481
|
+
const { top: top2, bottom: bottom2 } = (chart2 == null ? void 0 : chart2.chartArea) ?? {};
|
|
22482
|
+
(_a3 = ctx == null ? void 0 : ctx.moveTo) == null ? void 0 : _a3.call(ctx, minorTickPosition, top2);
|
|
22483
|
+
(_b3 = ctx == null ? void 0 : ctx.lineTo) == null ? void 0 : _b3.call(ctx, minorTickPosition, bottom2);
|
|
22481
22484
|
} else {
|
|
22482
|
-
const { left: left2, right: right2 } = chart2.chartArea;
|
|
22483
|
-
ctx.moveTo(left2, minorTickPosition);
|
|
22484
|
-
ctx.lineTo(right2, minorTickPosition);
|
|
22485
|
+
const { left: left2, right: right2 } = (chart2 == null ? void 0 : chart2.chartArea) ?? {};
|
|
22486
|
+
(_c3 = ctx == null ? void 0 : ctx.moveTo) == null ? void 0 : _c3.call(ctx, left2, minorTickPosition);
|
|
22487
|
+
(_d3 = ctx == null ? void 0 : ctx.lineTo) == null ? void 0 : _d3.call(ctx, right2, minorTickPosition);
|
|
22485
22488
|
}
|
|
22486
|
-
ctx.stroke();
|
|
22489
|
+
(_e3 = ctx == null ? void 0 : ctx.stroke) == null ? void 0 : _e3.call(ctx);
|
|
22487
22490
|
});
|
|
22488
|
-
ctx.restore();
|
|
22491
|
+
(_n2 = ctx == null ? void 0 : ctx.restore) == null ? void 0 : _n2.call(ctx);
|
|
22489
22492
|
};
|
|
22490
22493
|
const chartMinorGridlinesPlugin = {
|
|
22491
22494
|
id: "minorGridlines",
|
|
22492
22495
|
beforeDatasetsDraw: (chart2) => {
|
|
22493
|
-
|
|
22494
|
-
|
|
22496
|
+
var _a2;
|
|
22497
|
+
const { scales } = chart2 ?? {};
|
|
22498
|
+
(_a2 = Object.keys(scales)) == null ? void 0 : _a2.forEach((id) => drawMinorTicksForScale(scales == null ? void 0 : scales[id]));
|
|
22495
22499
|
}
|
|
22496
22500
|
};
|
|
22497
22501
|
const BORDER_WIDTH = {
|
|
@@ -22649,23 +22653,23 @@ var Events = /* @__PURE__ */ ((Events2) => {
|
|
|
22649
22653
|
const chartAreaBorderPlugin = {
|
|
22650
22654
|
id: "chartAreaBorder",
|
|
22651
22655
|
beforeDraw(chart2, _2, options) {
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
} =
|
|
22656
|
-
ctx.save();
|
|
22657
|
-
ctx.strokeStyle = options.borderColor;
|
|
22658
|
-
ctx.lineWidth = options.borderWidth;
|
|
22659
|
-
ctx.setLineDash(options.borderDash || []);
|
|
22660
|
-
ctx.lineDashOffset = options.borderDashOffset ?? 0;
|
|
22661
|
-
ctx.strokeRect(left2, top2, width, height);
|
|
22662
|
-
ctx.restore();
|
|
22656
|
+
var _a2, _b2, _c2, _d2;
|
|
22657
|
+
if (!(chart2 == null ? void 0 : chart2.ctx) || !chart2.chartArea) return;
|
|
22658
|
+
const { ctx, chartArea } = chart2 ?? {};
|
|
22659
|
+
const { left: left2, top: top2, width, height } = chartArea ?? {};
|
|
22660
|
+
(_a2 = ctx == null ? void 0 : ctx.save) == null ? void 0 : _a2.call(ctx);
|
|
22661
|
+
ctx.strokeStyle = options == null ? void 0 : options.borderColor;
|
|
22662
|
+
ctx.lineWidth = options == null ? void 0 : options.borderWidth;
|
|
22663
|
+
(_b2 = ctx == null ? void 0 : ctx.setLineDash) == null ? void 0 : _b2.call(ctx, (options == null ? void 0 : options.borderDash) || []);
|
|
22664
|
+
ctx.lineDashOffset = (options == null ? void 0 : options.borderDashOffset) ?? 0;
|
|
22665
|
+
(_c2 = ctx == null ? void 0 : ctx.strokeRect) == null ? void 0 : _c2.call(ctx, left2, top2, width, height);
|
|
22666
|
+
(_d2 = ctx == null ? void 0 : ctx.restore) == null ? void 0 : _d2.call(ctx);
|
|
22663
22667
|
}
|
|
22664
22668
|
};
|
|
22665
22669
|
const getPlugins = (graph, legend2) => {
|
|
22666
22670
|
var _a2;
|
|
22667
22671
|
let plugins = [];
|
|
22668
|
-
if (graph.showMinorGridlines) {
|
|
22672
|
+
if (graph == null ? void 0 : graph.showMinorGridlines) {
|
|
22669
22673
|
plugins.push(chartMinorGridlinesPlugin);
|
|
22670
22674
|
}
|
|
22671
22675
|
const customLegend = legend2 == null ? void 0 : legend2.customLegend;
|
|
@@ -22692,7 +22696,7 @@ const generateRandomColor = (colors2) => {
|
|
|
22692
22696
|
const getTitle = (options) => {
|
|
22693
22697
|
return options.title !== "" ? {
|
|
22694
22698
|
display: true,
|
|
22695
|
-
text: options.title
|
|
22699
|
+
text: (options == null ? void 0 : options.title) ?? ""
|
|
22696
22700
|
} : {};
|
|
22697
22701
|
};
|
|
22698
22702
|
const isVertical = (direction) => {
|
|
@@ -22709,14 +22713,14 @@ const getClassName = (chartStyling, styles2) => {
|
|
|
22709
22713
|
staticChartHeight = false,
|
|
22710
22714
|
squareAspectRatio: squareAspectRatio2 = 0
|
|
22711
22715
|
} = chartStyling;
|
|
22712
|
-
const squareAspectRatioStyle = squareAspectRatio2 ? styles2.squareAspectRatio : "";
|
|
22716
|
+
const squareAspectRatioStyle = squareAspectRatio2 ? styles2 == null ? void 0 : styles2.squareAspectRatio : "";
|
|
22713
22717
|
let heightStyles = "";
|
|
22714
22718
|
if (width || height) {
|
|
22715
22719
|
heightStyles = "";
|
|
22716
22720
|
} else {
|
|
22717
22721
|
heightStyles = staticChartHeight ? styles2 == null ? void 0 : styles2.fixedHeight : styles2 == null ? void 0 : styles2.stretchHeight;
|
|
22718
22722
|
}
|
|
22719
|
-
return cx(styles2.chart, heightStyles, squareAspectRatioStyle);
|
|
22723
|
+
return cx(styles2 == null ? void 0 : styles2.chart, heightStyles, squareAspectRatioStyle);
|
|
22720
22724
|
};
|
|
22721
22725
|
const getLegend = (options, clickHandler) => {
|
|
22722
22726
|
const { legend: legend2 } = options || {};
|
|
@@ -22739,13 +22743,14 @@ const getLegend = (options, clickHandler) => {
|
|
|
22739
22743
|
};
|
|
22740
22744
|
};
|
|
22741
22745
|
const afterLabelCallback = (tooltipItem) => {
|
|
22742
|
-
|
|
22746
|
+
var _a2, _b2;
|
|
22747
|
+
const { error = null } = ((_b2 = (_a2 = tooltipItem == null ? void 0 : tooltipItem.dataset) == null ? void 0 : _a2.data) == null ? void 0 : _b2[tooltipItem == null ? void 0 : tooltipItem.dataIndex]) ?? {};
|
|
22743
22748
|
return error ? `Error: ${round$2(error, 4)}` : "";
|
|
22744
22749
|
};
|
|
22745
22750
|
const getTooltipLabel = (tooltipItem, showLabelsInTooltips) => {
|
|
22746
22751
|
var _a2, _b2, _c2;
|
|
22747
22752
|
const datasetDataLabel = (_c2 = (_b2 = (_a2 = tooltipItem == null ? void 0 : tooltipItem.dataset) == null ? void 0 : _a2.data) == null ? void 0 : _b2[tooltipItem == null ? void 0 : tooltipItem.dataIndex]) == null ? void 0 : _c2.label;
|
|
22748
|
-
const dataLabel = Array.isArray(datasetDataLabel) ? datasetDataLabel.join(" , ") : datasetDataLabel;
|
|
22753
|
+
const dataLabel = Array.isArray(datasetDataLabel) ? datasetDataLabel == null ? void 0 : datasetDataLabel.join(" , ") : datasetDataLabel ?? "";
|
|
22749
22754
|
return showLabelsInTooltips && (dataLabel == null ? void 0 : dataLabel.length) ? ` (${dataLabel})` : "";
|
|
22750
22755
|
};
|
|
22751
22756
|
const sanitize = (str) => str.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -25019,7 +25024,7 @@ const getDefaultProps$3 = (props) => {
|
|
|
25019
25024
|
persistenceId: (chart2 == null ? void 0 : chart2.persistenceId) ?? "",
|
|
25020
25025
|
controlsPortalId: (chart2 == null ? void 0 : chart2.controlsPortalId) ?? "",
|
|
25021
25026
|
testId: (chart2 == null ? void 0 : chart2.testId) ?? void 0,
|
|
25022
|
-
data: chart2 == null ? void 0 : chart2.data,
|
|
25027
|
+
data: (chart2 == null ? void 0 : chart2.data) ?? { datasets: [] },
|
|
25023
25028
|
options: {
|
|
25024
25029
|
title: (options == null ? void 0 : options.title) ?? "",
|
|
25025
25030
|
scales: (options == null ? void 0 : options.scales) ?? {},
|
|
@@ -25462,12 +25467,16 @@ const getCondition = (x2, y2, left2, right2, bottom2) => {
|
|
|
25462
25467
|
return { overLeftSide, overRightSide, overBottomSide };
|
|
25463
25468
|
};
|
|
25464
25469
|
const getAlignmentData = (context) => {
|
|
25465
|
-
var _a2;
|
|
25466
|
-
const
|
|
25467
|
-
const
|
|
25470
|
+
var _a2, _b2;
|
|
25471
|
+
const chart2 = context == null ? void 0 : context.chart;
|
|
25472
|
+
const dataIndex = (context == null ? void 0 : context.dataIndex) ?? 0;
|
|
25473
|
+
const datasetIndex = (context == null ? void 0 : context.datasetIndex) ?? 0;
|
|
25474
|
+
const chartArea = (chart2 == null ? void 0 : chart2.chartArea) ?? {};
|
|
25468
25475
|
const { left: left2 = null, right: right2 = null, bottom: bottom2 = null } = chartArea;
|
|
25469
|
-
const meta = chart2 == null ? void 0 : chart2.getDatasetMeta(datasetIndex);
|
|
25470
|
-
const
|
|
25476
|
+
const meta = (_a2 = chart2 == null ? void 0 : chart2.getDatasetMeta) == null ? void 0 : _a2.call(chart2, datasetIndex);
|
|
25477
|
+
const dataPoint = (_b2 = meta == null ? void 0 : meta.data) == null ? void 0 : _b2[dataIndex];
|
|
25478
|
+
const x2 = (dataPoint == null ? void 0 : dataPoint.x) ?? null;
|
|
25479
|
+
const y2 = (dataPoint == null ? void 0 : dataPoint.y) ?? null;
|
|
25471
25480
|
return {
|
|
25472
25481
|
x: x2,
|
|
25473
25482
|
y: y2,
|
|
@@ -25488,12 +25497,13 @@ const getPosition = () => {
|
|
|
25488
25497
|
};
|
|
25489
25498
|
};
|
|
25490
25499
|
const getLineChartDataLabels = (options) => {
|
|
25491
|
-
|
|
25500
|
+
var _a2;
|
|
25501
|
+
return ((_a2 = options == null ? void 0 : options.graph) == null ? void 0 : _a2.showDataLabels) ? {
|
|
25492
25502
|
display: AUTO,
|
|
25493
25503
|
align: getPosition(),
|
|
25494
25504
|
formatter: (_2, context) => {
|
|
25495
|
-
var
|
|
25496
|
-
const dataPoint = (_b2 = (
|
|
25505
|
+
var _a3, _b2;
|
|
25506
|
+
const dataPoint = (_b2 = (_a3 = context == null ? void 0 : context.dataset) == null ? void 0 : _a3.data) == null ? void 0 : _b2[context.dataIndex];
|
|
25497
25507
|
if (!dataPoint || dataPoint.label == null) return "";
|
|
25498
25508
|
if (typeof dataPoint.label === "string") {
|
|
25499
25509
|
return dataPoint.label;
|
|
@@ -25520,17 +25530,25 @@ const customFormatNumber$1 = (labelNumber, scientificNotation) => {
|
|
|
25520
25530
|
return displayNumber(roundByMagnitude(labelNumber), roundOptions);
|
|
25521
25531
|
};
|
|
25522
25532
|
const getLineChartToolTips = (options) => {
|
|
25523
|
-
|
|
25533
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
25534
|
+
if (!((_b2 = (_a2 = options == null ? void 0 : options.axes) == null ? void 0 : _a2.x) == null ? void 0 : _b2.length) || !((_d2 = (_c2 = options == null ? void 0 : options.axes) == null ? void 0 : _c2.y) == null ? void 0 : _d2.length)) {
|
|
25535
|
+
console.warn("Tooltip config fallback: missing axes", options);
|
|
25536
|
+
return {
|
|
25537
|
+
enabled: false,
|
|
25538
|
+
callbacks: {}
|
|
25539
|
+
};
|
|
25540
|
+
}
|
|
25541
|
+
const { scientificNotation } = (options == null ? void 0 : options.tooltip) ?? {};
|
|
25524
25542
|
const getTooltipLabels = ({
|
|
25525
25543
|
xAxisID = "",
|
|
25526
25544
|
yAxisID = ""
|
|
25527
25545
|
}) => {
|
|
25528
|
-
var
|
|
25529
|
-
const xIndex = (xAxisID == null ? void 0 : xAxisID.length) > 1 ? Number(xAxisID[1]) - 1 : 0;
|
|
25530
|
-
const yIndex = (yAxisID == null ? void 0 : yAxisID.length) > 1 ? Number(yAxisID[1]) - 1 : 0;
|
|
25531
|
-
const xAxis = options.axes.x[xIndex];
|
|
25532
|
-
const yAxis = options.axes.y[yIndex];
|
|
25533
|
-
if (((
|
|
25546
|
+
var _a3, _b3, _c3, _d3, _e3, _f2, _g2;
|
|
25547
|
+
const xIndex = (xAxisID == null ? void 0 : xAxisID.length) > 1 ? Number(xAxisID == null ? void 0 : xAxisID[1]) - 1 : 0;
|
|
25548
|
+
const yIndex = (yAxisID == null ? void 0 : yAxisID.length) > 1 ? Number(yAxisID == null ? void 0 : yAxisID[1]) - 1 : 0;
|
|
25549
|
+
const xAxis = (_b3 = (_a3 = options == null ? void 0 : options.axes) == null ? void 0 : _a3.x) == null ? void 0 : _b3[xIndex];
|
|
25550
|
+
const yAxis = (_d3 = (_c3 = options == null ? void 0 : options.axes) == null ? void 0 : _c3.y) == null ? void 0 : _d3[yIndex];
|
|
25551
|
+
if (((_g2 = (_f2 = (_e3 = options == null ? void 0 : options.axes) == null ? void 0 : _e3.x) == null ? void 0 : _f2[0]) == null ? void 0 : _g2.position) === Position.Top) {
|
|
25534
25552
|
return {
|
|
25535
25553
|
titleAxisLabel: (yAxis == null ? void 0 : yAxis.label) || "",
|
|
25536
25554
|
valueAxisLabel: (xAxis == null ? void 0 : xAxis.label) || "",
|
|
@@ -25547,19 +25565,23 @@ const getLineChartToolTips = (options) => {
|
|
|
25547
25565
|
}
|
|
25548
25566
|
};
|
|
25549
25567
|
const titleCallback2 = (tooltipItem) => {
|
|
25568
|
+
var _a3, _b3, _c3, _d3;
|
|
25569
|
+
if (!(tooltipItem == null ? void 0 : tooltipItem[0])) return "";
|
|
25550
25570
|
const labels = getTooltipLabels(tooltipItem[0].dataset);
|
|
25551
|
-
const { titleLabel, titleAxisLabel } = labels ?? {};
|
|
25552
|
-
const formattedValue = titleLabel === TooltipLabel.Y ? tooltipItem[0].parsed.y : tooltipItem[0].parsed.x;
|
|
25571
|
+
const { titleLabel = "", titleAxisLabel = "" } = labels ?? {};
|
|
25572
|
+
const formattedValue = titleLabel === TooltipLabel.Y ? (_b3 = (_a3 = tooltipItem == null ? void 0 : tooltipItem[0]) == null ? void 0 : _a3.parsed) == null ? void 0 : _b3.y : (_d3 = (_c3 = tooltipItem == null ? void 0 : tooltipItem[0]) == null ? void 0 : _c3.parsed) == null ? void 0 : _d3.x;
|
|
25553
25573
|
const roundedValue = customFormatNumber$1(formattedValue, scientificNotation);
|
|
25554
25574
|
return `${roundedValue} ${titleAxisLabel}`;
|
|
25555
25575
|
};
|
|
25556
25576
|
const labelCallback2 = (tooltipItem) => {
|
|
25557
|
-
|
|
25558
|
-
|
|
25559
|
-
|
|
25577
|
+
var _a3;
|
|
25578
|
+
const { showLabelsInTooltips } = (options == null ? void 0 : options.tooltip) ?? {};
|
|
25579
|
+
let label = ((_a3 = tooltipItem == null ? void 0 : tooltipItem.dataset) == null ? void 0 : _a3.label) || "";
|
|
25580
|
+
const labels = getTooltipLabels(tooltipItem == null ? void 0 : tooltipItem.dataset);
|
|
25560
25581
|
const { valueLabel = "", valueAxisLabel = "" } = labels ?? {};
|
|
25561
25582
|
const getTooltipItemValue = () => {
|
|
25562
|
-
|
|
25583
|
+
var _a4, _b3;
|
|
25584
|
+
const labelNumber = valueLabel === TooltipLabel.X ? (_a4 = tooltipItem == null ? void 0 : tooltipItem.parsed) == null ? void 0 : _a4.x : (_b3 = tooltipItem == null ? void 0 : tooltipItem.parsed) == null ? void 0 : _b3.y;
|
|
25563
25585
|
return customFormatNumber$1(labelNumber, scientificNotation);
|
|
25564
25586
|
};
|
|
25565
25587
|
const tooltipItemValue = getTooltipItemValue();
|
|
@@ -25568,7 +25590,7 @@ const getLineChartToolTips = (options) => {
|
|
|
25568
25590
|
return `${label}: ${tooltipItemValue} ${units} ${tooltipLabel}`;
|
|
25569
25591
|
};
|
|
25570
25592
|
return {
|
|
25571
|
-
enabled: options.tooltip.tooltips,
|
|
25593
|
+
enabled: (_e2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _e2.tooltips,
|
|
25572
25594
|
mode: ChartHoverMode.Nearest,
|
|
25573
25595
|
intersect: true,
|
|
25574
25596
|
padding: TOOLTIP_PADDING,
|
|
@@ -26005,8 +26027,8 @@ const useChartOptions = ({
|
|
|
26005
26027
|
const { legend: legend2, customLegendPlugin } = useLegendState({ chartRef, options }) ?? {};
|
|
26006
26028
|
const { state: legendState } = useLegend() ?? {};
|
|
26007
26029
|
const { annotation: annotation2 } = legendState ?? {};
|
|
26008
|
-
const datalabels = getLineChartDataLabels(options);
|
|
26009
|
-
const tooltip = getLineChartToolTips(options);
|
|
26030
|
+
const datalabels = getLineChartDataLabels(options) ?? {};
|
|
26031
|
+
const tooltip = getLineChartToolTips(options) ?? {};
|
|
26010
26032
|
const scales = useMemo(
|
|
26011
26033
|
() => autoScale(options, state, generatedDatasets, chartRef),
|
|
26012
26034
|
[options, state, generatedDatasets, chartRef]
|
|
@@ -26111,6 +26133,7 @@ const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
|
|
|
26111
26133
|
resetZoom2();
|
|
26112
26134
|
return false;
|
|
26113
26135
|
}
|
|
26136
|
+
return true;
|
|
26114
26137
|
},
|
|
26115
26138
|
[resetZoom2]
|
|
26116
26139
|
);
|
|
@@ -26217,14 +26240,15 @@ const useChartState = ({
|
|
|
26217
26240
|
const WORD_SEPARATOR = " ";
|
|
26218
26241
|
const SEMI_TRANSPARENT = "rgba(0, 0, 0, 0.5)";
|
|
26219
26242
|
const getWords = (text) => {
|
|
26220
|
-
|
|
26243
|
+
var _a2;
|
|
26244
|
+
return (_a2 = Array.isArray(text) ? text.join(WORD_SEPARATOR) : text) == null ? void 0 : _a2.split(
|
|
26221
26245
|
WORD_SEPARATOR
|
|
26222
26246
|
);
|
|
26223
26247
|
};
|
|
26224
26248
|
const drawText = ({ ctx, lines, lineHeight, x: x2, y: y2, position }) => {
|
|
26225
|
-
lines.forEach((line, index2) => {
|
|
26226
|
-
const lineY = position.includes("top") ? y2 + lineHeight * (index2 + 1) - 5 : y2 - (lines.length - 1 - index2) * lineHeight;
|
|
26227
|
-
ctx.fillText(line, x2, lineY);
|
|
26249
|
+
lines == null ? void 0 : lines.forEach((line, index2) => {
|
|
26250
|
+
const lineY = (position == null ? void 0 : position.includes("top")) ? y2 + lineHeight * (index2 + 1) - 5 : y2 - (lines.length - 1 - index2) * lineHeight;
|
|
26251
|
+
ctx == null ? void 0 : ctx.fillText(line, x2, lineY);
|
|
26228
26252
|
});
|
|
26229
26253
|
};
|
|
26230
26254
|
const calculateMaxWidth = (initialMaxWidth, chartAreaWidth) => {
|
|
@@ -26234,71 +26258,72 @@ const calculateMaxWidth = (initialMaxWidth, chartAreaWidth) => {
|
|
|
26234
26258
|
return initialMaxWidth * maxWidthFactor;
|
|
26235
26259
|
};
|
|
26236
26260
|
const getLegendDimensions = (chart2) => {
|
|
26237
|
-
|
|
26238
|
-
const
|
|
26239
|
-
const
|
|
26261
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
26262
|
+
const { legend: legend2 } = chart2 ?? {};
|
|
26263
|
+
const legendWidth = legend2 && (legend2 == null ? void 0 : legend2.display) && ((_a2 = legend2 == null ? void 0 : legend2.options) == null ? void 0 : _a2.position) === "left" ? (legend2 == null ? void 0 : legend2.width) + ((_c2 = (_b2 = legend2 == null ? void 0 : legend2.options) == null ? void 0 : _b2.labels) == null ? void 0 : _c2.padding) * 2 : 0;
|
|
26264
|
+
const legendHeight = legend2 && legend2.display && (((_d2 = legend2 == null ? void 0 : legend2.options) == null ? void 0 : _d2.position) === "top" || ((_e2 = legend2 == null ? void 0 : legend2.options) == null ? void 0 : _e2.position) === "bottom") ? (legend2 == null ? void 0 : legend2.height) + ((_g2 = (_f2 = legend2 == null ? void 0 : legend2.options) == null ? void 0 : _f2.labels) == null ? void 0 : _g2.padding) * 2 : 0;
|
|
26240
26265
|
return { legendWidth, legendHeight };
|
|
26241
26266
|
};
|
|
26242
26267
|
const getPositionCoordinates = (position, chart2, xOffset, yOffset) => {
|
|
26243
|
-
const { chartArea, width } = chart2;
|
|
26268
|
+
const { chartArea, width } = chart2 ?? {};
|
|
26244
26269
|
const temporaryChartAreaRight = width - 8;
|
|
26245
|
-
const { legendWidth, legendHeight } = getLegendDimensions(chart2);
|
|
26270
|
+
const { legendWidth, legendHeight } = getLegendDimensions(chart2) ?? {};
|
|
26246
26271
|
switch (position) {
|
|
26247
26272
|
case TextLabelPosition.TOP_LEFT:
|
|
26248
26273
|
return [
|
|
26249
|
-
chartArea.left + xOffset + legendWidth,
|
|
26250
|
-
chartArea.top + yOffset + legendHeight
|
|
26274
|
+
(chartArea == null ? void 0 : chartArea.left) + xOffset + legendWidth,
|
|
26275
|
+
(chartArea == null ? void 0 : chartArea.top) + yOffset + legendHeight
|
|
26251
26276
|
];
|
|
26252
26277
|
case TextLabelPosition.TOP_CENTER:
|
|
26253
26278
|
return [
|
|
26254
|
-
chartArea.left + chartArea.width / 2,
|
|
26255
|
-
chartArea.top + yOffset + legendHeight
|
|
26279
|
+
(chartArea == null ? void 0 : chartArea.left) + (chartArea == null ? void 0 : chartArea.width) / 2,
|
|
26280
|
+
(chartArea == null ? void 0 : chartArea.top) + yOffset + legendHeight
|
|
26256
26281
|
];
|
|
26257
26282
|
case TextLabelPosition.TOP_RIGHT:
|
|
26258
26283
|
return [
|
|
26259
26284
|
temporaryChartAreaRight - xOffset,
|
|
26260
26285
|
//replace within chartArea.right when resize bug will be fixed
|
|
26261
|
-
chartArea.top + yOffset + legendHeight
|
|
26286
|
+
(chartArea == null ? void 0 : chartArea.top) + yOffset + legendHeight
|
|
26262
26287
|
];
|
|
26263
26288
|
case TextLabelPosition.MIDDLE_LEFT:
|
|
26264
26289
|
return [
|
|
26265
|
-
chartArea.left + xOffset + legendWidth,
|
|
26266
|
-
chartArea.top + chartArea.height / 2
|
|
26290
|
+
(chartArea == null ? void 0 : chartArea.left) + xOffset + legendWidth,
|
|
26291
|
+
(chartArea == null ? void 0 : chartArea.top) + (chartArea == null ? void 0 : chartArea.height) / 2
|
|
26267
26292
|
];
|
|
26268
26293
|
case TextLabelPosition.MIDDLE_CENTER:
|
|
26269
26294
|
return [
|
|
26270
|
-
chartArea.left + chartArea.width / 2,
|
|
26271
|
-
chartArea.top + chartArea.height / 2
|
|
26295
|
+
(chartArea == null ? void 0 : chartArea.left) + (chartArea == null ? void 0 : chartArea.width) / 2,
|
|
26296
|
+
(chartArea == null ? void 0 : chartArea.top) + (chartArea == null ? void 0 : chartArea.height) / 2
|
|
26272
26297
|
];
|
|
26273
26298
|
case TextLabelPosition.MIDDLE_RIGHT:
|
|
26274
26299
|
return [
|
|
26275
26300
|
temporaryChartAreaRight - xOffset - legendWidth,
|
|
26276
26301
|
//replace within chartArea.right when resize bug will be fixed
|
|
26277
|
-
chartArea.top + chartArea.height / 2
|
|
26302
|
+
(chartArea == null ? void 0 : chartArea.top) + (chartArea == null ? void 0 : chartArea.height) / 2
|
|
26278
26303
|
];
|
|
26279
26304
|
case TextLabelPosition.BOTTOM_LEFT:
|
|
26280
26305
|
return [
|
|
26281
|
-
chartArea.left + xOffset + legendWidth,
|
|
26282
|
-
chartArea.bottom - yOffset - legendHeight
|
|
26306
|
+
(chartArea == null ? void 0 : chartArea.left) + xOffset + legendWidth,
|
|
26307
|
+
(chartArea == null ? void 0 : chartArea.bottom) - yOffset - legendHeight
|
|
26283
26308
|
];
|
|
26284
26309
|
case TextLabelPosition.BOTTOM_CENTER:
|
|
26285
26310
|
return [
|
|
26286
|
-
chartArea.left + chartArea.width / 2,
|
|
26287
|
-
chartArea.bottom - yOffset - legendHeight
|
|
26311
|
+
(chartArea == null ? void 0 : chartArea.left) + (chartArea == null ? void 0 : chartArea.width) / 2,
|
|
26312
|
+
(chartArea == null ? void 0 : chartArea.bottom) - yOffset - legendHeight
|
|
26288
26313
|
];
|
|
26289
26314
|
case TextLabelPosition.BOTTOM_RIGHT:
|
|
26290
26315
|
default:
|
|
26291
26316
|
return [
|
|
26292
26317
|
temporaryChartAreaRight - xOffset - legendWidth,
|
|
26293
26318
|
//replace within chartArea.right when resize bug will be fixed
|
|
26294
|
-
chartArea.bottom - yOffset - legendHeight
|
|
26319
|
+
(chartArea == null ? void 0 : chartArea.bottom) - yOffset - legendHeight
|
|
26295
26320
|
];
|
|
26296
26321
|
}
|
|
26297
26322
|
};
|
|
26298
26323
|
const getTextAlign = (position) => {
|
|
26299
|
-
if (position.includes(AlignOptions.Center)) {
|
|
26324
|
+
if (position == null ? void 0 : position.includes(AlignOptions.Center)) {
|
|
26300
26325
|
return AlignOptions.Center;
|
|
26301
|
-
} else if (position.includes(AlignOptions.Left)) {
|
|
26326
|
+
} else if (position == null ? void 0 : position.includes(AlignOptions.Left)) {
|
|
26302
26327
|
return AlignOptions.Left;
|
|
26303
26328
|
} else {
|
|
26304
26329
|
return AlignOptions.Right;
|
|
@@ -26308,11 +26333,11 @@ const wrapText = (words, maxWidth, ctx) => {
|
|
|
26308
26333
|
let line = "";
|
|
26309
26334
|
let lines = [];
|
|
26310
26335
|
for (let i2 = 0; i2 < words.length; i2++) {
|
|
26311
|
-
const testLine = `${line}${words[i2]}${WORD_SEPARATOR}`;
|
|
26312
|
-
const { width: testWidth } = ctx.measureText(testLine);
|
|
26336
|
+
const testLine = `${line}${words == null ? void 0 : words[i2]}${WORD_SEPARATOR}`;
|
|
26337
|
+
const { width: testWidth } = (ctx == null ? void 0 : ctx.measureText(testLine)) ?? {};
|
|
26313
26338
|
if (testWidth > maxWidth) {
|
|
26314
|
-
lines.push(line.trim());
|
|
26315
|
-
line = `${words[i2]}${WORD_SEPARATOR}`;
|
|
26339
|
+
lines.push(line == null ? void 0 : line.trim());
|
|
26340
|
+
line = `${words == null ? void 0 : words[i2]}${WORD_SEPARATOR}`;
|
|
26316
26341
|
} else {
|
|
26317
26342
|
line = testLine;
|
|
26318
26343
|
}
|
|
@@ -26321,15 +26346,17 @@ const wrapText = (words, maxWidth, ctx) => {
|
|
|
26321
26346
|
return lines;
|
|
26322
26347
|
};
|
|
26323
26348
|
const renderWrappedText = (ctx, options) => {
|
|
26324
|
-
|
|
26349
|
+
var _a2, _b2;
|
|
26350
|
+
if (!ctx) return;
|
|
26351
|
+
const { text, maxWidth, fontSize, lineHeight, x: x2, y: y2, position } = options ?? {};
|
|
26325
26352
|
const words = getWords(text);
|
|
26326
26353
|
const wrappedLines = wrapText(words, maxWidth, ctx);
|
|
26327
|
-
ctx.save();
|
|
26354
|
+
(_a2 = ctx == null ? void 0 : ctx.save) == null ? void 0 : _a2.call(ctx);
|
|
26328
26355
|
ctx.font = `${fontSize}px Arial`;
|
|
26329
26356
|
ctx.fillStyle = SEMI_TRANSPARENT;
|
|
26330
26357
|
ctx.textAlign = getTextAlign(position);
|
|
26331
26358
|
drawText({ ctx, lines: wrappedLines, lineHeight, x: x2, y: y2, position });
|
|
26332
|
-
ctx.restore();
|
|
26359
|
+
(_b2 = ctx == null ? void 0 : ctx.restore) == null ? void 0 : _b2.call(ctx);
|
|
26333
26360
|
};
|
|
26334
26361
|
const chartAreaTextPlugin = {
|
|
26335
26362
|
id: "chartAreaText",
|
|
@@ -26343,9 +26370,9 @@ const chartAreaTextPlugin = {
|
|
|
26343
26370
|
lineHeight,
|
|
26344
26371
|
maxWidth: initialMaxWidth,
|
|
26345
26372
|
position
|
|
26346
|
-
} = options;
|
|
26373
|
+
} = options ?? {};
|
|
26347
26374
|
if (!showLabel || !text) return;
|
|
26348
|
-
const { ctx, chartArea } = chart2;
|
|
26375
|
+
const { ctx, chartArea } = chart2 ?? {};
|
|
26349
26376
|
if (!ctx || !chartArea) return;
|
|
26350
26377
|
const maxWidth = calculateMaxWidth(initialMaxWidth, chartArea.width);
|
|
26351
26378
|
const [x2, y2] = getPositionCoordinates(position, chart2, xOffset, yOffset);
|
|
@@ -26672,8 +26699,10 @@ const annotationDraggerPlugin = {
|
|
|
26672
26699
|
id: "annotationDraggerPlugin",
|
|
26673
26700
|
beforeDraw(chart2) {
|
|
26674
26701
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
26702
|
+
const ctx = chart2 == null ? void 0 : chart2.ctx;
|
|
26675
26703
|
let annotations = ((_b2 = (_a2 = chart2.options.plugins) == null ? void 0 : _a2.annotation) == null ? void 0 : _b2.annotations) ?? {};
|
|
26676
26704
|
if (!annotations) return;
|
|
26705
|
+
if (!ctx || !annotations) return;
|
|
26677
26706
|
annotationLabel(
|
|
26678
26707
|
chart2.ctx,
|
|
26679
26708
|
annotations,
|
|
@@ -26706,6 +26735,7 @@ const annotationDraggerPlugin = {
|
|
|
26706
26735
|
const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
|
|
26707
26736
|
enabled: false
|
|
26708
26737
|
};
|
|
26738
|
+
if (!canvas2 || !scales || !pluginOptions) return;
|
|
26709
26739
|
const typedScales = { ...scales, x: scales.x, y: scales.y };
|
|
26710
26740
|
let annotations = ((_d2 = (_c2 = chart2.options.plugins) == null ? void 0 : _c2.annotation) == null ? void 0 : _d2.annotations) ?? {};
|
|
26711
26741
|
if (!chart2 && !annotations) return;
|