@oliasoft-open-source/charts-library 8.0.3 → 8.0.4-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.d.ts +7 -7
- package/dist/index.js +51 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2220,25 +2220,25 @@ export { }
|
|
|
2220
2220
|
|
|
2221
2221
|
declare module 'chart.js' {
|
|
2222
2222
|
interface PluginOptionsByType<TType extends ChartType> {
|
|
2223
|
-
|
|
2224
|
-
enabled?: boolean;
|
|
2225
|
-
} | TLineMarkersOptions;
|
|
2223
|
+
annotationDraggerPlugin?: AnnotationDraggerPluginOptions;
|
|
2226
2224
|
}
|
|
2227
2225
|
}
|
|
2228
2226
|
|
|
2229
2227
|
|
|
2230
2228
|
declare module 'chart.js' {
|
|
2231
2229
|
interface PluginOptionsByType<TType extends ChartType> {
|
|
2232
|
-
|
|
2230
|
+
calloutConnectorPlugin?: {
|
|
2231
|
+
enableCalloutAnnotation?: boolean;
|
|
2232
|
+
};
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
2235
|
|
|
2236
2236
|
|
|
2237
2237
|
declare module 'chart.js' {
|
|
2238
2238
|
interface PluginOptionsByType<TType extends ChartType> {
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
};
|
|
2239
|
+
lineMarkersPlugin?: {
|
|
2240
|
+
enabled?: boolean;
|
|
2241
|
+
} | TLineMarkersOptions;
|
|
2242
2242
|
}
|
|
2243
2243
|
}
|
|
2244
2244
|
|
package/dist/index.js
CHANGED
|
@@ -35817,13 +35817,13 @@ var isCalloutAnchorInChartArea = (ctx, refAnnotation, margin = 0) => {
|
|
|
35817
35817
|
};
|
|
35818
35818
|
//#endregion
|
|
35819
35819
|
//#region src/components/common/plugins/annotation-dragger-plugin/annotation-position-storage.ts
|
|
35820
|
-
var STORAGE_PREFIX = "chart_annotations";
|
|
35821
|
-
var getStorageKey = (persistenceId) => {
|
|
35822
|
-
return `${STORAGE_PREFIX}:${persistenceId}`;
|
|
35820
|
+
var STORAGE_PREFIX$1 = "chart_annotations";
|
|
35821
|
+
var getStorageKey$1 = (persistenceId) => {
|
|
35822
|
+
return `${STORAGE_PREFIX$1}:${persistenceId}`;
|
|
35823
35823
|
};
|
|
35824
|
-
var readStorage = (persistenceId) => {
|
|
35824
|
+
var readStorage$1 = (persistenceId) => {
|
|
35825
35825
|
try {
|
|
35826
|
-
const raw = window.localStorage.getItem(getStorageKey(persistenceId));
|
|
35826
|
+
const raw = window.localStorage.getItem(getStorageKey$1(persistenceId));
|
|
35827
35827
|
if (!raw) return {};
|
|
35828
35828
|
const json = JSON.parse(raw);
|
|
35829
35829
|
return typeof json === "object" && json !== null ? json : {};
|
|
@@ -35831,15 +35831,15 @@ var readStorage = (persistenceId) => {
|
|
|
35831
35831
|
return {};
|
|
35832
35832
|
}
|
|
35833
35833
|
};
|
|
35834
|
-
var writeStorage = (persistenceId, data) => {
|
|
35834
|
+
var writeStorage$1 = (persistenceId, data) => {
|
|
35835
35835
|
try {
|
|
35836
|
-
window.localStorage.setItem(getStorageKey(persistenceId), JSON.stringify(data));
|
|
35836
|
+
window.localStorage.setItem(getStorageKey$1(persistenceId), JSON.stringify(data));
|
|
35837
35837
|
} catch {}
|
|
35838
35838
|
};
|
|
35839
35839
|
var setAnnotationPosition = (persistenceId, annotationId, pos) => {
|
|
35840
35840
|
if (!persistenceId) return;
|
|
35841
|
-
const current = readStorage(persistenceId);
|
|
35842
|
-
writeStorage(persistenceId, {
|
|
35841
|
+
const current = readStorage$1(persistenceId);
|
|
35842
|
+
writeStorage$1(persistenceId, {
|
|
35843
35843
|
...current,
|
|
35844
35844
|
[annotationId]: {
|
|
35845
35845
|
...current[annotationId] ?? {},
|
|
@@ -35849,7 +35849,7 @@ var setAnnotationPosition = (persistenceId, annotationId, pos) => {
|
|
|
35849
35849
|
};
|
|
35850
35850
|
var getAnnotationPosition = (persistenceId, annotationId) => {
|
|
35851
35851
|
if (!persistenceId) return void 0;
|
|
35852
|
-
return readStorage(persistenceId)[annotationId];
|
|
35852
|
+
return readStorage$1(persistenceId)[annotationId];
|
|
35853
35853
|
};
|
|
35854
35854
|
//#endregion
|
|
35855
35855
|
//#region src/components/common/helpers/get-chart-from-ctx.ts
|
|
@@ -38436,15 +38436,47 @@ var LegendDropZones = (legendDropZonesProps) => {
|
|
|
38436
38436
|
});
|
|
38437
38437
|
};
|
|
38438
38438
|
//#endregion
|
|
38439
|
+
//#region src/components/common/legend-component/legend-position-storage.ts
|
|
38440
|
+
var STORAGE_PREFIX = "chart_legend_position";
|
|
38441
|
+
var getStorageKey = (persistenceId) => {
|
|
38442
|
+
return `${STORAGE_PREFIX}:${persistenceId}`;
|
|
38443
|
+
};
|
|
38444
|
+
var isPosition = (value) => {
|
|
38445
|
+
return Object.values(Position).includes(String(value));
|
|
38446
|
+
};
|
|
38447
|
+
var readStorage = (persistenceId) => {
|
|
38448
|
+
try {
|
|
38449
|
+
const raw = window.localStorage.getItem(getStorageKey(persistenceId));
|
|
38450
|
+
if (!raw) return void 0;
|
|
38451
|
+
const parsed = JSON.parse(raw);
|
|
38452
|
+
return isPosition(parsed) ? parsed : void 0;
|
|
38453
|
+
} catch {
|
|
38454
|
+
return;
|
|
38455
|
+
}
|
|
38456
|
+
};
|
|
38457
|
+
var writeStorage = (persistenceId, position) => {
|
|
38458
|
+
try {
|
|
38459
|
+
window.localStorage.setItem(getStorageKey(persistenceId), JSON.stringify(position));
|
|
38460
|
+
} catch {}
|
|
38461
|
+
};
|
|
38462
|
+
var setLegendPosition = (persistenceId, position) => {
|
|
38463
|
+
if (!persistenceId) return;
|
|
38464
|
+
writeStorage(persistenceId, position);
|
|
38465
|
+
};
|
|
38466
|
+
var getLegendPosition = (persistenceId) => {
|
|
38467
|
+
if (!persistenceId) return void 0;
|
|
38468
|
+
return readStorage(persistenceId);
|
|
38469
|
+
};
|
|
38470
|
+
//#endregion
|
|
38439
38471
|
//#region src/components/common/legend-component/legend.tsx
|
|
38440
|
-
var Legend = ({ chartRef, legendConfig }) => {
|
|
38472
|
+
var Legend = ({ chartRef, legendConfig, persistenceId }) => {
|
|
38441
38473
|
const chart = chartRef?.current;
|
|
38442
38474
|
const [chartArea, setChartArea] = useState(chart?.chartArea);
|
|
38443
38475
|
const { options: { legend } } = legendConfig ?? {};
|
|
38444
38476
|
const [measureRef, measureRect] = useMeasure();
|
|
38445
38477
|
const resizeRef = measureRef;
|
|
38446
38478
|
const panelRef = useRef(null);
|
|
38447
|
-
const [legendPosition, setLegendPosition] = useState(legend?.position || Position.BottomLeft);
|
|
38479
|
+
const [legendPosition, setLegendPosition$1] = useState(() => getLegendPosition(persistenceId) || legend?.position || Position.BottomLeft);
|
|
38448
38480
|
const [prevLegendPositionProp, setPrevLegendPositionProp] = useState(legend?.position);
|
|
38449
38481
|
const panelRect = panelRef?.current ? panelRef.current.getBoundingClientRect() : null;
|
|
38450
38482
|
const panelSize = {
|
|
@@ -38463,8 +38495,12 @@ var Legend = ({ chartRef, legendConfig }) => {
|
|
|
38463
38495
|
}, [chart?.chartArea, measureRect]);
|
|
38464
38496
|
if (legend?.position && legend.position !== prevLegendPositionProp) {
|
|
38465
38497
|
setPrevLegendPositionProp(legend.position);
|
|
38466
|
-
setLegendPosition(legend.position);
|
|
38498
|
+
setLegendPosition$1(legend.position);
|
|
38467
38499
|
}
|
|
38500
|
+
const handleLegendPositionChange = (position) => {
|
|
38501
|
+
setLegendPosition$1(position);
|
|
38502
|
+
setLegendPosition(persistenceId, position);
|
|
38503
|
+
};
|
|
38468
38504
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38469
38505
|
/* @__PURE__ */ jsx("div", {
|
|
38470
38506
|
ref: resizeRef,
|
|
@@ -38482,7 +38518,7 @@ var Legend = ({ chartRef, legendConfig }) => {
|
|
|
38482
38518
|
}),
|
|
38483
38519
|
/* @__PURE__ */ jsx(LegendDropZones, {
|
|
38484
38520
|
chartArea,
|
|
38485
|
-
setLegendPosition:
|
|
38521
|
+
setLegendPosition: handleLegendPositionChange,
|
|
38486
38522
|
isDragging,
|
|
38487
38523
|
placeholderSize: panelSize
|
|
38488
38524
|
}, measureRect.width)
|
|
@@ -38573,6 +38609,7 @@ var LineChart = (props) => {
|
|
|
38573
38609
|
plugins: usePlugins
|
|
38574
38610
|
}), showCustomLegend && !!generatedDatasets.length && /* @__PURE__ */ jsx(Legend, {
|
|
38575
38611
|
chartRef,
|
|
38612
|
+
persistenceId,
|
|
38576
38613
|
legendConfig: {
|
|
38577
38614
|
options,
|
|
38578
38615
|
generatedDatasets,
|
package/package.json
CHANGED