@oliasoft-open-source/charts-library 5.14.1 → 5.15.0-beta-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/index.js +120 -122
- package/dist/src/components/bar-chart/utils/get-bar-chart-scales.d.ts +2 -1
- package/dist/src/components/bar-chart/utils/use-bar-chart-options.d.ts +1 -1
- package/dist/src/components/common/common.interface.d.ts +8 -10
- package/dist/src/components/common/enums.d.ts +3 -1
- package/dist/src/components/common/helpers/get-cartesian-scale-options.d.ts +27 -0
- package/dist/src/components/line-chart/line-chart.interface.d.ts +3 -3
- package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +2 -586
- package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +2 -172
- package/dist/src/components/scatter-chart/scatter-chart-default-props.interface.d.ts +1 -0
- package/dist/src/components/scatter-chart/utils/get-scales-config.d.ts +2 -173
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
2
|
+
import "chartjs-adapter-date-fns";
|
|
2
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
import { DndProvider, useDrag, useDrop } from "react-dnd";
|
|
4
5
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
5
|
-
import { displayNumber, isCloseTo, round, roundByMagnitude } from "@oliasoft-open-source/units";
|
|
6
|
+
import { displayNumber, isCloseTo, round, roundByMagnitude, toNum } from "@oliasoft-open-source/units";
|
|
6
7
|
import cx from "classnames";
|
|
7
|
-
import { cloneDeep, debounce, defaultTo, find, findIndex, get, has, isArray, isEmpty, isNil, isNumber, isObject, map, noop, set, some, startCase } from "es-toolkit/compat";
|
|
8
|
+
import { cloneDeep, debounce, defaultTo, find, findIndex, get, has, isArray, isEmpty, isFinite as isFinite$1, isNil, isNumber, isObject, isString, map, noop, set, some, startCase } from "es-toolkit/compat";
|
|
8
9
|
import { produce } from "immer";
|
|
9
10
|
import { Button, ButtonGroup, Field, Flex, Icon, InputGroup, InputGroupAddon, Menu, NumberInput, Popover, Portal, Select, Spacer, Text, Tooltip } from "@oliasoft-open-source/react-ui-library";
|
|
10
11
|
import { useMeasure } from "react-use";
|
|
@@ -12094,7 +12095,7 @@ function interpolate(table, val, reverse) {
|
|
|
12094
12095
|
const span = nextSource - prevSource;
|
|
12095
12096
|
return span ? prevTarget + (nextTarget - prevTarget) * (val - prevSource) / span : prevTarget;
|
|
12096
12097
|
}
|
|
12097
|
-
|
|
12098
|
+
var TimeSeriesScale = class extends TimeScale {
|
|
12098
12099
|
static id = "timeseries";
|
|
12099
12100
|
static defaults = TimeScale.defaults;
|
|
12100
12101
|
constructor(props) {
|
|
@@ -12163,7 +12164,7 @@ function interpolate(table, val, reverse) {
|
|
|
12163
12164
|
const decimal = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;
|
|
12164
12165
|
return interpolate(this._table, decimal * this._tableRange + this._minPos, true);
|
|
12165
12166
|
}
|
|
12166
|
-
}
|
|
12167
|
+
};
|
|
12167
12168
|
//#endregion
|
|
12168
12169
|
//#region node_modules/.pnpm/react-chartjs-2@5.3.1_chart.js@4.5.1_react@18.3.1/node_modules/react-chartjs-2/dist/index.js
|
|
12169
12170
|
var defaultDatasetIdKey = "label";
|
|
@@ -19069,6 +19070,8 @@ var ScaleType = /* @__PURE__ */ function(ScaleType) {
|
|
|
19069
19070
|
ScaleType["Category"] = "category";
|
|
19070
19071
|
ScaleType["Linear"] = "linear";
|
|
19071
19072
|
ScaleType["Logarithmic"] = "logarithmic";
|
|
19073
|
+
ScaleType["Time"] = "time";
|
|
19074
|
+
ScaleType["TimeSeries"] = "timeseries";
|
|
19072
19075
|
return ScaleType;
|
|
19073
19076
|
}({});
|
|
19074
19077
|
var ChartDirection = /* @__PURE__ */ function(ChartDirection) {
|
|
@@ -19874,7 +19877,7 @@ var isGreaterThanMin = (value, min) => {
|
|
|
19874
19877
|
* @param {boolean} [hasMultiAxes] - optional, false by default
|
|
19875
19878
|
* @return {string} - e.g. x if chart has singular axes; x, x2 - in case of multiple axes
|
|
19876
19879
|
*/
|
|
19877
|
-
var generateAxisId = (axisType, index = 0, hasMultiAxes = false) => {
|
|
19880
|
+
var generateAxisId$1 = (axisType, index = 0, hasMultiAxes = false) => {
|
|
19878
19881
|
return `${axisType}${hasMultiAxes && index !== 0 ? index + 1 : ""}`;
|
|
19879
19882
|
};
|
|
19880
19883
|
/**
|
|
@@ -19984,7 +19987,7 @@ var useChartFunctions = ({ chartRef, state, options, dispatch }) => {
|
|
|
19984
19987
|
if (!axes[axisType] || !axes[axisType]?.length) return [];
|
|
19985
19988
|
else return axes[axisType].map((axisObj, index) => {
|
|
19986
19989
|
return {
|
|
19987
|
-
id: generateAxisId(axisType, index, axes[axisType].length > 1),
|
|
19990
|
+
id: generateAxisId$1(axisType, index, axes[axisType].length > 1),
|
|
19988
19991
|
label: axisObj?.label || ""
|
|
19989
19992
|
};
|
|
19990
19993
|
});
|
|
@@ -20798,53 +20801,83 @@ var formatAxisLabelNumbers = (tickValue, ticks) => {
|
|
|
20798
20801
|
});
|
|
20799
20802
|
};
|
|
20800
20803
|
//#endregion
|
|
20801
|
-
//#region src/components/
|
|
20802
|
-
var
|
|
20803
|
-
|
|
20804
|
-
|
|
20805
|
-
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
|
|
20809
|
-
const
|
|
20810
|
-
|
|
20811
|
-
|
|
20812
|
-
|
|
20813
|
-
|
|
20814
|
-
|
|
20815
|
-
|
|
20816
|
-
|
|
20804
|
+
//#region src/components/common/helpers/get-cartesian-scale-options.ts
|
|
20805
|
+
var isNumericScale = (scaleType) => {
|
|
20806
|
+
return scaleType === ScaleType.Linear || scaleType === ScaleType.Logarithmic;
|
|
20807
|
+
};
|
|
20808
|
+
var getGridLines = (gridLines) => {
|
|
20809
|
+
return gridLines && typeof gridLines === "object" ? gridLines : {};
|
|
20810
|
+
};
|
|
20811
|
+
var getCartesianScaleOptions = ({ axisData, scaleType, scaleConfigFromProps, display, beginAtZero, reverse, suggestedMax, suggestedMin, min, max, additionalStepSize, useStepSize = true, stacked, numericTickCallback }) => {
|
|
20812
|
+
const ticksConfigFromProps = scaleConfigFromProps?.ticks;
|
|
20813
|
+
const titleConfigFromProps = scaleConfigFromProps?.title;
|
|
20814
|
+
const titleText = axisData?.label || (typeof axisData?.unit === "string" ? axisData.unit : void 0);
|
|
20815
|
+
const stepSize = useStepSize && isNumericScale(scaleType) && scaleType !== ScaleType.Logarithmic ? { stepSize: axisData?.stepSize ?? additionalStepSize } : {};
|
|
20816
|
+
return {
|
|
20817
|
+
...display !== void 0 ? { display } : {},
|
|
20818
|
+
type: scaleType,
|
|
20819
|
+
position: axisData?.position,
|
|
20820
|
+
beginAtZero,
|
|
20821
|
+
reverse,
|
|
20822
|
+
suggestedMax,
|
|
20823
|
+
suggestedMin,
|
|
20824
|
+
min,
|
|
20825
|
+
max,
|
|
20826
|
+
...stacked !== void 0 ? { stacked } : {},
|
|
20827
|
+
...scaleConfigFromProps,
|
|
20828
|
+
title: {
|
|
20829
|
+
display: Boolean(titleText?.length),
|
|
20830
|
+
text: titleText,
|
|
20831
|
+
padding: 0,
|
|
20832
|
+
...titleConfigFromProps,
|
|
20833
|
+
font: {
|
|
20834
|
+
size: 12,
|
|
20835
|
+
...titleConfigFromProps?.font
|
|
20836
|
+
}
|
|
20837
|
+
},
|
|
20838
|
+
ticks: {
|
|
20839
|
+
...stepSize,
|
|
20840
|
+
...isNumericScale(scaleType) && numericTickCallback ? { callback: numericTickCallback } : {},
|
|
20817
20841
|
includeBounds: false,
|
|
20818
20842
|
...ticksConfigFromProps,
|
|
20819
20843
|
font: {
|
|
20820
20844
|
size: 12,
|
|
20821
20845
|
...ticksConfigFromProps?.font
|
|
20822
20846
|
}
|
|
20823
|
-
}
|
|
20847
|
+
},
|
|
20848
|
+
grid: {
|
|
20849
|
+
...getGridLines(axisData?.gridLines),
|
|
20850
|
+
...scaleConfigFromProps?.grid
|
|
20851
|
+
}
|
|
20824
20852
|
};
|
|
20825
|
-
|
|
20853
|
+
};
|
|
20854
|
+
//#endregion
|
|
20855
|
+
//#region src/components/line-chart/utils/get-line-chart-scales.ts
|
|
20856
|
+
var getLineChartAxis = (options, axisType, state, currentScales, i = 0) => {
|
|
20857
|
+
const axisData = currentScales || options.axes[axisType][0] || {};
|
|
20858
|
+
const stateAxis = state?.axes.filter((axis) => axis?.id?.startsWith(axisType))[i];
|
|
20859
|
+
const axisKey = generateAxisId$1(axisType, i, true);
|
|
20860
|
+
const scaleConfigFromProps = options?.scales?.[axisKey];
|
|
20861
|
+
const { additionalAxesOptions } = options;
|
|
20862
|
+
const scaleType = scaleConfigFromProps?.type ?? additionalAxesOptions.chartScaleType;
|
|
20863
|
+
const ticksFormattingCallback = (tick, _, ticks) => {
|
|
20864
|
+
const tickValue = Number(tick);
|
|
20865
|
+
return scaleType === ScaleType.Logarithmic ? LOGARITHMIC_STEPS.includes(tickValue) ? formatAxisLabelNumbers(tickValue, ticks) : "" : formatAxisLabelNumbers(tickValue, ticks);
|
|
20866
|
+
};
|
|
20867
|
+
return getCartesianScaleOptions({
|
|
20868
|
+
axisData,
|
|
20869
|
+
scaleType,
|
|
20870
|
+
scaleConfigFromProps,
|
|
20826
20871
|
display: true,
|
|
20827
|
-
type: additionalAxesOptions.chartScaleType,
|
|
20828
|
-
position: axisData.position,
|
|
20829
20872
|
beginAtZero: additionalAxesOptions.beginAtZero,
|
|
20830
20873
|
reverse: axisType === AxisType.Y ? additionalAxesOptions.reverse : false,
|
|
20831
20874
|
suggestedMax: additionalAxesOptions.suggestedMax,
|
|
20832
20875
|
suggestedMin: additionalAxesOptions.suggestedMin,
|
|
20833
20876
|
min: stateAxis?.min ?? additionalAxesOptions?.range?.[axisType]?.min,
|
|
20834
20877
|
max: stateAxis?.max ?? additionalAxesOptions?.range?.[axisType]?.max,
|
|
20835
|
-
|
|
20836
|
-
|
|
20837
|
-
|
|
20838
|
-
padding: 0,
|
|
20839
|
-
...titleConfigFromProps,
|
|
20840
|
-
font: {
|
|
20841
|
-
size: 12,
|
|
20842
|
-
...titleConfigFromProps?.font
|
|
20843
|
-
}
|
|
20844
|
-
},
|
|
20845
|
-
ticks: getTicks(),
|
|
20846
|
-
grid: { ...axisData.gridLines }
|
|
20847
|
-
};
|
|
20878
|
+
additionalStepSize: axisType === AxisType.Y ? additionalAxesOptions.stepSize : null,
|
|
20879
|
+
numericTickCallback: ticksFormattingCallback
|
|
20880
|
+
});
|
|
20848
20881
|
};
|
|
20849
20882
|
var getLineChartAxes = (options, axisType, state) => {
|
|
20850
20883
|
return options.axes[axisType].reduce((acc, curr, i) => {
|
|
@@ -20852,7 +20885,7 @@ var getLineChartAxes = (options, axisType, state) => {
|
|
|
20852
20885
|
axisData.color = curr.color || COLORS[i] || generateRandomColor(COLORS);
|
|
20853
20886
|
axisData.position = curr.position || getAxisPosition(axisType, i);
|
|
20854
20887
|
const axis = getLineChartAxis(options, axisType, state, axisData, i);
|
|
20855
|
-
const axisId = generateAxisId(axisType, i, true);
|
|
20888
|
+
const axisId = generateAxisId$1(axisType, i, true);
|
|
20856
20889
|
return {
|
|
20857
20890
|
...acc,
|
|
20858
20891
|
[axisId]: axis
|
|
@@ -20871,6 +20904,11 @@ var getLineChartScales = (options, state) => {
|
|
|
20871
20904
|
};
|
|
20872
20905
|
//#endregion
|
|
20873
20906
|
//#region src/components/common/helpers/range/estimate-data-series-have-close-values.ts
|
|
20907
|
+
var getFiniteNumber = (value) => {
|
|
20908
|
+
if (!isNumber(value) && !isString(value)) return;
|
|
20909
|
+
const numericValue = toNum(value);
|
|
20910
|
+
return isFinite$1(numericValue) ? numericValue : void 0;
|
|
20911
|
+
};
|
|
20874
20912
|
/**
|
|
20875
20913
|
* Estimates whether any of the data series has values that are all close together
|
|
20876
20914
|
* - checks only the first and last values in each series (i.e. assumes they are ordered)
|
|
@@ -20884,8 +20922,13 @@ var estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
|
|
|
20884
20922
|
const yAxisId = dataset?.yAxisID ?? "y";
|
|
20885
20923
|
const data = dataset?.data ?? [];
|
|
20886
20924
|
if (data && data?.length) {
|
|
20887
|
-
const { x:
|
|
20888
|
-
const { x:
|
|
20925
|
+
const { x: rawXFirstCurrent, y: rawYFirstCurrent } = data?.[0] ?? {};
|
|
20926
|
+
const { x: rawXLastCurrent, y: rawYLastCurrent } = data?.at(-1) ?? {};
|
|
20927
|
+
const xFirstCurrent = getFiniteNumber(rawXFirstCurrent);
|
|
20928
|
+
const yFirstCurrent = getFiniteNumber(rawYFirstCurrent);
|
|
20929
|
+
const xLastCurrent = getFiniteNumber(rawXLastCurrent);
|
|
20930
|
+
const yLastCurrent = getFiniteNumber(rawYLastCurrent);
|
|
20931
|
+
if (xFirstCurrent === void 0 || yFirstCurrent === void 0 || xLastCurrent === void 0 || yLastCurrent === void 0) return acc;
|
|
20889
20932
|
const xFirstAcc = acc?.[xAxisId]?.xFirst ?? xFirstCurrent;
|
|
20890
20933
|
const xLastAcc = acc?.[xAxisId]?.xLast ?? xLastCurrent;
|
|
20891
20934
|
const yFirstAcc = acc?.[yAxisId]?.yFirst ?? yFirstCurrent;
|
|
@@ -24506,7 +24549,7 @@ var Legend = ({ chartRef, legendConfig }) => {
|
|
|
24506
24549
|
};
|
|
24507
24550
|
//#endregion
|
|
24508
24551
|
//#region src/components/line-chart/line-chart.tsx
|
|
24509
|
-
Chart$1.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, plugin_legend, plugin_tooltip, plugin_title, index, plugin$1, plugin, annotation, chartAreaTextPlugin, annotationDraggerPlugin, ellipsisAnnotationPlugin, calloutConnectorPlugin, lineMarkersPlugin);
|
|
24552
|
+
Chart$1.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, TimeScale, TimeSeriesScale, plugin_legend, plugin_tooltip, plugin_title, index, plugin$1, plugin, annotation, chartAreaTextPlugin, annotationDraggerPlugin, ellipsisAnnotationPlugin, calloutConnectorPlugin, lineMarkersPlugin);
|
|
24510
24553
|
var LineChart = (props) => {
|
|
24511
24554
|
setDefaultTheme();
|
|
24512
24555
|
const chartRef = useRef(null);
|
|
@@ -38830,68 +38873,42 @@ var getStackedOptions = (axisType, { stacked, stackedX, stackedY }) => {
|
|
|
38830
38873
|
else if (axisType === AxisType.Y) return stackedY ?? stacked;
|
|
38831
38874
|
return stacked;
|
|
38832
38875
|
};
|
|
38833
|
-
var
|
|
38876
|
+
var generateAxisId = (axisType, index = 0) => {
|
|
38877
|
+
return index === 0 ? axisType : `${axisType}${index + 1}`;
|
|
38878
|
+
};
|
|
38879
|
+
var getBarChartAxis = ({ chart, axisType = AxisType.X, currentScale, i = 0 }) => {
|
|
38834
38880
|
const { data, options } = chart ?? {};
|
|
38835
38881
|
const isDirectionVertical = isVertical(options.direction);
|
|
38836
38882
|
const axisData = currentScale || options?.axes?.[axisType]?.[0];
|
|
38837
38883
|
const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
|
|
38838
|
-
const
|
|
38839
|
-
const
|
|
38884
|
+
const axisKey = generateAxisId(axisType, i);
|
|
38885
|
+
const scaleConfigFromProps = options?.scales?.[axisKey];
|
|
38886
|
+
const getDefaultScaleType = () => {
|
|
38840
38887
|
const scaleType = data.labels ? ScaleType.Category : ScaleType.Linear;
|
|
38841
38888
|
return axisType === (isDirectionVertical ? AxisType.X : AxisType.Y) ? scaleType : options?.additionalAxesOptions?.chartScaleType;
|
|
38842
38889
|
};
|
|
38890
|
+
const scaleType = scaleConfigFromProps?.type ?? getDefaultScaleType();
|
|
38843
38891
|
const getReverse = () => {
|
|
38844
38892
|
return axisType === (isDirectionVertical ? AxisType.Y : AxisType.X) ? options?.additionalAxesOptions?.reverse : false;
|
|
38845
38893
|
};
|
|
38846
|
-
const
|
|
38847
|
-
|
|
38848
|
-
const getTicks = () => {
|
|
38849
|
-
const additionalAxesOptions = options?.additionalAxesOptions;
|
|
38850
|
-
const ticksConfigFromProps = options?.scales?.[axisKey]?.ticks;
|
|
38851
|
-
const isLogarithmic = isDirectionCompatibleWithAxisType && additionalAxesOptions?.chartScaleType === ScaleType.Logarithmic;
|
|
38852
|
-
const ticksFormattingCallback = (tick, _, ticks) => {
|
|
38853
|
-
return isLogarithmic ? LOGARITHMIC_STEPS.includes(Number(tick)) ? formatAxisLabelNumbers(tick, ticks) : "" : formatAxisLabelNumbers(tick, ticks);
|
|
38854
|
-
};
|
|
38855
|
-
const ticks = {
|
|
38856
|
-
...!isLogarithmic ? { stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions?.stepSize : null) } : {},
|
|
38857
|
-
includeBounds: false,
|
|
38858
|
-
...ticksConfigFromProps,
|
|
38859
|
-
font: {
|
|
38860
|
-
size: 12,
|
|
38861
|
-
...ticksConfigFromProps?.font
|
|
38862
|
-
}
|
|
38863
|
-
};
|
|
38864
|
-
if (additionalAxesOptions?.chartScaleType === ScaleType.Logarithmic) ticks.callback = ticksFormattingCallback;
|
|
38865
|
-
return ticks;
|
|
38894
|
+
const ticksFormattingCallback = (tick, _, ticks) => {
|
|
38895
|
+
return isDirectionCompatibleWithAxisType && scaleType === ScaleType.Logarithmic ? LOGARITHMIC_STEPS.includes(Number(tick)) ? formatAxisLabelNumbers(tick, ticks) : "" : formatAxisLabelNumbers(tick, ticks);
|
|
38866
38896
|
};
|
|
38867
|
-
return {
|
|
38868
|
-
|
|
38869
|
-
|
|
38897
|
+
return getCartesianScaleOptions({
|
|
38898
|
+
axisData,
|
|
38899
|
+
scaleType,
|
|
38900
|
+
scaleConfigFromProps,
|
|
38870
38901
|
beginAtZero: options?.additionalAxesOptions?.beginAtZero,
|
|
38871
38902
|
reverse: getReverse(),
|
|
38872
38903
|
suggestedMax: options?.additionalAxesOptions?.suggestedMax,
|
|
38873
38904
|
suggestedMin: options?.additionalAxesOptions?.suggestedMin,
|
|
38874
38905
|
min: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.min : void 0,
|
|
38875
38906
|
max: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.max : void 0,
|
|
38876
|
-
|
|
38877
|
-
|
|
38878
|
-
|
|
38879
|
-
|
|
38880
|
-
...titleConfigFromProps,
|
|
38881
|
-
font: {
|
|
38882
|
-
size: 12,
|
|
38883
|
-
...titleConfigFromProps?.font
|
|
38884
|
-
}
|
|
38885
|
-
},
|
|
38886
|
-
ticks: getTicks(),
|
|
38887
|
-
grid: { ...grid },
|
|
38888
|
-
stacked: getStackedOptions(axisType, options?.additionalAxesOptions)
|
|
38889
|
-
};
|
|
38907
|
+
additionalStepSize: axisType === AxisType.Y ? options?.additionalAxesOptions?.stepSize : null,
|
|
38908
|
+
stacked: getStackedOptions(axisType, options?.additionalAxesOptions),
|
|
38909
|
+
numericTickCallback: ticksFormattingCallback
|
|
38910
|
+
});
|
|
38890
38911
|
};
|
|
38891
|
-
/**
|
|
38892
|
-
* @param {IBarChartData} chart - chart data
|
|
38893
|
-
* @param {'x'|'y'} axisType
|
|
38894
|
-
*/
|
|
38895
38912
|
var getBarChartAxes = (chart, axisType) => {
|
|
38896
38913
|
return (chart?.options?.axes?.[axisType] || []).reduce((acc, curr, i) => {
|
|
38897
38914
|
const axisData = curr;
|
|
@@ -38900,9 +38917,10 @@ var getBarChartAxes = (chart, axisType) => {
|
|
|
38900
38917
|
const axis = getBarChartAxis({
|
|
38901
38918
|
chart,
|
|
38902
38919
|
axisType,
|
|
38903
|
-
currentScale: axisData
|
|
38920
|
+
currentScale: axisData,
|
|
38921
|
+
i
|
|
38904
38922
|
});
|
|
38905
|
-
const axisId =
|
|
38923
|
+
const axisId = generateAxisId(axisType, i);
|
|
38906
38924
|
return {
|
|
38907
38925
|
...acc,
|
|
38908
38926
|
[axisId]: axis
|
|
@@ -39166,6 +39184,7 @@ var normalizeBarOptions = (options = {}) => ({
|
|
|
39166
39184
|
chartStyling: defaultChartStyling$1(options?.chartStyling),
|
|
39167
39185
|
tooltip: defaultTooltip$1(options?.tooltip),
|
|
39168
39186
|
graph: defaultGraph$1(options?.graph),
|
|
39187
|
+
scales: options?.scales ?? {},
|
|
39169
39188
|
annotations: defaultAnnotations$1(options?.annotations),
|
|
39170
39189
|
legend: defaultLegend$1(options?.legend),
|
|
39171
39190
|
chartOptions: defaultChartOptions$1(options?.chartOptions),
|
|
@@ -39194,7 +39213,7 @@ var getDefaultProps$1 = (props) => {
|
|
|
39194
39213
|
};
|
|
39195
39214
|
//#endregion
|
|
39196
39215
|
//#region src/components/bar-chart/bar-chart.tsx
|
|
39197
|
-
Chart$1.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, BarElement, plugin_legend, plugin_tooltip, plugin_title, index, plugin$1, plugin, annotation, import_chartjs_plugin_dragdata_min.default);
|
|
39216
|
+
Chart$1.register(LinearScale, PointElement, LineElement, CategoryScale, LogarithmicScale, TimeScale, TimeSeriesScale, BarElement, plugin_legend, plugin_tooltip, plugin_title, index, plugin$1, plugin, annotation, import_chartjs_plugin_dragdata_min.default);
|
|
39198
39217
|
var BarChart = (props) => {
|
|
39199
39218
|
setDefaultTheme();
|
|
39200
39219
|
const chartRef = useRef(null);
|
|
@@ -39305,46 +39324,23 @@ var getScatterChartAxis = ({ options, axisType = AxisType.X, currentScale }) =>
|
|
|
39305
39324
|
const isDirectionVertical = isVertical(options.direction);
|
|
39306
39325
|
const axisData = currentScale || options?.axes?.[axisType]?.[0];
|
|
39307
39326
|
const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
|
|
39308
|
-
const
|
|
39309
|
-
const
|
|
39310
|
-
const titleConfigFromProps = options?.scales?.[axisType]?.title;
|
|
39327
|
+
const scaleConfigFromProps = options?.scales?.[axisType];
|
|
39328
|
+
const scaleType = scaleConfigFromProps?.type ?? options?.additionalAxesOptions?.chartScaleType ?? ScaleType.Linear;
|
|
39311
39329
|
const getReverse = () => {
|
|
39312
39330
|
return axisType === (isDirectionVertical ? AxisType.Y : AxisType.X) ? options?.additionalAxesOptions?.reverse : false;
|
|
39313
39331
|
};
|
|
39314
|
-
|
|
39315
|
-
|
|
39316
|
-
|
|
39317
|
-
|
|
39318
|
-
includeBounds: false,
|
|
39319
|
-
...ticksConfigFromProps,
|
|
39320
|
-
font: {
|
|
39321
|
-
size: 12,
|
|
39322
|
-
...ticksConfigFromProps?.font
|
|
39323
|
-
}
|
|
39324
|
-
};
|
|
39325
|
-
};
|
|
39326
|
-
return {
|
|
39327
|
-
type: ScaleType.Linear,
|
|
39328
|
-
position: axisData?.position,
|
|
39332
|
+
return getCartesianScaleOptions({
|
|
39333
|
+
axisData,
|
|
39334
|
+
scaleType,
|
|
39335
|
+
scaleConfigFromProps,
|
|
39329
39336
|
beginAtZero: options?.additionalAxesOptions?.beginAtZero,
|
|
39330
39337
|
reverse: getReverse(),
|
|
39331
39338
|
suggestedMax: options?.additionalAxesOptions?.suggestedMax,
|
|
39332
39339
|
suggestedMin: options?.additionalAxesOptions?.suggestedMin,
|
|
39333
39340
|
min: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.min : void 0,
|
|
39334
39341
|
max: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.max : void 0,
|
|
39335
|
-
|
|
39336
|
-
|
|
39337
|
-
text: axisData?.label || axisData?.unit,
|
|
39338
|
-
padding: 0,
|
|
39339
|
-
...titleConfigFromProps,
|
|
39340
|
-
font: {
|
|
39341
|
-
size: 12,
|
|
39342
|
-
...titleConfigFromProps?.font
|
|
39343
|
-
}
|
|
39344
|
-
},
|
|
39345
|
-
ticks: getTicks(),
|
|
39346
|
-
grid: { ...grid }
|
|
39347
|
-
};
|
|
39342
|
+
additionalStepSize: axisType === AxisType.Y ? options?.additionalAxesOptions?.stepSize : null
|
|
39343
|
+
});
|
|
39348
39344
|
};
|
|
39349
39345
|
var getScatterChartScales = (options) => {
|
|
39350
39346
|
return {
|
|
@@ -39508,6 +39504,7 @@ var defaultAxes = (axes) => ({
|
|
|
39508
39504
|
y: axes?.y ?? [{}]
|
|
39509
39505
|
});
|
|
39510
39506
|
var defaultAdditionalAxesOptions = (options) => ({
|
|
39507
|
+
chartScaleType: options?.chartScaleType || "linear",
|
|
39511
39508
|
reverse: options?.reverse ?? false,
|
|
39512
39509
|
stacked: options?.stacked ?? false,
|
|
39513
39510
|
beginAtZero: options?.beginAtZero ?? true,
|
|
@@ -39525,6 +39522,7 @@ var normalizeScatterOptions = (options = {}) => ({
|
|
|
39525
39522
|
chartStyling: defaultChartStyling(options?.chartStyling),
|
|
39526
39523
|
tooltip: defaultTooltip(options?.tooltip),
|
|
39527
39524
|
graph: defaultGraph(options?.graph),
|
|
39525
|
+
scales: options?.scales ?? {},
|
|
39528
39526
|
legend: defaultLegend(options?.legend),
|
|
39529
39527
|
annotations: defaultAnnotations(options?.annotations),
|
|
39530
39528
|
chartOptions: defaultChartOptions(options?.chartOptions),
|
|
@@ -39631,7 +39629,7 @@ var scatter_chart_module_default = {
|
|
|
39631
39629
|
};
|
|
39632
39630
|
//#endregion
|
|
39633
39631
|
//#region src/components/scatter-chart/scatter-chart.tsx
|
|
39634
|
-
Chart$1.register(LinearScale, PointElement, CategoryScale, plugin_legend, plugin_tooltip, plugin_title, plugin$1, plugin, annotation, gradientBackgroundPlugin);
|
|
39632
|
+
Chart$1.register(LinearScale, PointElement, CategoryScale, TimeScale, TimeSeriesScale, plugin_legend, plugin_tooltip, plugin_title, plugin$1, plugin, annotation, gradientBackgroundPlugin);
|
|
39635
39633
|
var ScatterChart = (props) => {
|
|
39636
39634
|
setDefaultTheme();
|
|
39637
39635
|
const chartRef = useRef(null);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IBarDefaultProps } from '../bar-chart.interface';
|
|
2
|
-
|
|
2
|
+
import { ICommonScaleOptions } from '../../common/common.interface';
|
|
3
|
+
declare const getBarChartScales: (chart: IBarDefaultProps) => Record<string, ICommonScaleOptions>;
|
|
3
4
|
export default getBarChartScales;
|
|
@@ -17,7 +17,7 @@ export declare const useBarChartOptions: ({ chart, chartRef, }: IUseBarChartOpti
|
|
|
17
17
|
mode: ChartHoverMode;
|
|
18
18
|
intersect: boolean;
|
|
19
19
|
};
|
|
20
|
-
scales:
|
|
20
|
+
scales: Record<string, import('../../common/common.interface').ICommonScaleOptions>;
|
|
21
21
|
plugins: {
|
|
22
22
|
title: {
|
|
23
23
|
display: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartEvent, ChartTypeRegistry,
|
|
1
|
+
import { ChartEvent, ChartTypeRegistry, Plugin, ScaleOptions } from 'chart.js';
|
|
2
2
|
import { LabelOptions } from 'chartjs-plugin-annotation';
|
|
3
3
|
import { GradientDirection } from './plugins/gradient-background-plugin/enums';
|
|
4
4
|
import { AnnotationType as DraggableAnnotationType, DragAxis } from './plugins/annotation-dragger-plugin/enums';
|
|
@@ -9,8 +9,8 @@ export type DeepPartial<T> = T extends (...args: unknown[]) => unknown ? T : T e
|
|
|
9
9
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
10
10
|
} : T;
|
|
11
11
|
export interface ICommonDataValue {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
12
|
+
x: number | string;
|
|
13
|
+
y: number | string;
|
|
14
14
|
label?: string;
|
|
15
15
|
}
|
|
16
16
|
export interface ICommonDataset {
|
|
@@ -21,10 +21,8 @@ export interface ICommonDataset {
|
|
|
21
21
|
data: ICommonDataValue[];
|
|
22
22
|
hidden?: boolean;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
y: LinearScaleOptions;
|
|
27
|
-
}
|
|
24
|
+
export type ICommonScaleOptions = ScaleOptions<'category'> | ScaleOptions<'linear'> | ScaleOptions<'logarithmic'> | ScaleOptions<'time'> | ScaleOptions<'timeseries'>;
|
|
25
|
+
export type ICommonScales = Partial<Record<string, ICommonScaleOptions>>;
|
|
28
26
|
export interface ICommonAnnotationElement {
|
|
29
27
|
id?: string;
|
|
30
28
|
display: boolean;
|
|
@@ -152,15 +150,15 @@ export interface ICommonTooltip {
|
|
|
152
150
|
callbacks?: ICommonTooltipCallbacks;
|
|
153
151
|
}
|
|
154
152
|
export interface ICommonAdditionalAxesOptions {
|
|
155
|
-
chartScaleType?: 'linear' | 'logarithmic';
|
|
153
|
+
chartScaleType?: 'linear' | 'logarithmic' | 'time' | 'timeseries';
|
|
156
154
|
reverse?: boolean;
|
|
157
155
|
beginAtZero?: boolean;
|
|
158
156
|
stepSize?: number;
|
|
159
157
|
stacked?: boolean;
|
|
160
158
|
suggestedMin?: number;
|
|
161
159
|
suggestedMax?: number;
|
|
162
|
-
min?: number;
|
|
163
|
-
max?: number;
|
|
160
|
+
min?: number | string;
|
|
161
|
+
max?: number | string;
|
|
164
162
|
}
|
|
165
163
|
export interface ICommonAnnotation {
|
|
166
164
|
showLabel?: boolean;
|
|
@@ -30,7 +30,9 @@ export declare enum CursorStyle {
|
|
|
30
30
|
export declare enum ScaleType {
|
|
31
31
|
Category = "category",
|
|
32
32
|
Linear = "linear",
|
|
33
|
-
Logarithmic = "logarithmic"
|
|
33
|
+
Logarithmic = "logarithmic",
|
|
34
|
+
Time = "time",
|
|
35
|
+
TimeSeries = "timeseries"
|
|
34
36
|
}
|
|
35
37
|
export declare enum ChartDirection {
|
|
36
38
|
VERTICAL = "vertical",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Tick } from 'chart.js';
|
|
2
|
+
import { ICommonScaleOptions, UnusedParameter } from '../common.interface';
|
|
3
|
+
type TScaleType = NonNullable<ICommonScaleOptions['type']>;
|
|
4
|
+
interface IGetCartesianScaleOptionsParams {
|
|
5
|
+
axisData?: {
|
|
6
|
+
gridLines?: unknown;
|
|
7
|
+
label?: string;
|
|
8
|
+
position?: unknown;
|
|
9
|
+
stepSize?: number;
|
|
10
|
+
unit?: unknown;
|
|
11
|
+
};
|
|
12
|
+
scaleType?: TScaleType;
|
|
13
|
+
scaleConfigFromProps?: ICommonScaleOptions;
|
|
14
|
+
display?: boolean;
|
|
15
|
+
beginAtZero?: boolean;
|
|
16
|
+
reverse?: boolean;
|
|
17
|
+
suggestedMax?: number | string;
|
|
18
|
+
suggestedMin?: number | string;
|
|
19
|
+
min?: number | string;
|
|
20
|
+
max?: number | string;
|
|
21
|
+
additionalStepSize?: number | null;
|
|
22
|
+
useStepSize?: boolean;
|
|
23
|
+
stacked?: boolean;
|
|
24
|
+
numericTickCallback?: (tick: string | number, unused: UnusedParameter, ticks: Tick[]) => unknown;
|
|
25
|
+
}
|
|
26
|
+
export declare const getCartesianScaleOptions: ({ axisData, scaleType, scaleConfigFromProps, display, beginAtZero, reverse, suggestedMax, suggestedMin, min, max, additionalStepSize, useStepSize, stacked, numericTickCallback, }: IGetCartesianScaleOptionsParams) => ICommonScaleOptions;
|
|
27
|
+
export {};
|
|
@@ -19,14 +19,14 @@ export interface ILineChartTooltip extends ICommonTooltip {
|
|
|
19
19
|
scientificNotation?: boolean;
|
|
20
20
|
}
|
|
21
21
|
export interface ILineChartRange {
|
|
22
|
-
min?: number;
|
|
23
|
-
max?: number;
|
|
22
|
+
min?: number | string;
|
|
23
|
+
max?: number | string;
|
|
24
24
|
}
|
|
25
25
|
export interface ILineRange {
|
|
26
26
|
[key: string]: ILineChartRange;
|
|
27
27
|
}
|
|
28
28
|
export interface ILineChartAdditionalAxesOptions {
|
|
29
|
-
chartScaleType?: 'linear' | 'logarithmic';
|
|
29
|
+
chartScaleType?: 'linear' | 'logarithmic' | 'time' | 'timeseries';
|
|
30
30
|
reverse?: boolean;
|
|
31
31
|
beginAtZero?: boolean;
|
|
32
32
|
stepSize?: number;
|