@oliasoft-open-source/charts-library 9.1.0-beta-3 → 9.1.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
CHANGED
|
@@ -33650,9 +33650,10 @@ var storeChartStateInStorage = (state, persistenceId) => {
|
|
|
33650
33650
|
Initial chart state for the line chart.
|
|
33651
33651
|
*/
|
|
33652
33652
|
var initialState = ({ options, persistenceId }) => {
|
|
33653
|
-
const { chartOptions: { enableZoom, enablePan, showPoints, showLine, enableDragAnnotation }, legend: { display }, dragData } = options;
|
|
33653
|
+
const { chartOptions: { enableZoom, enablePan, showPoints, showLine, enableDragAnnotation }, legend: { display }, dragData, additionalAxesOptions } = options;
|
|
33654
33654
|
const { zoomEnabled, panEnabled, pointsEnabled, lineEnabled, legendEnabled, enableDragPoints, enableDragAnnotation: enableDragAnnotationStorage } = getChartStateFromStorage(persistenceId) || {};
|
|
33655
33655
|
return {
|
|
33656
|
+
equalScaleEnabled: !!additionalAxesOptions.allowEqualScale && !!additionalAxesOptions.defaultEqualScaleEnabled,
|
|
33656
33657
|
zoomEnabled: enableDragAnnotation ?? enableDragAnnotationStorage ? false : zoomEnabled ?? enableZoom,
|
|
33657
33658
|
panEnabled: panEnabled ?? enablePan,
|
|
33658
33659
|
pointsEnabled: pointsEnabled ?? showPoints,
|
|
@@ -34243,11 +34244,6 @@ var AxesOptionsPopover = (optionsPopover) => {
|
|
|
34243
34244
|
onChange: onToggleEqualScale
|
|
34244
34245
|
})
|
|
34245
34246
|
}),
|
|
34246
|
-
equalScaleEnabled && /* @__PURE__ */ jsx(Text, {
|
|
34247
|
-
small: true,
|
|
34248
|
-
muted: true,
|
|
34249
|
-
children: translations.equalAxisScaleReadOnly
|
|
34250
|
-
}),
|
|
34251
34247
|
formState.localAxes.map((axis) => {
|
|
34252
34248
|
const axisLabel = controlsAxesLabels.find((el) => el.id === axis.id)?.label || startCase(axis.id);
|
|
34253
34249
|
const axisErrors = errors.find((err) => err.id === axis.id);
|
|
@@ -34302,6 +34298,7 @@ var AxesOptionsPopover = (optionsPopover) => {
|
|
|
34302
34298
|
}, axis.id);
|
|
34303
34299
|
}),
|
|
34304
34300
|
depthType?.options?.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ButtonGroup, {
|
|
34301
|
+
disabled: equalScaleEnabled,
|
|
34305
34302
|
items: depthType.options.map((depth, i) => ({
|
|
34306
34303
|
key: i,
|
|
34307
34304
|
label: depth
|
|
@@ -34316,6 +34313,11 @@ var AxesOptionsPopover = (optionsPopover) => {
|
|
|
34316
34313
|
small: true,
|
|
34317
34314
|
value: depthType.options.indexOf(formState.depthType)
|
|
34318
34315
|
}), /* @__PURE__ */ jsx(Spacer, {})] }),
|
|
34316
|
+
equalScaleEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
|
|
34317
|
+
small: true,
|
|
34318
|
+
muted: true,
|
|
34319
|
+
children: translations.equalAxisScaleReadOnly
|
|
34320
|
+
}), /* @__PURE__ */ jsx(Spacer, {})] }),
|
|
34319
34321
|
/* @__PURE__ */ jsxs(Flex, {
|
|
34320
34322
|
gap: "8px",
|
|
34321
34323
|
alignItems: "center",
|
|
@@ -34583,7 +34585,8 @@ var defaultAxes$2 = (axes) => {
|
|
|
34583
34585
|
};
|
|
34584
34586
|
};
|
|
34585
34587
|
var defaultAdditionalAxesOptions$2 = (options) => ({
|
|
34586
|
-
allowEqualScale: options?.allowEqualScale ??
|
|
34588
|
+
allowEqualScale: options?.allowEqualScale ?? true,
|
|
34589
|
+
defaultEqualScaleEnabled: options?.defaultEqualScaleEnabled ?? false,
|
|
34587
34590
|
chartScaleType: options?.chartScaleType || "linear",
|
|
34588
34591
|
reverse: options?.reverse || false,
|
|
34589
34592
|
beginAtZero: options?.beginAtZero ?? false,
|
|
@@ -36689,15 +36692,23 @@ var getEqualScaleRanges = (x, y, width, height) => {
|
|
|
36689
36692
|
*/
|
|
36690
36693
|
var createEqualScalePlugin = (onAxesUpdate) => {
|
|
36691
36694
|
let fitting = false;
|
|
36695
|
+
let wasEnabled = false;
|
|
36692
36696
|
return {
|
|
36693
36697
|
id: "equalAxisScale",
|
|
36698
|
+
beforeRender() {
|
|
36699
|
+
if (fitting) return false;
|
|
36700
|
+
},
|
|
36694
36701
|
afterUpdate(chart, _args, { enabled }) {
|
|
36695
36702
|
if (fitting) return;
|
|
36696
36703
|
const { x, y } = chart.scales;
|
|
36697
36704
|
if (!enabled || Object.keys(chart.scales).length !== 2 || x?.type !== "linear" || y?.type !== "linear") {
|
|
36698
|
-
|
|
36705
|
+
if (wasEnabled) {
|
|
36706
|
+
wasEnabled = false;
|
|
36707
|
+
onAxesUpdate();
|
|
36708
|
+
}
|
|
36699
36709
|
return;
|
|
36700
36710
|
}
|
|
36711
|
+
wasEnabled = true;
|
|
36701
36712
|
const baseX = {
|
|
36702
36713
|
min: x.min,
|
|
36703
36714
|
max: x.max
|
|
@@ -67,11 +67,13 @@ export interface ILineRange {
|
|
|
67
67
|
/** LineChart scale defaults and per-axis range overrides. */
|
|
68
68
|
export interface ILineChartAdditionalAxesOptions {
|
|
69
69
|
/**
|
|
70
|
-
* Offers a toggle for equal units per pixel on one pair of linear X/Y axes. Defaults to
|
|
70
|
+
* Offers a toggle for equal units per pixel on one pair of linear X/Y axes. Defaults to true.
|
|
71
71
|
* Both axes must use the same physical units; no unit conversion is performed.
|
|
72
|
-
*
|
|
72
|
+
* Equal scaling expands the requested viewport without changing the canvas shape.
|
|
73
73
|
*/
|
|
74
74
|
allowEqualScale?: boolean;
|
|
75
|
+
/** Initial toggle value when allowEqualScale is true. Defaults to false; later changes do not reset user choice. */
|
|
76
|
+
defaultEqualScaleEnabled?: boolean;
|
|
75
77
|
/** Scale family used when constructing axes. */
|
|
76
78
|
chartScaleType?: 'linear' | 'logarithmic' | 'time' | 'timeseries';
|
|
77
79
|
/** Reverses the Y scale direction. Does not change tooltip axis selection. */
|
package/package.json
CHANGED