@oliasoft-open-source/charts-library 7.0.0-beta-2 → 8.0.0-beta-1
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 +5 -4
- package/dist/index.js +34 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -769,6 +769,7 @@ export declare interface ILineChartStyling extends ICommonStyling {
|
|
|
769
769
|
export declare interface ILineChartTooltip extends ICommonTooltip {
|
|
770
770
|
hideSimulationName?: boolean;
|
|
771
771
|
scientificNotation?: boolean;
|
|
772
|
+
titleAxis?: `${AxisType}`;
|
|
772
773
|
}
|
|
773
774
|
|
|
774
775
|
export declare interface ILineInteractions extends ICommonInteractions {
|
|
@@ -1237,7 +1238,9 @@ export { }
|
|
|
1237
1238
|
|
|
1238
1239
|
declare module 'chart.js' {
|
|
1239
1240
|
interface PluginOptionsByType<TType extends ChartType> {
|
|
1240
|
-
|
|
1241
|
+
calloutConnectorPlugin?: {
|
|
1242
|
+
enableCalloutAnnotation?: boolean;
|
|
1243
|
+
};
|
|
1241
1244
|
}
|
|
1242
1245
|
}
|
|
1243
1246
|
|
|
@@ -1253,9 +1256,7 @@ declare module 'chart.js' {
|
|
|
1253
1256
|
|
|
1254
1257
|
declare module 'chart.js' {
|
|
1255
1258
|
interface PluginOptionsByType<TType extends ChartType> {
|
|
1256
|
-
|
|
1257
|
-
enableCalloutAnnotation?: boolean;
|
|
1258
|
-
};
|
|
1259
|
+
annotationDraggerPlugin?: AnnotationDraggerPluginOptions;
|
|
1259
1260
|
}
|
|
1260
1261
|
}
|
|
1261
1262
|
|
package/dist/index.js
CHANGED
|
@@ -20540,7 +20540,8 @@ var defaultTooltip$3 = (tooltip) => ({
|
|
|
20540
20540
|
showLabelsInTooltips: tooltip?.showLabelsInTooltips ?? false,
|
|
20541
20541
|
hideSimulationName: tooltip?.hideSimulationName ?? false,
|
|
20542
20542
|
scientificNotation: tooltip?.scientificNotation ?? true,
|
|
20543
|
-
callbacks: tooltip?.callbacks
|
|
20543
|
+
callbacks: tooltip?.callbacks,
|
|
20544
|
+
titleAxis: tooltip?.titleAxis ?? AxisType.X
|
|
20544
20545
|
});
|
|
20545
20546
|
var defaultGraph$3 = (graph) => ({
|
|
20546
20547
|
lineTension: graph?.lineTension ?? .01,
|
|
@@ -21193,45 +21194,38 @@ var getLineChartToolTips = (options) => {
|
|
|
21193
21194
|
callbacks: {}
|
|
21194
21195
|
};
|
|
21195
21196
|
}
|
|
21196
|
-
const { scientificNotation = true } = options?.tooltip ?? {};
|
|
21197
|
-
const
|
|
21198
|
-
|
|
21199
|
-
const
|
|
21200
|
-
const
|
|
21201
|
-
const
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
21206
|
-
|
|
21207
|
-
|
|
21208
|
-
|
|
21209
|
-
|
|
21210
|
-
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
const
|
|
21218
|
-
|
|
21219
|
-
const
|
|
21220
|
-
|
|
21221
|
-
|
|
21222
|
-
|
|
21223
|
-
|
|
21224
|
-
|
|
21225
|
-
const
|
|
21226
|
-
|
|
21227
|
-
|
|
21228
|
-
const getTooltipItemValue = () => {
|
|
21229
|
-
const valueAxisId = valueLabel === TooltipLabel.X ? tooltipItem.dataset?.xAxisID ?? "x" : tooltipItem.dataset?.yAxisID ?? "y";
|
|
21230
|
-
const valueScaleType = options?.scales?.[valueAxisId]?.type;
|
|
21231
|
-
if ((isTimeScaleType(valueScaleType) || valueScaleType === "category") && tooltipItem.label) return tooltipItem.label;
|
|
21232
|
-
return customFormatNumber$1(valueLabel === TooltipLabel.X ? tooltipItem?.parsed?.x : tooltipItem?.parsed?.y, scientificNotation);
|
|
21233
|
-
};
|
|
21234
|
-
return `${label}: ${getTooltipItemValue()} ${getUnitsFromLabel(valueAxisLabel)} ${getTooltipLabel(tooltipItem, showLabelsInTooltips)}`;
|
|
21197
|
+
const { scientificNotation = true, showLabelsInTooltips = false, titleAxis = AxisType.X } = options?.tooltip ?? {};
|
|
21198
|
+
const valueAxis = titleAxis === AxisType.X ? AxisType.Y : AxisType.X;
|
|
21199
|
+
const getAxis = (item, axis) => {
|
|
21200
|
+
const axisIdKey = `${axis}AxisID`;
|
|
21201
|
+
const id = item.dataset[axisIdKey] || axis;
|
|
21202
|
+
const index = id === axis ? 0 : toNum(id.slice(1)) - 1;
|
|
21203
|
+
return {
|
|
21204
|
+
id,
|
|
21205
|
+
config: options.axes[axis][index]
|
|
21206
|
+
};
|
|
21207
|
+
};
|
|
21208
|
+
const formatValue = (item, axis) => {
|
|
21209
|
+
const { id } = getAxis(item, axis);
|
|
21210
|
+
const scale = item.chart?.scales[id];
|
|
21211
|
+
const scaleType = scale?.type ?? options.scales?.[id]?.type;
|
|
21212
|
+
const value = item.parsed[axis];
|
|
21213
|
+
if (value === null || value === void 0) return "";
|
|
21214
|
+
if (scaleType === ScaleType.Time || scaleType === ScaleType.TimeSeries || scaleType === ScaleType.Category) return (axis === (item.chart?.getDatasetMeta(item.datasetIndex).iScale?.axis ?? AxisType.X) ? item.label : item.formattedValue) || scale?.getLabelForValue(value) || String(value);
|
|
21215
|
+
return customFormatNumber$1(value, scientificNotation);
|
|
21216
|
+
};
|
|
21217
|
+
const titleCallback = (items) => {
|
|
21218
|
+
const item = items?.[0];
|
|
21219
|
+
if (!item) return "";
|
|
21220
|
+
const { config } = getAxis(item, titleAxis);
|
|
21221
|
+
return `${formatValue(item, titleAxis)} ${config?.label || ""}`;
|
|
21222
|
+
};
|
|
21223
|
+
const labelCallback = (item) => {
|
|
21224
|
+
const { config } = getAxis(item, valueAxis);
|
|
21225
|
+
const units = (typeof config?.unit === "string" ? config.unit : config?.unit?.selectedUnit) || getUnitsFromLabel(config?.label || "");
|
|
21226
|
+
const label = item.dataset.label || "";
|
|
21227
|
+
const pointLabel = getTooltipLabel(item, showLabelsInTooltips);
|
|
21228
|
+
return `${label}: ${formatValue(item, valueAxis)} ${units} ${pointLabel}`;
|
|
21235
21229
|
};
|
|
21236
21230
|
const userCallbacks = options?.tooltip?.callbacks ?? null;
|
|
21237
21231
|
const callbacks = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/charts-library",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-beta-1",
|
|
4
4
|
"description": "React Chart Library (based on Chart.js and react-chart-js-2)",
|
|
5
5
|
"homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
|
|
6
6
|
"bugs": {
|