@oliasoft-open-source/charts-library 4.5.0-beta-1 → 4.5.0
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/index.js +124 -170
- package/dist/index.js.map +1 -1
- package/dist/src/components/common/common.interface.d.ts +3 -3
- package/dist/src/components/common/helpers/custom-format-number.d.ts +1 -1
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +1 -1
- package/dist/src/components/common/plugins/annotation-dragger-plugin/enums.d.ts +5 -0
- package/dist/src/components/line-chart/line-chart.stories.d.ts +42 -65
- package/dist/src/components/pie-chart/pie-chart-defalut-props.interface.d.ts +2 -5
- package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +1 -1
- package/dist/src/components/scatter-chart/scatter-chart-default-props.interface.d.ts +1 -0
- package/dist/src/components/scatter-chart/scatter-chart.interface.d.ts +1 -0
- package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +1 -1
- package/package.json +7 -7
- package/dist/src/components/common/plugins/ellipsis-annotation-plugin/ellipsis-annotation-plugin.d.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -13,7 +13,6 @@ import { round as round$2, displayNumber, isCloseTo, roundByMagnitude } from "@o
|
|
|
13
13
|
import cx from "classnames";
|
|
14
14
|
import { Portal, Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer } from "@oliasoft-open-source/react-ui-library";
|
|
15
15
|
import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, isNil, map as map$3, find, get as get$1 } from "lodash";
|
|
16
|
-
import { roundNumberToPrecision } from "@oliasoft-open-source/units/dist/rounding/rounding";
|
|
17
16
|
/*!
|
|
18
17
|
* @kurkle/color v0.3.2
|
|
19
18
|
* https://github.com/kurkle/color#readme
|
|
@@ -22174,139 +22173,6 @@ class HTML5BackendImpl {
|
|
|
22174
22173
|
const HTML5Backend = function createBackend(manager, context, options) {
|
|
22175
22174
|
return new HTML5BackendImpl(manager, context, options);
|
|
22176
22175
|
};
|
|
22177
|
-
const BORDER_WIDTH = {
|
|
22178
|
-
INITIAL: 2,
|
|
22179
|
-
HOVERED: 6,
|
|
22180
|
-
POINT_HOVERED: 8
|
|
22181
|
-
};
|
|
22182
|
-
const BORDER_COLOR = "rgba(0,0,0,0.1)";
|
|
22183
|
-
const ANNOTATION_DASH = [10, 2];
|
|
22184
|
-
const DEFAULT_FONT_SIZE = 12;
|
|
22185
|
-
const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
|
|
22186
|
-
const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
|
|
22187
|
-
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
22188
|
-
const TOOLTIP_PADDING = 8;
|
|
22189
|
-
const TOOLTIP_BOX_PADDING = 4;
|
|
22190
|
-
const TRANSPARENT = "transparent";
|
|
22191
|
-
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
22192
|
-
const COLORS = [
|
|
22193
|
-
"#3366cc",
|
|
22194
|
-
"#dc3912",
|
|
22195
|
-
"#ff9900",
|
|
22196
|
-
"#109618",
|
|
22197
|
-
"#990099",
|
|
22198
|
-
"#0099c6",
|
|
22199
|
-
"#dd4477",
|
|
22200
|
-
"#66aa00",
|
|
22201
|
-
"#b82e2e",
|
|
22202
|
-
"#316395",
|
|
22203
|
-
"#994499",
|
|
22204
|
-
"#22aa99",
|
|
22205
|
-
"#aaaa11",
|
|
22206
|
-
"#6633cc",
|
|
22207
|
-
"#e67300",
|
|
22208
|
-
"#8b0707",
|
|
22209
|
-
"#651067",
|
|
22210
|
-
"#329262",
|
|
22211
|
-
"#5574a6",
|
|
22212
|
-
"#3b3eac"
|
|
22213
|
-
];
|
|
22214
|
-
const ALPHA_CHANEL = "99";
|
|
22215
|
-
const WHITE_COLOR_AS_DECIMAL = 16777215;
|
|
22216
|
-
const AUTO = "auto";
|
|
22217
|
-
const ANIMATION_DURATION = {
|
|
22218
|
-
NO: 0,
|
|
22219
|
-
SLOW: 400,
|
|
22220
|
-
FAST: 1e3
|
|
22221
|
-
};
|
|
22222
|
-
const DEFAULT_CHART_NAME = "new_chart";
|
|
22223
|
-
const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
|
|
22224
|
-
const DECIMAL_POINT_TOLERANCE = 9;
|
|
22225
|
-
const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
|
|
22226
|
-
const GRADIENT_COLORS = [
|
|
22227
|
-
{ offset: 0, color: "rgba(144,238,144,0.8)" },
|
|
22228
|
-
// Light green
|
|
22229
|
-
{ offset: 0.6, color: "rgba(255,255,224,0.8)" },
|
|
22230
|
-
// Light yellow
|
|
22231
|
-
{ offset: 0.8, color: "rgba(255,255,224,0.8)" },
|
|
22232
|
-
// Light yellow
|
|
22233
|
-
{ offset: 0.92, color: "rgba(255,182,193,0.5)" },
|
|
22234
|
-
// Light red
|
|
22235
|
-
{ offset: 0.99, color: "rgba(255,182,193,0.8)" }
|
|
22236
|
-
// Light red
|
|
22237
|
-
];
|
|
22238
|
-
const findRadii = (points, mainPoint, isXReverse, isYReverse) => {
|
|
22239
|
-
if ((points == null ? void 0 : points.length) === 0) {
|
|
22240
|
-
throw new Error("Array of points is empty");
|
|
22241
|
-
}
|
|
22242
|
-
let top2 = mainPoint;
|
|
22243
|
-
let bottom2 = mainPoint;
|
|
22244
|
-
let left2 = mainPoint;
|
|
22245
|
-
let right2 = mainPoint;
|
|
22246
|
-
for (const point of points) {
|
|
22247
|
-
if (isYReverse ? point.y < top2.y : point.y > top2.y) {
|
|
22248
|
-
top2 = point;
|
|
22249
|
-
}
|
|
22250
|
-
if (isYReverse ? point.y > bottom2.y : point.y < bottom2.y) {
|
|
22251
|
-
bottom2 = point;
|
|
22252
|
-
}
|
|
22253
|
-
if (isXReverse ? point.x > left2.x : point.x < left2.x) {
|
|
22254
|
-
left2 = point;
|
|
22255
|
-
}
|
|
22256
|
-
if (isXReverse ? point.x < right2.x : point.x > right2.x) {
|
|
22257
|
-
right2 = point;
|
|
22258
|
-
}
|
|
22259
|
-
}
|
|
22260
|
-
const radiusX = Math.abs(right2.x - left2.x) / 2;
|
|
22261
|
-
const radiusY = Math.abs(bottom2.y - top2.y) / 2;
|
|
22262
|
-
return { radiusX, radiusY };
|
|
22263
|
-
};
|
|
22264
|
-
const ellipsisAnnotationPlugin = {
|
|
22265
|
-
id: "ellipsisAnnotationPlugin",
|
|
22266
|
-
afterDraw: (chart2) => {
|
|
22267
|
-
var _a2, _b2, _c2, _d2;
|
|
22268
|
-
const {
|
|
22269
|
-
ctx,
|
|
22270
|
-
scales: { x: x2, y: y2 },
|
|
22271
|
-
data: { datasets },
|
|
22272
|
-
options
|
|
22273
|
-
} = chart2;
|
|
22274
|
-
const isXReverse = ((_b2 = (_a2 = options == null ? void 0 : options.scales) == null ? void 0 : _a2.x) == null ? void 0 : _b2.reverse) || false;
|
|
22275
|
-
const isYReverse = ((_d2 = (_c2 = options == null ? void 0 : options.scales) == null ? void 0 : _c2.y) == null ? void 0 : _d2.reverse) || false;
|
|
22276
|
-
datasets.forEach((dataset) => {
|
|
22277
|
-
dataset.data.forEach((item) => {
|
|
22278
|
-
if (item.ellipsePoints && item.ellipsePoints.length) {
|
|
22279
|
-
const centerX = x2.getPixelForValue(item.x);
|
|
22280
|
-
const centerY = y2.getPixelForValue(item.y);
|
|
22281
|
-
const points = item.ellipsePoints.map((point) => ({
|
|
22282
|
-
x: x2.getPixelForValue(point.x),
|
|
22283
|
-
y: y2.getPixelForValue(point.y)
|
|
22284
|
-
}));
|
|
22285
|
-
const mainPoint = { x: centerX, y: centerY };
|
|
22286
|
-
const { radiusX, radiusY } = findRadii(
|
|
22287
|
-
points,
|
|
22288
|
-
mainPoint,
|
|
22289
|
-
isXReverse,
|
|
22290
|
-
isYReverse
|
|
22291
|
-
);
|
|
22292
|
-
const rotationAngle = item.ellipseRotation * Math.PI / 180;
|
|
22293
|
-
ctx.beginPath();
|
|
22294
|
-
ctx.ellipse(
|
|
22295
|
-
centerX,
|
|
22296
|
-
centerY,
|
|
22297
|
-
radiusX,
|
|
22298
|
-
radiusY,
|
|
22299
|
-
rotationAngle,
|
|
22300
|
-
0,
|
|
22301
|
-
2 * Math.PI
|
|
22302
|
-
);
|
|
22303
|
-
ctx.strokeStyle = (dataset == null ? void 0 : dataset.borderColor) ?? DEFAULT_COLOR;
|
|
22304
|
-
ctx.stroke();
|
|
22305
|
-
}
|
|
22306
|
-
});
|
|
22307
|
-
});
|
|
22308
|
-
}
|
|
22309
|
-
};
|
|
22310
22176
|
const chart$3 = "_chart_e3qdd_1";
|
|
22311
22177
|
const canvas$1 = "_canvas_e3qdd_11";
|
|
22312
22178
|
const fixedHeight$3 = "_fixedHeight_e3qdd_20";
|
|
@@ -22600,6 +22466,67 @@ const chartMinorGridlinesPlugin = {
|
|
|
22600
22466
|
Object.keys(scales).forEach((id) => drawMinorTicksForScale(scales[id]));
|
|
22601
22467
|
}
|
|
22602
22468
|
};
|
|
22469
|
+
const BORDER_WIDTH = {
|
|
22470
|
+
INITIAL: 2,
|
|
22471
|
+
HOVERED: 6,
|
|
22472
|
+
POINT_HOVERED: 8
|
|
22473
|
+
};
|
|
22474
|
+
const BORDER_COLOR = "rgba(0,0,0,0.1)";
|
|
22475
|
+
const ANNOTATION_DASH = [10, 2];
|
|
22476
|
+
const DEFAULT_FONT_SIZE = 12;
|
|
22477
|
+
const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
|
|
22478
|
+
const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
|
|
22479
|
+
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
22480
|
+
const TOOLTIP_PADDING = 8;
|
|
22481
|
+
const TOOLTIP_BOX_PADDING = 4;
|
|
22482
|
+
const TRANSPARENT = "transparent";
|
|
22483
|
+
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
22484
|
+
const COLORS = [
|
|
22485
|
+
"#3366cc",
|
|
22486
|
+
"#dc3912",
|
|
22487
|
+
"#ff9900",
|
|
22488
|
+
"#109618",
|
|
22489
|
+
"#990099",
|
|
22490
|
+
"#0099c6",
|
|
22491
|
+
"#dd4477",
|
|
22492
|
+
"#66aa00",
|
|
22493
|
+
"#b82e2e",
|
|
22494
|
+
"#316395",
|
|
22495
|
+
"#994499",
|
|
22496
|
+
"#22aa99",
|
|
22497
|
+
"#aaaa11",
|
|
22498
|
+
"#6633cc",
|
|
22499
|
+
"#e67300",
|
|
22500
|
+
"#8b0707",
|
|
22501
|
+
"#651067",
|
|
22502
|
+
"#329262",
|
|
22503
|
+
"#5574a6",
|
|
22504
|
+
"#3b3eac"
|
|
22505
|
+
];
|
|
22506
|
+
const ALPHA_CHANEL = "99";
|
|
22507
|
+
const WHITE_COLOR_AS_DECIMAL = 16777215;
|
|
22508
|
+
const AUTO = "auto";
|
|
22509
|
+
const ANIMATION_DURATION = {
|
|
22510
|
+
NO: 0,
|
|
22511
|
+
SLOW: 400,
|
|
22512
|
+
FAST: 1e3
|
|
22513
|
+
};
|
|
22514
|
+
const DEFAULT_CHART_NAME = "new_chart";
|
|
22515
|
+
const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
|
|
22516
|
+
const DECIMAL_POINT_TOLERANCE = 9;
|
|
22517
|
+
const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
|
|
22518
|
+
const GRADIENT_COLORS = [
|
|
22519
|
+
{ offset: 0, color: "rgba(144,238,144,0.8)" },
|
|
22520
|
+
// Light green
|
|
22521
|
+
{ offset: 0.6, color: "rgba(255,255,224,0.8)" },
|
|
22522
|
+
// Light yellow
|
|
22523
|
+
{ offset: 0.8, color: "rgba(255,255,224,0.8)" },
|
|
22524
|
+
// Light yellow
|
|
22525
|
+
{ offset: 0.92, color: "rgba(255,182,193,0.5)" },
|
|
22526
|
+
// Light red
|
|
22527
|
+
{ offset: 0.99, color: "rgba(255,182,193,0.8)" }
|
|
22528
|
+
// Light red
|
|
22529
|
+
];
|
|
22603
22530
|
const chartAreaBorderPlugin = {
|
|
22604
22531
|
id: "chartAreaBorder",
|
|
22605
22532
|
beforeDraw(chart2, _2, options) {
|
|
@@ -25413,6 +25340,12 @@ var AnnotationType = /* @__PURE__ */ ((AnnotationType2) => {
|
|
|
25413
25340
|
AnnotationType2["ELLIPSE"] = "ellipse";
|
|
25414
25341
|
return AnnotationType2;
|
|
25415
25342
|
})(AnnotationType || {});
|
|
25343
|
+
var DragAxis = /* @__PURE__ */ ((DragAxis2) => {
|
|
25344
|
+
DragAxis2["X"] = "x";
|
|
25345
|
+
DragAxis2["Y"] = "y";
|
|
25346
|
+
DragAxis2["Both"] = "both";
|
|
25347
|
+
return DragAxis2;
|
|
25348
|
+
})(DragAxis || {});
|
|
25416
25349
|
const handleLineEnter = (element, chart2, annotation2) => {
|
|
25417
25350
|
var _a2;
|
|
25418
25351
|
chart2.canvas.style.cursor = CursorStyle.Pointer;
|
|
@@ -25492,13 +25425,9 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25492
25425
|
const borderColor = {
|
|
25493
25426
|
[AnnotationType.LINE]: color2,
|
|
25494
25427
|
[AnnotationType.POINT]: color2,
|
|
25495
|
-
[AnnotationType.BOX]: color2
|
|
25496
|
-
[AnnotationType.ELLIPSE]: color2
|
|
25428
|
+
[AnnotationType.BOX]: color2
|
|
25497
25429
|
}[type] || TRANSPARENT;
|
|
25498
|
-
const borderWidth =
|
|
25499
|
-
[AnnotationType.LINE]: BORDER_WIDTH.INITIAL,
|
|
25500
|
-
[AnnotationType.ELLIPSE]: (ann == null ? void 0 : ann.borderWidth) ?? 0
|
|
25501
|
-
}[type] ?? 0;
|
|
25430
|
+
const borderWidth = type === AnnotationType.LINE ? BORDER_WIDTH.INITIAL : 0;
|
|
25502
25431
|
const borderDash = type === AnnotationType.LINE ? ANNOTATION_DASH : void 0;
|
|
25503
25432
|
const defLabel = {
|
|
25504
25433
|
content: ann == null ? void 0 : ann.label,
|
|
@@ -25564,17 +25493,15 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25564
25493
|
const onDragStart = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragStart) ? ann == null ? void 0 : ann.onDragStart(cord, annotation2) : void 0;
|
|
25565
25494
|
const onDrag = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDrag) ? ann == null ? void 0 : ann.onDrag(cord, annotation2) : void 0;
|
|
25566
25495
|
const onDragEnd = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragEnd) ? ann == null ? void 0 : ann.onDragEnd(cord, annotation2) : void 0;
|
|
25567
|
-
const rotation = ann.rotation * Math.PI / 180;
|
|
25568
25496
|
return {
|
|
25569
25497
|
...ann,
|
|
25570
25498
|
drawTime: "afterDraw",
|
|
25571
25499
|
display: ann == null ? void 0 : ann.display,
|
|
25572
25500
|
annotationIndex: idx,
|
|
25573
25501
|
id: `${ann == null ? void 0 : ann.label}-${ann == null ? void 0 : ann.value}-${idx}`,
|
|
25574
|
-
rotation,
|
|
25575
25502
|
scaleID,
|
|
25576
25503
|
label,
|
|
25577
|
-
backgroundColor:
|
|
25504
|
+
backgroundColor: color2,
|
|
25578
25505
|
borderColor,
|
|
25579
25506
|
borderWidth,
|
|
25580
25507
|
borderDash,
|
|
@@ -26222,21 +26149,29 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
|
|
|
26222
26149
|
const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
|
|
26223
26150
|
if (isDragging2 && activeAnnotation) {
|
|
26224
26151
|
canvas2.style.cursor = CursorStyle.Move;
|
|
26152
|
+
const dragAxis = (activeAnnotation == null ? void 0 : activeAnnotation.dragAxis) ?? DragAxis.Both;
|
|
26225
26153
|
const { x: x2, y: y2 } = getMousePositionInCoordinates(event, canvas2, scales);
|
|
26226
26154
|
const metrics = calculateAnnotationMetricsInValues(activeAnnotation);
|
|
26227
26155
|
let newCenterX = x2 - dragStartX;
|
|
26228
26156
|
let newCenterY = y2 - dragStartY;
|
|
26229
|
-
if (
|
|
26230
|
-
|
|
26231
|
-
|
|
26232
|
-
activeAnnotation.
|
|
26233
|
-
|
|
26234
|
-
|
|
26235
|
-
|
|
26236
|
-
|
|
26237
|
-
|
|
26238
|
-
|
|
26239
|
-
|
|
26157
|
+
if (dragAxis !== DragAxis.Y) {
|
|
26158
|
+
if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
|
|
26159
|
+
activeAnnotation.xValue = newCenterX;
|
|
26160
|
+
} else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
|
|
26161
|
+
if (!isNil(metrics == null ? void 0 : metrics.width)) {
|
|
26162
|
+
activeAnnotation.xMin = newCenterX - metrics.width / 2;
|
|
26163
|
+
activeAnnotation.xMax = newCenterX + metrics.width / 2;
|
|
26164
|
+
}
|
|
26165
|
+
}
|
|
26166
|
+
}
|
|
26167
|
+
if (dragAxis !== DragAxis.X) {
|
|
26168
|
+
if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
|
|
26169
|
+
activeAnnotation.yValue = newCenterY;
|
|
26170
|
+
} else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
|
|
26171
|
+
if (!isNil(metrics == null ? void 0 : metrics.height)) {
|
|
26172
|
+
activeAnnotation.yMin = newCenterY - metrics.height / 2;
|
|
26173
|
+
activeAnnotation.yMax = newCenterY + metrics.height / 2;
|
|
26174
|
+
}
|
|
26240
26175
|
}
|
|
26241
26176
|
}
|
|
26242
26177
|
chart2.update();
|
|
@@ -26919,8 +26854,7 @@ Chart$2.register(
|
|
|
26919
26854
|
plugin,
|
|
26920
26855
|
annotation,
|
|
26921
26856
|
chartAreaTextPlugin,
|
|
26922
|
-
annotationDraggerPlugin
|
|
26923
|
-
ellipsisAnnotationPlugin
|
|
26857
|
+
annotationDraggerPlugin
|
|
26924
26858
|
);
|
|
26925
26859
|
const LineChart = (props) => {
|
|
26926
26860
|
var _a2, _b2;
|
|
@@ -27073,7 +27007,8 @@ const defaultChartStyling$2 = (styling) => ({
|
|
|
27073
27007
|
});
|
|
27074
27008
|
const defaultTooltip$2 = (tooltip) => ({
|
|
27075
27009
|
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
27076
|
-
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
|
|
27010
|
+
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
|
|
27011
|
+
scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
|
|
27077
27012
|
});
|
|
27078
27013
|
const defaultGraph$2 = (graph) => ({
|
|
27079
27014
|
showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
|
|
@@ -27118,6 +27053,8 @@ const getDefaultProps$2 = (props) => {
|
|
|
27118
27053
|
}
|
|
27119
27054
|
};
|
|
27120
27055
|
};
|
|
27056
|
+
const DISPLAY_SCIENTIFIC_LOWER_BOUND = 1e-4;
|
|
27057
|
+
const DISPLAY_SCIENTIFIC_UPPER_BOUND = 1e7;
|
|
27121
27058
|
const usePieChartConfig = (chart2) => {
|
|
27122
27059
|
const [pointHover, setPointHover] = useState(false);
|
|
27123
27060
|
const { data, options } = chart2;
|
|
@@ -27250,6 +27187,16 @@ const usePieChartConfig = (chart2) => {
|
|
|
27250
27187
|
};
|
|
27251
27188
|
};
|
|
27252
27189
|
const getToolTips = () => {
|
|
27190
|
+
const customFormatNumber2 = (labelNumber) => {
|
|
27191
|
+
var _a2;
|
|
27192
|
+
let roundOptions = {};
|
|
27193
|
+
if (!((_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.scientificNotation)) {
|
|
27194
|
+
roundOptions = { scientific: false };
|
|
27195
|
+
} else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
|
|
27196
|
+
roundOptions = { roundScientificCoefficient: 3 };
|
|
27197
|
+
}
|
|
27198
|
+
return displayNumber(roundByMagnitude(labelNumber), roundOptions);
|
|
27199
|
+
};
|
|
27253
27200
|
return {
|
|
27254
27201
|
callbacks: {
|
|
27255
27202
|
title: (tooltipItem) => {
|
|
@@ -27266,8 +27213,7 @@ const usePieChartConfig = (chart2) => {
|
|
|
27266
27213
|
const value = tooltipItem.dataset.data[dataIndex];
|
|
27267
27214
|
const labelValue = typeof value === "object" ? `${value.value || ""} ${options.tooltip.showLabelsInTooltips && value.label ? "(" + value.label + ")" : ""}` : value;
|
|
27268
27215
|
const unit = (data == null ? void 0 : data.yUnit) ? `[${data == null ? void 0 : data.yUnit}]` : "";
|
|
27269
|
-
|
|
27270
|
-
return `${dataLabel} ${formattedValue} ${unit}`;
|
|
27216
|
+
return `${dataLabel} ${customFormatNumber2(labelValue)} ${unit}`;
|
|
27271
27217
|
}
|
|
27272
27218
|
},
|
|
27273
27219
|
padding: TOOLTIP_PADDING,
|
|
@@ -39938,8 +39884,6 @@ const getBarChartDataLabels = (options) => {
|
|
|
39938
39884
|
formatter: formatterCallback
|
|
39939
39885
|
} : { display: false };
|
|
39940
39886
|
};
|
|
39941
|
-
const DISPLAY_SCIENTIFIC_LOWER_BOUND = 1e-4;
|
|
39942
|
-
const DISPLAY_SCIENTIFIC_UPPER_BOUND = 1e7;
|
|
39943
39887
|
const getBarChartToolTips = (options) => {
|
|
39944
39888
|
var _a2;
|
|
39945
39889
|
const getTooltipLabels = (dataset) => {
|
|
@@ -39975,8 +39919,11 @@ const getBarChartToolTips = (options) => {
|
|
|
39975
39919
|
return axisLabel + barLabel;
|
|
39976
39920
|
};
|
|
39977
39921
|
const customFormatNumber2 = (labelNumber) => {
|
|
39922
|
+
var _a3;
|
|
39978
39923
|
let roundOptions = {};
|
|
39979
|
-
if (
|
|
39924
|
+
if (!((_a3 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a3.scientificNotation)) {
|
|
39925
|
+
roundOptions = { scientific: false };
|
|
39926
|
+
} else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
|
|
39980
39927
|
roundOptions = { roundScientificCoefficient: 3 };
|
|
39981
39928
|
}
|
|
39982
39929
|
return displayNumber(roundByMagnitude(labelNumber), roundOptions);
|
|
@@ -40112,7 +40059,8 @@ const defaultChartStyling$1 = (styling) => ({
|
|
|
40112
40059
|
});
|
|
40113
40060
|
const defaultTooltip$1 = (tooltip) => ({
|
|
40114
40061
|
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
40115
|
-
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
|
|
40062
|
+
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
|
|
40063
|
+
scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
|
|
40116
40064
|
});
|
|
40117
40065
|
const defaultGraph$1 = (graph) => ({
|
|
40118
40066
|
showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
|
|
@@ -40261,9 +40209,11 @@ const BarChartWithLegend = (props) => {
|
|
|
40261
40209
|
const { options } = getDefaultProps$1(props);
|
|
40262
40210
|
return /* @__PURE__ */ jsx(LegendProvider, { options, children: /* @__PURE__ */ jsx(BarChart, { ...props }) });
|
|
40263
40211
|
};
|
|
40264
|
-
const customFormatNumber = (labelNumber) => {
|
|
40212
|
+
const customFormatNumber = (labelNumber, scientificNotation) => {
|
|
40265
40213
|
let roundOptions = {};
|
|
40266
|
-
if (
|
|
40214
|
+
if (!scientificNotation) {
|
|
40215
|
+
roundOptions = { scientific: false };
|
|
40216
|
+
} else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
|
|
40267
40217
|
roundOptions = { roundScientificCoefficient: 3 };
|
|
40268
40218
|
}
|
|
40269
40219
|
return displayNumber(roundByMagnitude(labelNumber), roundOptions);
|
|
@@ -40276,12 +40226,15 @@ const titleCallback = (tooltipItems, options) => {
|
|
|
40276
40226
|
return label;
|
|
40277
40227
|
}
|
|
40278
40228
|
};
|
|
40279
|
-
const labelCallback = (tooltipItem) => {
|
|
40229
|
+
const labelCallback = (tooltipItem, options) => {
|
|
40230
|
+
var _a2;
|
|
40280
40231
|
const { raw, dataset } = tooltipItem ?? {};
|
|
40281
40232
|
const datapointLabel = raw == null ? void 0 : raw.label;
|
|
40233
|
+
const scientificNotation = (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.scientificNotation;
|
|
40282
40234
|
return `${datapointLabel ?? (dataset == null ? void 0 : dataset.label)} ( x: ${customFormatNumber(
|
|
40283
|
-
raw == null ? void 0 : raw.x
|
|
40284
|
-
|
|
40235
|
+
raw == null ? void 0 : raw.x,
|
|
40236
|
+
scientificNotation
|
|
40237
|
+
)} , y: ${customFormatNumber(raw == null ? void 0 : raw.y, scientificNotation)} )`;
|
|
40285
40238
|
};
|
|
40286
40239
|
const getTooltipsConfig = (options) => {
|
|
40287
40240
|
var _a2, _b2, _c2;
|
|
@@ -40289,7 +40242,7 @@ const getTooltipsConfig = (options) => {
|
|
|
40289
40242
|
enabled: (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.enabled,
|
|
40290
40243
|
callbacks: {
|
|
40291
40244
|
title: (tooltipItems) => titleCallback(tooltipItems, options),
|
|
40292
|
-
label: labelCallback
|
|
40245
|
+
label: (tooltipItems) => labelCallback(tooltipItems, options)
|
|
40293
40246
|
},
|
|
40294
40247
|
backgroundColor: (_b2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _b2.backgroundColor,
|
|
40295
40248
|
displayColors: (_c2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _c2.displayColors,
|
|
@@ -40465,7 +40418,8 @@ const defaultTooltip = (tooltip) => ({
|
|
|
40465
40418
|
tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
|
|
40466
40419
|
showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
|
|
40467
40420
|
backgroundColor: (tooltip == null ? void 0 : tooltip.backgroundColor) || "#333",
|
|
40468
|
-
displayColors: (tooltip == null ? void 0 : tooltip.displayColors) || false
|
|
40421
|
+
displayColors: (tooltip == null ? void 0 : tooltip.displayColors) || false,
|
|
40422
|
+
scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
|
|
40469
40423
|
});
|
|
40470
40424
|
const defaultGraph = (graph) => ({
|
|
40471
40425
|
showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) ?? false,
|