@oliasoft-open-source/charts-library 3.6.1 → 3.6.2
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 +56 -27
- 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
|
}
|
|
@@ -25796,7 +25827,7 @@ const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
|
|
|
25796
25827
|
[resetZoom2]
|
|
25797
25828
|
);
|
|
25798
25829
|
const handleDoubleClick = useCallback(
|
|
25799
|
-
(
|
|
25830
|
+
(_2, args) => {
|
|
25800
25831
|
const { event } = args;
|
|
25801
25832
|
if (event.type === DOUBLE_CLICK) {
|
|
25802
25833
|
debouncedResetZoom();
|
|
@@ -26152,6 +26183,7 @@ Chart$2.register(
|
|
|
26152
26183
|
chartAreaTextPlugin
|
|
26153
26184
|
);
|
|
26154
26185
|
const LineChart = (props) => {
|
|
26186
|
+
var _a2, _b2;
|
|
26155
26187
|
setDefaultTheme();
|
|
26156
26188
|
const chartRef = useRef(null);
|
|
26157
26189
|
const { table: table2 } = props;
|
|
@@ -26165,7 +26197,7 @@ const LineChart = (props) => {
|
|
|
26165
26197
|
controlsPortalId
|
|
26166
26198
|
} = chart2;
|
|
26167
26199
|
const { annotations, axes, chartStyling, graph } = options;
|
|
26168
|
-
const showCustomLegend = !options.legend.customLegend.customLegendContainerID;
|
|
26200
|
+
const showCustomLegend = !((_b2 = (_a2 = options == null ? void 0 : options.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendContainerID);
|
|
26169
26201
|
const [state, dispatch] = useReducer(
|
|
26170
26202
|
reducer$1,
|
|
26171
26203
|
{
|
|
@@ -39465,9 +39497,6 @@ const BarChart = (props) => {
|
|
|
39465
39497
|
mode: ChartHoverMode.Nearest,
|
|
39466
39498
|
intersect: true
|
|
39467
39499
|
},
|
|
39468
|
-
// elements: {
|
|
39469
|
-
// bar: { pointStyle: PointStyle.Circle },
|
|
39470
|
-
// },
|
|
39471
39500
|
scales: getBarChartScales(chart2),
|
|
39472
39501
|
plugins: {
|
|
39473
39502
|
title: getTitle(options),
|