@oliasoft-open-source/charts-library 5.15.0-beta-1 → 5.15.0-beta-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/index.js +115 -121
- 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 +3 -3
- package/dist/src/components/common/helpers/get-cartesian-scale-options.d.ts +28 -0
- package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +2 -474
- 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 -475
- package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19877,7 +19877,7 @@ var isGreaterThanMin = (value, min) => {
|
|
|
19877
19877
|
* @param {boolean} [hasMultiAxes] - optional, false by default
|
|
19878
19878
|
* @return {string} - e.g. x if chart has singular axes; x, x2 - in case of multiple axes
|
|
19879
19879
|
*/
|
|
19880
|
-
var generateAxisId = (axisType, index = 0, hasMultiAxes = false) => {
|
|
19880
|
+
var generateAxisId$1 = (axisType, index = 0, hasMultiAxes = false) => {
|
|
19881
19881
|
return `${axisType}${hasMultiAxes && index !== 0 ? index + 1 : ""}`;
|
|
19882
19882
|
};
|
|
19883
19883
|
/**
|
|
@@ -19987,7 +19987,7 @@ var useChartFunctions = ({ chartRef, state, options, dispatch }) => {
|
|
|
19987
19987
|
if (!axes[axisType] || !axes[axisType]?.length) return [];
|
|
19988
19988
|
else return axes[axisType].map((axisObj, index) => {
|
|
19989
19989
|
return {
|
|
19990
|
-
id: generateAxisId(axisType, index, axes[axisType].length > 1),
|
|
19990
|
+
id: generateAxisId$1(axisType, index, axes[axisType].length > 1),
|
|
19991
19991
|
label: axisObj?.label || ""
|
|
19992
19992
|
};
|
|
19993
19993
|
});
|
|
@@ -20801,48 +20801,36 @@ var formatAxisLabelNumbers = (tickValue, ticks) => {
|
|
|
20801
20801
|
});
|
|
20802
20802
|
};
|
|
20803
20803
|
//#endregion
|
|
20804
|
-
//#region src/components/
|
|
20805
|
-
var
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
|
|
20809
|
-
|
|
20804
|
+
//#region src/components/common/helpers/get-cartesian-scale-options.ts
|
|
20805
|
+
var isTimeScaleType = (scaleType) => {
|
|
20806
|
+
return scaleType === ScaleType.Time || scaleType === ScaleType.TimeSeries;
|
|
20807
|
+
};
|
|
20808
|
+
var isNumericScale = (scaleType) => {
|
|
20809
|
+
return scaleType === ScaleType.Linear || scaleType === ScaleType.Logarithmic;
|
|
20810
|
+
};
|
|
20811
|
+
var getGridLines = (gridLines) => {
|
|
20812
|
+
return gridLines && typeof gridLines === "object" ? gridLines : {};
|
|
20813
|
+
};
|
|
20814
|
+
var getCartesianScaleOptions = ({ axisData, scaleType, scaleConfigFromProps, display, beginAtZero, reverse, suggestedMax, suggestedMin, min, max, additionalStepSize, useStepSize = true, stacked, numericTickCallback }) => {
|
|
20810
20815
|
const ticksConfigFromProps = scaleConfigFromProps?.ticks;
|
|
20811
20816
|
const titleConfigFromProps = scaleConfigFromProps?.title;
|
|
20812
|
-
const
|
|
20813
|
-
const
|
|
20814
|
-
const getTicks = () => {
|
|
20815
|
-
const isLogarithmic = scaleType === ScaleType.Logarithmic;
|
|
20816
|
-
const isNumericScale = scaleType === ScaleType.Linear || scaleType === ScaleType.Logarithmic;
|
|
20817
|
-
const ticksFormattingCallback = (tick, _, ticks) => {
|
|
20818
|
-
const tickValue = Number(tick);
|
|
20819
|
-
return isLogarithmic ? LOGARITHMIC_STEPS.includes(tickValue) ? formatAxisLabelNumbers(tickValue, ticks) : "" : formatAxisLabelNumbers(tickValue, ticks);
|
|
20820
|
-
};
|
|
20821
|
-
return {
|
|
20822
|
-
...isNumericScale && !isLogarithmic ? { stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions.stepSize : null) } : {},
|
|
20823
|
-
...isNumericScale ? { callback: ticksFormattingCallback } : {},
|
|
20824
|
-
includeBounds: false,
|
|
20825
|
-
...ticksConfigFromProps,
|
|
20826
|
-
font: {
|
|
20827
|
-
size: 12,
|
|
20828
|
-
...ticksConfigFromProps?.font
|
|
20829
|
-
}
|
|
20830
|
-
};
|
|
20831
|
-
};
|
|
20817
|
+
const titleText = axisData?.label || (typeof axisData?.unit === "string" ? axisData.unit : void 0);
|
|
20818
|
+
const stepSize = useStepSize && isNumericScale(scaleType) && scaleType !== ScaleType.Logarithmic ? { stepSize: axisData?.stepSize ?? additionalStepSize } : {};
|
|
20832
20819
|
return {
|
|
20833
|
-
display:
|
|
20820
|
+
...display !== void 0 ? { display } : {},
|
|
20834
20821
|
type: scaleType,
|
|
20835
|
-
position: axisData
|
|
20836
|
-
beginAtZero
|
|
20837
|
-
reverse
|
|
20838
|
-
suggestedMax
|
|
20839
|
-
suggestedMin
|
|
20840
|
-
min
|
|
20841
|
-
max
|
|
20822
|
+
position: axisData?.position,
|
|
20823
|
+
beginAtZero,
|
|
20824
|
+
reverse,
|
|
20825
|
+
suggestedMax,
|
|
20826
|
+
suggestedMin,
|
|
20827
|
+
min,
|
|
20828
|
+
max,
|
|
20829
|
+
...stacked !== void 0 ? { stacked } : {},
|
|
20842
20830
|
...scaleConfigFromProps,
|
|
20843
20831
|
title: {
|
|
20844
|
-
display: Boolean(
|
|
20845
|
-
text:
|
|
20832
|
+
display: Boolean(titleText?.length),
|
|
20833
|
+
text: titleText,
|
|
20846
20834
|
padding: 0,
|
|
20847
20835
|
...titleConfigFromProps,
|
|
20848
20836
|
font: {
|
|
@@ -20850,20 +20838,57 @@ var getLineChartAxis = (options, axisType, state, currentScales, i = 0) => {
|
|
|
20850
20838
|
...titleConfigFromProps?.font
|
|
20851
20839
|
}
|
|
20852
20840
|
},
|
|
20853
|
-
ticks:
|
|
20841
|
+
ticks: {
|
|
20842
|
+
...stepSize,
|
|
20843
|
+
...isNumericScale(scaleType) && numericTickCallback ? { callback: numericTickCallback } : {},
|
|
20844
|
+
includeBounds: false,
|
|
20845
|
+
...ticksConfigFromProps,
|
|
20846
|
+
font: {
|
|
20847
|
+
size: 12,
|
|
20848
|
+
...ticksConfigFromProps?.font
|
|
20849
|
+
}
|
|
20850
|
+
},
|
|
20854
20851
|
grid: {
|
|
20855
|
-
...axisData
|
|
20852
|
+
...getGridLines(axisData?.gridLines),
|
|
20856
20853
|
...scaleConfigFromProps?.grid
|
|
20857
20854
|
}
|
|
20858
20855
|
};
|
|
20859
20856
|
};
|
|
20857
|
+
//#endregion
|
|
20858
|
+
//#region src/components/line-chart/utils/get-line-chart-scales.ts
|
|
20859
|
+
var getLineChartAxis = (options, axisType, state, currentScales, i = 0) => {
|
|
20860
|
+
const axisData = currentScales || options.axes[axisType][0] || {};
|
|
20861
|
+
const stateAxis = state?.axes.filter((axis) => axis?.id?.startsWith(axisType))[i];
|
|
20862
|
+
const axisKey = generateAxisId$1(axisType, i, true);
|
|
20863
|
+
const scaleConfigFromProps = options?.scales?.[axisKey];
|
|
20864
|
+
const { additionalAxesOptions } = options;
|
|
20865
|
+
const scaleType = scaleConfigFromProps?.type ?? additionalAxesOptions.chartScaleType;
|
|
20866
|
+
const ticksFormattingCallback = (tick, _, ticks) => {
|
|
20867
|
+
const tickValue = Number(tick);
|
|
20868
|
+
return scaleType === ScaleType.Logarithmic ? LOGARITHMIC_STEPS.includes(tickValue) ? formatAxisLabelNumbers(tickValue, ticks) : "" : formatAxisLabelNumbers(tickValue, ticks);
|
|
20869
|
+
};
|
|
20870
|
+
return getCartesianScaleOptions({
|
|
20871
|
+
axisData,
|
|
20872
|
+
scaleType,
|
|
20873
|
+
scaleConfigFromProps,
|
|
20874
|
+
display: true,
|
|
20875
|
+
beginAtZero: additionalAxesOptions.beginAtZero,
|
|
20876
|
+
reverse: axisType === AxisType.Y ? additionalAxesOptions.reverse : false,
|
|
20877
|
+
suggestedMax: additionalAxesOptions.suggestedMax,
|
|
20878
|
+
suggestedMin: additionalAxesOptions.suggestedMin,
|
|
20879
|
+
min: stateAxis?.min ?? additionalAxesOptions?.range?.[axisType]?.min,
|
|
20880
|
+
max: stateAxis?.max ?? additionalAxesOptions?.range?.[axisType]?.max,
|
|
20881
|
+
additionalStepSize: axisType === AxisType.Y ? additionalAxesOptions.stepSize : null,
|
|
20882
|
+
numericTickCallback: ticksFormattingCallback
|
|
20883
|
+
});
|
|
20884
|
+
};
|
|
20860
20885
|
var getLineChartAxes = (options, axisType, state) => {
|
|
20861
20886
|
return options.axes[axisType].reduce((acc, curr, i) => {
|
|
20862
20887
|
const axisData = curr;
|
|
20863
20888
|
axisData.color = curr.color || COLORS[i] || generateRandomColor(COLORS);
|
|
20864
20889
|
axisData.position = curr.position || getAxisPosition(axisType, i);
|
|
20865
20890
|
const axis = getLineChartAxis(options, axisType, state, axisData, i);
|
|
20866
|
-
const axisId = generateAxisId(axisType, i, true);
|
|
20891
|
+
const axisId = generateAxisId$1(axisType, i, true);
|
|
20867
20892
|
return {
|
|
20868
20893
|
...acc,
|
|
20869
20894
|
[axisId]: axis
|
|
@@ -21176,13 +21201,20 @@ var getLineChartToolTips = (options) => {
|
|
|
21176
21201
|
const titleCallback = (tooltipItem) => {
|
|
21177
21202
|
if (!tooltipItem?.[0]) return "";
|
|
21178
21203
|
const { titleLabel = "", titleAxisLabel = "" } = getTooltipLabels(tooltipItem[0].dataset) ?? {};
|
|
21179
|
-
|
|
21204
|
+
const titleAxisId = titleLabel === TooltipLabel.Y ? tooltipItem[0].dataset?.yAxisID ?? "y" : tooltipItem[0].dataset?.xAxisID ?? "x";
|
|
21205
|
+
const titleScaleType = options?.scales?.[titleAxisId]?.type;
|
|
21206
|
+
const titleValue = isTimeScaleType(titleScaleType) || titleScaleType === "category" ? tooltipItem[0].label : void 0;
|
|
21207
|
+
const formattedValue = titleLabel === TooltipLabel.Y ? tooltipItem?.[0]?.parsed?.y : tooltipItem?.[0]?.parsed?.x;
|
|
21208
|
+
return `${titleValue ?? customFormatNumber$1(formattedValue, scientificNotation)} ${titleAxisLabel}`;
|
|
21180
21209
|
};
|
|
21181
21210
|
const labelCallback = (tooltipItem) => {
|
|
21182
21211
|
const { showLabelsInTooltips = false } = options?.tooltip ?? {};
|
|
21183
21212
|
let label = tooltipItem?.dataset?.label || "";
|
|
21184
21213
|
const { valueLabel = "", valueAxisLabel = "" } = getTooltipLabels(tooltipItem?.dataset) ?? {};
|
|
21185
21214
|
const getTooltipItemValue = () => {
|
|
21215
|
+
const valueAxisId = valueLabel === TooltipLabel.X ? tooltipItem.dataset?.xAxisID ?? "x" : tooltipItem.dataset?.yAxisID ?? "y";
|
|
21216
|
+
const valueScaleType = options?.scales?.[valueAxisId]?.type;
|
|
21217
|
+
if ((isTimeScaleType(valueScaleType) || valueScaleType === "category") && tooltipItem.label) return tooltipItem.label;
|
|
21186
21218
|
return customFormatNumber$1(valueLabel === TooltipLabel.X ? tooltipItem?.parsed?.x : tooltipItem?.parsed?.y, scientificNotation);
|
|
21187
21219
|
};
|
|
21188
21220
|
return `${label}: ${getTooltipItemValue()} ${getUnitsFromLabel(valueAxisLabel)} ${getTooltipLabel(tooltipItem, showLabelsInTooltips)}`;
|
|
@@ -38851,67 +38883,42 @@ var getStackedOptions = (axisType, { stacked, stackedX, stackedY }) => {
|
|
|
38851
38883
|
else if (axisType === AxisType.Y) return stackedY ?? stacked;
|
|
38852
38884
|
return stacked;
|
|
38853
38885
|
};
|
|
38854
|
-
var
|
|
38886
|
+
var generateAxisId = (axisType, index = 0) => {
|
|
38887
|
+
return index === 0 ? axisType : `${axisType}${index + 1}`;
|
|
38888
|
+
};
|
|
38889
|
+
var getBarChartAxis = ({ chart, axisType = AxisType.X, currentScale, i = 0 }) => {
|
|
38855
38890
|
const { data, options } = chart ?? {};
|
|
38856
38891
|
const isDirectionVertical = isVertical(options.direction);
|
|
38857
38892
|
const axisData = currentScale || options?.axes?.[axisType]?.[0];
|
|
38858
38893
|
const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
|
|
38859
|
-
const
|
|
38860
|
-
const
|
|
38894
|
+
const axisKey = generateAxisId(axisType, i);
|
|
38895
|
+
const scaleConfigFromProps = options?.scales?.[axisKey];
|
|
38896
|
+
const getDefaultScaleType = () => {
|
|
38861
38897
|
const scaleType = data.labels ? ScaleType.Category : ScaleType.Linear;
|
|
38862
38898
|
return axisType === (isDirectionVertical ? AxisType.X : AxisType.Y) ? scaleType : options?.additionalAxesOptions?.chartScaleType;
|
|
38863
38899
|
};
|
|
38900
|
+
const scaleType = scaleConfigFromProps?.type ?? getDefaultScaleType();
|
|
38864
38901
|
const getReverse = () => {
|
|
38865
38902
|
return axisType === (isDirectionVertical ? AxisType.Y : AxisType.X) ? options?.additionalAxesOptions?.reverse : false;
|
|
38866
38903
|
};
|
|
38867
|
-
const
|
|
38868
|
-
|
|
38869
|
-
const getTicks = () => {
|
|
38870
|
-
const additionalAxesOptions = options?.additionalAxesOptions;
|
|
38871
|
-
const ticksConfigFromProps = options?.scales?.[axisKey]?.ticks;
|
|
38872
|
-
const isLogarithmic = isDirectionCompatibleWithAxisType && additionalAxesOptions?.chartScaleType === ScaleType.Logarithmic;
|
|
38873
|
-
const ticksFormattingCallback = (tick, _, ticks) => {
|
|
38874
|
-
return isLogarithmic ? LOGARITHMIC_STEPS.includes(Number(tick)) ? formatAxisLabelNumbers(tick, ticks) : "" : formatAxisLabelNumbers(tick, ticks);
|
|
38875
|
-
};
|
|
38876
|
-
return {
|
|
38877
|
-
...!isLogarithmic ? { stepSize: axisData.stepSize ?? (axisType === AxisType.Y ? additionalAxesOptions?.stepSize : null) } : {},
|
|
38878
|
-
...additionalAxesOptions?.chartScaleType === ScaleType.Logarithmic ? { callback: ticksFormattingCallback } : {},
|
|
38879
|
-
includeBounds: false,
|
|
38880
|
-
...ticksConfigFromProps,
|
|
38881
|
-
font: {
|
|
38882
|
-
size: 12,
|
|
38883
|
-
...ticksConfigFromProps?.font
|
|
38884
|
-
}
|
|
38885
|
-
};
|
|
38904
|
+
const ticksFormattingCallback = (tick, _, ticks) => {
|
|
38905
|
+
return isDirectionCompatibleWithAxisType && scaleType === ScaleType.Logarithmic ? LOGARITHMIC_STEPS.includes(Number(tick)) ? formatAxisLabelNumbers(tick, ticks) : "" : formatAxisLabelNumbers(tick, ticks);
|
|
38886
38906
|
};
|
|
38887
|
-
return {
|
|
38888
|
-
|
|
38889
|
-
|
|
38907
|
+
return getCartesianScaleOptions({
|
|
38908
|
+
axisData,
|
|
38909
|
+
scaleType,
|
|
38910
|
+
scaleConfigFromProps,
|
|
38890
38911
|
beginAtZero: options?.additionalAxesOptions?.beginAtZero,
|
|
38891
38912
|
reverse: getReverse(),
|
|
38892
38913
|
suggestedMax: options?.additionalAxesOptions?.suggestedMax,
|
|
38893
38914
|
suggestedMin: options?.additionalAxesOptions?.suggestedMin,
|
|
38894
38915
|
min: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.min : void 0,
|
|
38895
38916
|
max: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.max : void 0,
|
|
38896
|
-
|
|
38897
|
-
|
|
38898
|
-
|
|
38899
|
-
|
|
38900
|
-
...titleConfigFromProps,
|
|
38901
|
-
font: {
|
|
38902
|
-
size: 12,
|
|
38903
|
-
...titleConfigFromProps?.font
|
|
38904
|
-
}
|
|
38905
|
-
},
|
|
38906
|
-
ticks: getTicks(),
|
|
38907
|
-
grid: { ...grid },
|
|
38908
|
-
stacked: getStackedOptions(axisType, options?.additionalAxesOptions)
|
|
38909
|
-
};
|
|
38917
|
+
additionalStepSize: axisType === AxisType.Y ? options?.additionalAxesOptions?.stepSize : null,
|
|
38918
|
+
stacked: getStackedOptions(axisType, options?.additionalAxesOptions),
|
|
38919
|
+
numericTickCallback: ticksFormattingCallback
|
|
38920
|
+
});
|
|
38910
38921
|
};
|
|
38911
|
-
/**
|
|
38912
|
-
* @param {IBarChartData} chart - chart data
|
|
38913
|
-
* @param {'x'|'y'} axisType
|
|
38914
|
-
*/
|
|
38915
38922
|
var getBarChartAxes = (chart, axisType) => {
|
|
38916
38923
|
return (chart?.options?.axes?.[axisType] || []).reduce((acc, curr, i) => {
|
|
38917
38924
|
const axisData = curr;
|
|
@@ -38920,9 +38927,10 @@ var getBarChartAxes = (chart, axisType) => {
|
|
|
38920
38927
|
const axis = getBarChartAxis({
|
|
38921
38928
|
chart,
|
|
38922
38929
|
axisType,
|
|
38923
|
-
currentScale: axisData
|
|
38930
|
+
currentScale: axisData,
|
|
38931
|
+
i
|
|
38924
38932
|
});
|
|
38925
|
-
const axisId =
|
|
38933
|
+
const axisId = generateAxisId(axisType, i);
|
|
38926
38934
|
return {
|
|
38927
38935
|
...acc,
|
|
38928
38936
|
[axisId]: axis
|
|
@@ -39186,6 +39194,7 @@ var normalizeBarOptions = (options = {}) => ({
|
|
|
39186
39194
|
chartStyling: defaultChartStyling$1(options?.chartStyling),
|
|
39187
39195
|
tooltip: defaultTooltip$1(options?.tooltip),
|
|
39188
39196
|
graph: defaultGraph$1(options?.graph),
|
|
39197
|
+
scales: options?.scales ?? {},
|
|
39189
39198
|
annotations: defaultAnnotations$1(options?.annotations),
|
|
39190
39199
|
legend: defaultLegend$1(options?.legend),
|
|
39191
39200
|
chartOptions: defaultChartOptions$1(options?.chartOptions),
|
|
@@ -39214,7 +39223,7 @@ var getDefaultProps$1 = (props) => {
|
|
|
39214
39223
|
};
|
|
39215
39224
|
//#endregion
|
|
39216
39225
|
//#region src/components/bar-chart/bar-chart.tsx
|
|
39217
|
-
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);
|
|
39226
|
+
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);
|
|
39218
39227
|
var BarChart = (props) => {
|
|
39219
39228
|
setDefaultTheme();
|
|
39220
39229
|
const chartRef = useRef(null);
|
|
@@ -39305,7 +39314,13 @@ var labelCallback = (tooltipItem, options) => {
|
|
|
39305
39314
|
const { raw, dataset } = tooltipItem ?? {};
|
|
39306
39315
|
const datapointLabel = raw?.label;
|
|
39307
39316
|
const scientificNotation = options?.tooltip?.scientificNotation;
|
|
39308
|
-
|
|
39317
|
+
const xScaleType = options?.scales?.x?.type;
|
|
39318
|
+
const yScaleType = options?.scales?.y?.type;
|
|
39319
|
+
const formatValue = (value, scaleType, formattedLabel) => {
|
|
39320
|
+
if (isTimeScaleType(scaleType) && formattedLabel) return formattedLabel;
|
|
39321
|
+
return typeof value === "number" ? customFormatNumber(value, scientificNotation) : value;
|
|
39322
|
+
};
|
|
39323
|
+
return `${datapointLabel ?? dataset?.label} ( x: ${formatValue(raw?.x, xScaleType, tooltipItem.label)} , y: ${formatValue(raw?.y, yScaleType)} )`;
|
|
39309
39324
|
};
|
|
39310
39325
|
var getTooltipsConfig = (options) => {
|
|
39311
39326
|
return {
|
|
@@ -39325,46 +39340,23 @@ var getScatterChartAxis = ({ options, axisType = AxisType.X, currentScale }) =>
|
|
|
39325
39340
|
const isDirectionVertical = isVertical(options.direction);
|
|
39326
39341
|
const axisData = currentScale || options?.axes?.[axisType]?.[0];
|
|
39327
39342
|
const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
|
|
39328
|
-
const
|
|
39329
|
-
const
|
|
39330
|
-
const titleConfigFromProps = options?.scales?.[axisType]?.title;
|
|
39343
|
+
const scaleConfigFromProps = options?.scales?.[axisType];
|
|
39344
|
+
const scaleType = scaleConfigFromProps?.type ?? options?.additionalAxesOptions?.chartScaleType ?? ScaleType.Linear;
|
|
39331
39345
|
const getReverse = () => {
|
|
39332
39346
|
return axisType === (isDirectionVertical ? AxisType.Y : AxisType.X) ? options?.additionalAxesOptions?.reverse : false;
|
|
39333
39347
|
};
|
|
39334
|
-
|
|
39335
|
-
|
|
39336
|
-
|
|
39337
|
-
|
|
39338
|
-
includeBounds: false,
|
|
39339
|
-
...ticksConfigFromProps,
|
|
39340
|
-
font: {
|
|
39341
|
-
size: 12,
|
|
39342
|
-
...ticksConfigFromProps?.font
|
|
39343
|
-
}
|
|
39344
|
-
};
|
|
39345
|
-
};
|
|
39346
|
-
return {
|
|
39347
|
-
type: ScaleType.Linear,
|
|
39348
|
-
position: axisData?.position,
|
|
39348
|
+
return getCartesianScaleOptions({
|
|
39349
|
+
axisData,
|
|
39350
|
+
scaleType,
|
|
39351
|
+
scaleConfigFromProps,
|
|
39349
39352
|
beginAtZero: options?.additionalAxesOptions?.beginAtZero,
|
|
39350
39353
|
reverse: getReverse(),
|
|
39351
39354
|
suggestedMax: options?.additionalAxesOptions?.suggestedMax,
|
|
39352
39355
|
suggestedMin: options?.additionalAxesOptions?.suggestedMin,
|
|
39353
39356
|
min: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.min : void 0,
|
|
39354
39357
|
max: isDirectionCompatibleWithAxisType ? options?.additionalAxesOptions?.max : void 0,
|
|
39355
|
-
|
|
39356
|
-
|
|
39357
|
-
text: axisData?.label || axisData?.unit,
|
|
39358
|
-
padding: 0,
|
|
39359
|
-
...titleConfigFromProps,
|
|
39360
|
-
font: {
|
|
39361
|
-
size: 12,
|
|
39362
|
-
...titleConfigFromProps?.font
|
|
39363
|
-
}
|
|
39364
|
-
},
|
|
39365
|
-
ticks: getTicks(),
|
|
39366
|
-
grid: { ...grid }
|
|
39367
|
-
};
|
|
39358
|
+
additionalStepSize: axisType === AxisType.Y ? options?.additionalAxesOptions?.stepSize : null
|
|
39359
|
+
});
|
|
39368
39360
|
};
|
|
39369
39361
|
var getScatterChartScales = (options) => {
|
|
39370
39362
|
return {
|
|
@@ -39528,6 +39520,7 @@ var defaultAxes = (axes) => ({
|
|
|
39528
39520
|
y: axes?.y ?? [{}]
|
|
39529
39521
|
});
|
|
39530
39522
|
var defaultAdditionalAxesOptions = (options) => ({
|
|
39523
|
+
chartScaleType: options?.chartScaleType || "linear",
|
|
39531
39524
|
reverse: options?.reverse ?? false,
|
|
39532
39525
|
stacked: options?.stacked ?? false,
|
|
39533
39526
|
beginAtZero: options?.beginAtZero ?? true,
|
|
@@ -39545,6 +39538,7 @@ var normalizeScatterOptions = (options = {}) => ({
|
|
|
39545
39538
|
chartStyling: defaultChartStyling(options?.chartStyling),
|
|
39546
39539
|
tooltip: defaultTooltip(options?.tooltip),
|
|
39547
39540
|
graph: defaultGraph(options?.graph),
|
|
39541
|
+
scales: options?.scales ?? {},
|
|
39548
39542
|
legend: defaultLegend(options?.legend),
|
|
39549
39543
|
annotations: defaultAnnotations(options?.annotations),
|
|
39550
39544
|
chartOptions: defaultChartOptions(options?.chartOptions),
|
|
@@ -39651,7 +39645,7 @@ var scatter_chart_module_default = {
|
|
|
39651
39645
|
};
|
|
39652
39646
|
//#endregion
|
|
39653
39647
|
//#region src/components/scatter-chart/scatter-chart.tsx
|
|
39654
|
-
Chart$1.register(LinearScale, PointElement, CategoryScale, plugin_legend, plugin_tooltip, plugin_title, plugin$1, plugin, annotation, gradientBackgroundPlugin);
|
|
39648
|
+
Chart$1.register(LinearScale, PointElement, CategoryScale, TimeScale, TimeSeriesScale, plugin_legend, plugin_tooltip, plugin_title, plugin$1, plugin, annotation, gradientBackgroundPlugin);
|
|
39655
39649
|
var ScatterChart = (props) => {
|
|
39656
39650
|
setDefaultTheme();
|
|
39657
39651
|
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;
|
|
@@ -150,15 +150,15 @@ export interface ICommonTooltip {
|
|
|
150
150
|
callbacks?: ICommonTooltipCallbacks;
|
|
151
151
|
}
|
|
152
152
|
export interface ICommonAdditionalAxesOptions {
|
|
153
|
-
chartScaleType?: 'linear' | 'logarithmic';
|
|
153
|
+
chartScaleType?: 'linear' | 'logarithmic' | 'time' | 'timeseries';
|
|
154
154
|
reverse?: boolean;
|
|
155
155
|
beginAtZero?: boolean;
|
|
156
156
|
stepSize?: number;
|
|
157
157
|
stacked?: boolean;
|
|
158
158
|
suggestedMin?: number;
|
|
159
159
|
suggestedMax?: number;
|
|
160
|
-
min?: number;
|
|
161
|
-
max?: number;
|
|
160
|
+
min?: number | string;
|
|
161
|
+
max?: number | string;
|
|
162
162
|
}
|
|
163
163
|
export interface ICommonAnnotation {
|
|
164
164
|
showLabel?: boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Tick } from 'chart.js';
|
|
2
|
+
import { ICommonScaleOptions, UnusedParameter } from '../common.interface';
|
|
3
|
+
type TScaleType = NonNullable<ICommonScaleOptions['type']>;
|
|
4
|
+
export declare const isTimeScaleType: (scaleType?: ICommonScaleOptions["type"]) => scaleType is "time" | "timeseries";
|
|
5
|
+
interface IGetCartesianScaleOptionsParams {
|
|
6
|
+
axisData?: {
|
|
7
|
+
gridLines?: unknown;
|
|
8
|
+
label?: string;
|
|
9
|
+
position?: unknown;
|
|
10
|
+
stepSize?: number;
|
|
11
|
+
unit?: unknown;
|
|
12
|
+
};
|
|
13
|
+
scaleType?: TScaleType;
|
|
14
|
+
scaleConfigFromProps?: ICommonScaleOptions;
|
|
15
|
+
display?: boolean;
|
|
16
|
+
beginAtZero?: boolean;
|
|
17
|
+
reverse?: boolean;
|
|
18
|
+
suggestedMax?: number | string;
|
|
19
|
+
suggestedMin?: number | string;
|
|
20
|
+
min?: number | string;
|
|
21
|
+
max?: number | string;
|
|
22
|
+
additionalStepSize?: number | null;
|
|
23
|
+
useStepSize?: boolean;
|
|
24
|
+
stacked?: boolean;
|
|
25
|
+
numericTickCallback?: (tick: string | number, unused: UnusedParameter, ticks: Tick[]) => unknown;
|
|
26
|
+
}
|
|
27
|
+
export declare const getCartesianScaleOptions: ({ axisData, scaleType, scaleConfigFromProps, display, beginAtZero, reverse, suggestedMax, suggestedMin, min, max, additionalStepSize, useStepSize, stacked, numericTickCallback, }: IGetCartesianScaleOptionsParams) => ICommonScaleOptions;
|
|
28
|
+
export {};
|