@oliasoft-open-source/charts-library 3.6.1 → 3.6.3
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 +8 -0
- package/dist/index.js +72 -37
- package/dist/index.js.map +1 -1
- package/dist/src/components/bar-chart/get-bar-chart-data-labels.d.ts +1 -2
- package/dist/src/components/bar-chart/get-bar-chart-scales.d.ts +1 -2
- package/dist/src/components/common/common.interface.d.ts +2 -1
- package/dist/src/components/common/helpers/chart-border-plugin.d.ts +2 -2
- package/dist/src/components/common/helpers/chart-utils.d.ts +91 -0
- package/dist/src/components/common/helpers/get-custom-legend-plugin-example.d.ts +1 -1
- package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +2 -2
- package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +2 -2
- package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +1 -1
- package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +2 -4
- package/dist/src/components/line-chart/hooks/use-chart-plugins.d.ts +7 -0
- package/dist/src/components/line-chart/legend/legend-interface.d.ts +1 -1
- package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +2 -99
- package/dist/src/components/line-chart/line-chart.interface.d.ts +3 -3
- package/dist/src/components/line-chart/state/initial-state.d.ts +4 -26
- package/dist/src/components/line-chart/utils/axis-formatting/axis-formatting.d.ts +1 -1
- package/dist/src/components/line-chart/utils/get-generated-labels.d.ts +1 -0
- package/package.json +3 -2
package/dist/declaration.d.ts
CHANGED
|
@@ -15,3 +15,11 @@ declare module '*.svg' {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare module 'chartjs-plugin-dragdata';
|
|
18
|
+
|
|
19
|
+
declare module 'react-base64-downloader' {
|
|
20
|
+
export function triggerBase64Download(base64: string, filename: string): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '@oliasoft-open-source/react-ui-library';
|
|
24
|
+
|
|
25
|
+
declare module 'html-to-image';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
8
8
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
9
9
|
import React, { forwardRef, useRef, useEffect, createContext as createContext$2, memo, useLayoutEffect, useState, useCallback, useMemo, isValidElement, cloneElement, useContext, useReducer } from "react";
|
|
10
|
-
import { round as round$2,
|
|
10
|
+
import { round as round$2, displayNumber, isCloseTo, roundByMagnitude, toNum } from "@oliasoft-open-source/units";
|
|
11
11
|
import cx from "classnames";
|
|
12
12
|
import { produce } from "immer";
|
|
13
13
|
import { Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Portal } from "@oliasoft-open-source/react-ui-library";
|
|
@@ -13369,7 +13369,12 @@ const getAxisPosition = (axisType, i2) => {
|
|
|
13369
13369
|
return i2 % 2 === 0 ? positionA : positionB;
|
|
13370
13370
|
};
|
|
13371
13371
|
const getClassName = (chartStyling, styles2) => {
|
|
13372
|
-
const {
|
|
13372
|
+
const {
|
|
13373
|
+
width,
|
|
13374
|
+
height,
|
|
13375
|
+
staticChartHeight = false,
|
|
13376
|
+
squareAspectRatio: squareAspectRatio2 = 0
|
|
13377
|
+
} = chartStyling;
|
|
13373
13378
|
const squareAspectRatioStyle = squareAspectRatio2 ? styles2.squareAspectRatio : "";
|
|
13374
13379
|
let heightStyles = "";
|
|
13375
13380
|
if (width || height) {
|
|
@@ -22766,7 +22771,8 @@ const initialState = ({ options, persistenceId }) => {
|
|
|
22766
22771
|
axes: stateAxes,
|
|
22767
22772
|
showAnnotationLineIndex: setAnnotations(annotationsData),
|
|
22768
22773
|
showTable: false,
|
|
22769
|
-
enableDragPoints: dragData.enableDragData && enableDragPoints
|
|
22774
|
+
enableDragPoints: (dragData == null ? void 0 : dragData.enableDragData) && enableDragPoints,
|
|
22775
|
+
initialAxesRanges: []
|
|
22770
22776
|
};
|
|
22771
22777
|
};
|
|
22772
22778
|
var DefaultContext = {
|
|
@@ -23996,10 +24002,16 @@ const useChartFunctions = ({
|
|
|
23996
24002
|
const { datasetIndex } = legendItem2;
|
|
23997
24003
|
const chartInstance = chartRef == null ? void 0 : chartRef.current;
|
|
23998
24004
|
const { datasets } = (chartInstance == null ? void 0 : chartInstance.data) || {};
|
|
23999
|
-
const dataset = datasets[datasetIndex];
|
|
24000
|
-
const meta = chartInstance.getDatasetMeta(datasetIndex);
|
|
24001
|
-
|
|
24002
|
-
|
|
24005
|
+
const dataset = datasets == null ? void 0 : datasets[datasetIndex];
|
|
24006
|
+
const meta = chartInstance == null ? void 0 : chartInstance.getDatasetMeta(datasetIndex);
|
|
24007
|
+
if (meta) {
|
|
24008
|
+
if (meta.hidden === null) {
|
|
24009
|
+
meta.hidden = !dataset.hidden;
|
|
24010
|
+
} else {
|
|
24011
|
+
meta.hidden = null;
|
|
24012
|
+
}
|
|
24013
|
+
}
|
|
24014
|
+
if (annotations.controlAnnotation && (dataset == null ? void 0 : dataset.isAnnotation)) {
|
|
24003
24015
|
const { annotationIndex } = dataset;
|
|
24004
24016
|
dispatch({ type: "TOGGLE_ANNOTATION", payload: { annotationIndex } });
|
|
24005
24017
|
}
|
|
@@ -24007,7 +24019,9 @@ const useChartFunctions = ({
|
|
|
24007
24019
|
datasets == null ? void 0 : datasets.forEach((ds, ix) => {
|
|
24008
24020
|
if (ds.displayGroup !== dataset.displayGroup)
|
|
24009
24021
|
return;
|
|
24010
|
-
chartInstance
|
|
24022
|
+
if (chartInstance && meta) {
|
|
24023
|
+
chartInstance.getDatasetMeta(ix).hidden = meta.hidden;
|
|
24024
|
+
}
|
|
24011
24025
|
});
|
|
24012
24026
|
}
|
|
24013
24027
|
if (onLegendClick) {
|
|
@@ -24230,10 +24244,11 @@ const reducer = (state, action) => {
|
|
|
24230
24244
|
});
|
|
24231
24245
|
case actionTypes.UnitUpdated:
|
|
24232
24246
|
return produce(state, (draft) => {
|
|
24247
|
+
var _a2;
|
|
24233
24248
|
const { name, value, id } = action.payload;
|
|
24234
|
-
const
|
|
24235
|
-
if (
|
|
24236
|
-
|
|
24249
|
+
const unit = (_a2 = draft.find((a2) => a2.id === id)) == null ? void 0 : _a2.unit;
|
|
24250
|
+
if (unit && name) {
|
|
24251
|
+
unit[name] = value;
|
|
24237
24252
|
}
|
|
24238
24253
|
});
|
|
24239
24254
|
default:
|
|
@@ -24281,8 +24296,8 @@ const AxesOptionsPopover = (optionsPopover) => {
|
|
|
24281
24296
|
if (valid) {
|
|
24282
24297
|
const sanitizedFormState = formState.map((axis) => ({
|
|
24283
24298
|
...axis,
|
|
24284
|
-
min:
|
|
24285
|
-
max:
|
|
24299
|
+
min: typeof axis.min === "string" ? Number(axis.min) : axis.min,
|
|
24300
|
+
max: typeof axis.max === "string" ? Number(axis.max) : axis.max
|
|
24286
24301
|
}));
|
|
24287
24302
|
onUpdateAxes({
|
|
24288
24303
|
axes: sanitizedFormState
|
|
@@ -24324,7 +24339,9 @@ const AxesOptionsPopover = (optionsPopover) => {
|
|
|
24324
24339
|
(el) => el.id === axis.id
|
|
24325
24340
|
);
|
|
24326
24341
|
const axisLabel = axisControl == null ? void 0 : axisControl.label;
|
|
24327
|
-
const axisState = formState.find(
|
|
24342
|
+
const axisState = formState.find(
|
|
24343
|
+
(a2) => a2.id === axis.id
|
|
24344
|
+
);
|
|
24328
24345
|
const axisErrors = errors == null ? void 0 : errors.find((a2) => a2.id === axis.id);
|
|
24329
24346
|
const { min, max, unit } = axisState || {};
|
|
24330
24347
|
const minErrorMsg = ((_a3 = axisErrors == null ? void 0 : axisErrors.min) == null ? void 0 : _a3[0]) ? translations[axisErrors.min[0]] : null;
|
|
@@ -24368,7 +24385,7 @@ const AxesOptionsPopover = (optionsPopover) => {
|
|
|
24368
24385
|
{
|
|
24369
24386
|
name: "selectedUnit",
|
|
24370
24387
|
options: (_c2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _c2.options,
|
|
24371
|
-
value: unit == null ? void 0 : unit.selectedUnit,
|
|
24388
|
+
value: typeof unit !== "string" ? unit == null ? void 0 : unit.selectedUnit : void 0,
|
|
24372
24389
|
onChange: (e2) => {
|
|
24373
24390
|
onEditUnit({
|
|
24374
24391
|
name: e2.target.name,
|
|
@@ -24570,7 +24587,7 @@ const Controls = ({
|
|
|
24570
24587
|
onTogglePan,
|
|
24571
24588
|
onToggleZoom,
|
|
24572
24589
|
enableDragPoints,
|
|
24573
|
-
isDragDataAllowed: dragData.enableDragData,
|
|
24590
|
+
isDragDataAllowed: dragData == null ? void 0 : dragData.enableDragData,
|
|
24574
24591
|
onToggleDragPoints,
|
|
24575
24592
|
onDisableDragOptions,
|
|
24576
24593
|
translations
|
|
@@ -24639,6 +24656,10 @@ function useMeasure() {
|
|
|
24639
24656
|
const useMeasure$1 = isBrowser && typeof window.ResizeObserver !== "undefined" ? useMeasure : function() {
|
|
24640
24657
|
return [noop, defaultState];
|
|
24641
24658
|
};
|
|
24659
|
+
const getGeneratedLabels = (chart2) => {
|
|
24660
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
24661
|
+
return ((_e2 = (_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) == null ? void 0 : _e2.call(_d2, chart2)) ?? [];
|
|
24662
|
+
};
|
|
24642
24663
|
const legend = "_legend_wpro0_1";
|
|
24643
24664
|
const isDragging = "_isDragging_wpro0_8";
|
|
24644
24665
|
const legendItems = "_legendItems_wpro0_11";
|
|
@@ -24774,7 +24795,6 @@ const LegendItem = ({ hidden, dataset, handleClick }) => {
|
|
|
24774
24795
|
};
|
|
24775
24796
|
const LEGEND_MARGIN = 4;
|
|
24776
24797
|
const LegendPanel = forwardRef((props, ref) => {
|
|
24777
|
-
var _a2, _b2, _c2, _d2;
|
|
24778
24798
|
const {
|
|
24779
24799
|
legendPosition,
|
|
24780
24800
|
chartRef,
|
|
@@ -24800,7 +24820,7 @@ const LegendPanel = forwardRef((props, ref) => {
|
|
|
24800
24820
|
const { data, chartArea, height = 0, width = 0 } = chart2;
|
|
24801
24821
|
const { datasets } = data;
|
|
24802
24822
|
const { top: top2, left: left2, bottom: bottom2, right: right2 } = chartArea;
|
|
24803
|
-
const items = (
|
|
24823
|
+
const items = getGeneratedLabels(chart2);
|
|
24804
24824
|
const style = {
|
|
24805
24825
|
left: legendPosition.includes("left") ? left2 : void 0,
|
|
24806
24826
|
right: legendPosition.includes("right") ? width - right2 : void 0,
|
|
@@ -24974,9 +24994,20 @@ const TextLabelPosition = {
|
|
|
24974
24994
|
BOTTOM_CENTER: "bottom-center",
|
|
24975
24995
|
BOTTOM_RIGHT: "bottom-right"
|
|
24976
24996
|
};
|
|
24997
|
+
const defaultAxis = (position) => ({
|
|
24998
|
+
label: "",
|
|
24999
|
+
position,
|
|
25000
|
+
color: "",
|
|
25001
|
+
unit: {
|
|
25002
|
+
options: [],
|
|
25003
|
+
selectedUnit: "",
|
|
25004
|
+
setSelectedUnit: () => {
|
|
25005
|
+
}
|
|
25006
|
+
}
|
|
25007
|
+
});
|
|
24977
25008
|
const defaultAxes$1 = (axes) => ({
|
|
24978
|
-
x: (axes == null ? void 0 : axes.x) || [
|
|
24979
|
-
y: (axes == null ? void 0 : axes.y) || [
|
|
25009
|
+
x: (axes == null ? void 0 : axes.x) || [defaultAxis("bottom")],
|
|
25010
|
+
y: (axes == null ? void 0 : axes.y) || [defaultAxis("left")]
|
|
24980
25011
|
});
|
|
24981
25012
|
const defaultAdditionalAxesOptions$1 = (options) => ({
|
|
24982
25013
|
chartScaleType: (options == null ? void 0 : options.chartScaleType) || "linear",
|
|
@@ -25070,7 +25101,7 @@ const getDefaultProps$2 = (props) => {
|
|
|
25070
25101
|
return {
|
|
25071
25102
|
persistenceId: (chart2 == null ? void 0 : chart2.persistenceId) ?? "",
|
|
25072
25103
|
controlsPortalId: (chart2 == null ? void 0 : chart2.controlsPortalId) ?? "",
|
|
25073
|
-
testId: (chart2 == null ? void 0 : chart2.testId) ??
|
|
25104
|
+
testId: (chart2 == null ? void 0 : chart2.testId) ?? void 0,
|
|
25074
25105
|
data: chart2 == null ? void 0 : chart2.data,
|
|
25075
25106
|
options: {
|
|
25076
25107
|
title: (options == null ? void 0 : options.title) ?? "",
|
|
@@ -25192,7 +25223,7 @@ const calculateDelta$1 = (tickValue, ticks) => {
|
|
|
25192
25223
|
}
|
|
25193
25224
|
return delta;
|
|
25194
25225
|
};
|
|
25195
|
-
const formatAxisLabelNumbers = (tickValue, ticks
|
|
25226
|
+
const formatAxisLabelNumbers = (tickValue, ticks) => {
|
|
25196
25227
|
if (tickValue === 0 || tickValue === null) {
|
|
25197
25228
|
return "0";
|
|
25198
25229
|
}
|
|
@@ -25471,23 +25502,29 @@ const getLineChartDataLabels = (options) => {
|
|
|
25471
25502
|
formatter: (_value, context) => context.dataset.data[context.dataIndex].label || ""
|
|
25472
25503
|
} : { display: false };
|
|
25473
25504
|
};
|
|
25474
|
-
const annotationEnter = (
|
|
25505
|
+
const annotationEnter = (element, chart2) => {
|
|
25475
25506
|
var _a2;
|
|
25476
25507
|
if ((_a2 = element.options.scaleID) == null ? void 0 : _a2.includes(AxisType.X)) {
|
|
25477
25508
|
element.options.label.xAdjust = chart2.chartArea.left;
|
|
25478
25509
|
}
|
|
25479
25510
|
element.options.borderWidth = BORDER_WIDTH.HOVERED;
|
|
25480
|
-
if (element.options.label)
|
|
25511
|
+
if (element.options.label) {
|
|
25512
|
+
element.label.options.display = true;
|
|
25481
25513
|
element.options.label.enabled = true;
|
|
25514
|
+
}
|
|
25482
25515
|
chart2.draw();
|
|
25483
25516
|
chart2.canvas.style.cursor = CursorStyle.Pointer;
|
|
25517
|
+
return true;
|
|
25484
25518
|
};
|
|
25485
|
-
const annotationLeave = (
|
|
25519
|
+
const annotationLeave = (element, chart2) => {
|
|
25486
25520
|
element.options.borderWidth = BORDER_WIDTH.INITIAL;
|
|
25487
|
-
if (element.options.label)
|
|
25521
|
+
if (element.options.label) {
|
|
25522
|
+
element.label.options.display = false;
|
|
25488
25523
|
element.options.label.enabled = false;
|
|
25524
|
+
}
|
|
25489
25525
|
chart2.draw();
|
|
25490
25526
|
chart2.canvas.style.cursor = CursorStyle.Initial;
|
|
25527
|
+
return true;
|
|
25491
25528
|
};
|
|
25492
25529
|
const generateAnnotations = (options, state) => {
|
|
25493
25530
|
const { annotationsData } = (options == null ? void 0 : options.annotations) || {};
|
|
@@ -25506,22 +25543,22 @@ const generateAnnotations = (options, state) => {
|
|
|
25506
25543
|
const label = type === "line" ? {
|
|
25507
25544
|
backgroundColor: color2,
|
|
25508
25545
|
content: curr == null ? void 0 : curr.label,
|
|
25509
|
-
|
|
25546
|
+
display: false,
|
|
25510
25547
|
position: Position.Top
|
|
25511
25548
|
} : {
|
|
25512
25549
|
content: curr == null ? void 0 : curr.label,
|
|
25513
|
-
|
|
25550
|
+
display: true,
|
|
25514
25551
|
font: { weight: "normal" }
|
|
25515
25552
|
};
|
|
25516
|
-
const enter = (
|
|
25553
|
+
const enter = ({ element }, { chart: chart2 }) => {
|
|
25517
25554
|
if (type !== "line")
|
|
25518
25555
|
return;
|
|
25519
|
-
annotationEnter(
|
|
25556
|
+
annotationEnter(element, chart2);
|
|
25520
25557
|
};
|
|
25521
|
-
const leave = (
|
|
25558
|
+
const leave = ({ element }, { chart: chart2 }) => {
|
|
25522
25559
|
if (type !== "line")
|
|
25523
25560
|
return;
|
|
25524
|
-
annotationLeave(
|
|
25561
|
+
annotationLeave(element, chart2);
|
|
25525
25562
|
};
|
|
25526
25563
|
const annotation2 = {
|
|
25527
25564
|
...curr,
|
|
@@ -25796,7 +25833,7 @@ const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
|
|
|
25796
25833
|
[resetZoom2]
|
|
25797
25834
|
);
|
|
25798
25835
|
const handleDoubleClick = useCallback(
|
|
25799
|
-
(
|
|
25836
|
+
(_2, args) => {
|
|
25800
25837
|
const { event } = args;
|
|
25801
25838
|
if (event.type === DOUBLE_CLICK) {
|
|
25802
25839
|
debouncedResetZoom();
|
|
@@ -26152,6 +26189,7 @@ Chart$2.register(
|
|
|
26152
26189
|
chartAreaTextPlugin
|
|
26153
26190
|
);
|
|
26154
26191
|
const LineChart = (props) => {
|
|
26192
|
+
var _a2, _b2;
|
|
26155
26193
|
setDefaultTheme();
|
|
26156
26194
|
const chartRef = useRef(null);
|
|
26157
26195
|
const { table: table2 } = props;
|
|
@@ -26165,7 +26203,7 @@ const LineChart = (props) => {
|
|
|
26165
26203
|
controlsPortalId
|
|
26166
26204
|
} = chart2;
|
|
26167
26205
|
const { annotations, axes, chartStyling, graph } = options;
|
|
26168
|
-
const showCustomLegend = !options.legend.customLegend.customLegendContainerID;
|
|
26206
|
+
const showCustomLegend = !((_b2 = (_a2 = options == null ? void 0 : options.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendContainerID);
|
|
26169
26207
|
const [state, dispatch] = useReducer(
|
|
26170
26208
|
reducer$1,
|
|
26171
26209
|
{
|
|
@@ -39465,9 +39503,6 @@ const BarChart = (props) => {
|
|
|
39465
39503
|
mode: ChartHoverMode.Nearest,
|
|
39466
39504
|
intersect: true
|
|
39467
39505
|
},
|
|
39468
|
-
// elements: {
|
|
39469
|
-
// bar: { pointStyle: PointStyle.Circle },
|
|
39470
|
-
// },
|
|
39471
39506
|
scales: getBarChartScales(chart2),
|
|
39472
39507
|
plugins: {
|
|
39473
39508
|
title: getTitle(options),
|