@oliasoft-open-source/charts-library 5.15.0-beta-2 → 5.15.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
@@ -20802,6 +20802,9 @@ var formatAxisLabelNumbers = (tickValue, ticks) => {
20802
20802
  };
20803
20803
  //#endregion
20804
20804
  //#region src/components/common/helpers/get-cartesian-scale-options.ts
20805
+ var isTimeScaleType = (scaleType) => {
20806
+ return scaleType === ScaleType.Time || scaleType === ScaleType.TimeSeries;
20807
+ };
20805
20808
  var isNumericScale = (scaleType) => {
20806
20809
  return scaleType === ScaleType.Linear || scaleType === ScaleType.Logarithmic;
20807
20810
  };
@@ -21198,13 +21201,20 @@ var getLineChartToolTips = (options) => {
21198
21201
  const titleCallback = (tooltipItem) => {
21199
21202
  if (!tooltipItem?.[0]) return "";
21200
21203
  const { titleLabel = "", titleAxisLabel = "" } = getTooltipLabels(tooltipItem[0].dataset) ?? {};
21201
- return `${customFormatNumber$1(titleLabel === TooltipLabel.Y ? tooltipItem?.[0]?.parsed?.y : tooltipItem?.[0]?.parsed?.x, scientificNotation)} ${titleAxisLabel}`;
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}`;
21202
21209
  };
21203
21210
  const labelCallback = (tooltipItem) => {
21204
21211
  const { showLabelsInTooltips = false } = options?.tooltip ?? {};
21205
21212
  let label = tooltipItem?.dataset?.label || "";
21206
21213
  const { valueLabel = "", valueAxisLabel = "" } = getTooltipLabels(tooltipItem?.dataset) ?? {};
21207
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;
21208
21218
  return customFormatNumber$1(valueLabel === TooltipLabel.X ? tooltipItem?.parsed?.x : tooltipItem?.parsed?.y, scientificNotation);
21209
21219
  };
21210
21220
  return `${label}: ${getTooltipItemValue()} ${getUnitsFromLabel(valueAxisLabel)} ${getTooltipLabel(tooltipItem, showLabelsInTooltips)}`;
@@ -39304,7 +39314,13 @@ var labelCallback = (tooltipItem, options) => {
39304
39314
  const { raw, dataset } = tooltipItem ?? {};
39305
39315
  const datapointLabel = raw?.label;
39306
39316
  const scientificNotation = options?.tooltip?.scientificNotation;
39307
- return `${datapointLabel ?? dataset?.label} ( x: ${customFormatNumber(raw?.x, scientificNotation)} , y: ${customFormatNumber(raw?.y, scientificNotation)} )`;
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)} )`;
39308
39324
  };
39309
39325
  var getTooltipsConfig = (options) => {
39310
39326
  return {
@@ -1,6 +1,7 @@
1
1
  import { Tick } from 'chart.js';
2
2
  import { ICommonScaleOptions, UnusedParameter } from '../common.interface';
3
3
  type TScaleType = NonNullable<ICommonScaleOptions['type']>;
4
+ export declare const isTimeScaleType: (scaleType?: ICommonScaleOptions["type"]) => scaleType is "time" | "timeseries";
4
5
  interface IGetCartesianScaleOptionsParams {
5
6
  axisData?: {
6
7
  gridLines?: unknown;
@@ -1,8 +1,8 @@
1
1
  import { TooltipItem } from 'chart.js';
2
2
  import { IDefaultScatterOptions } from '../scatter-chart-default-props.interface';
3
3
  interface IRawData {
4
- x: number;
5
- y: number;
4
+ x: number | string;
5
+ y: number | string;
6
6
  label?: string;
7
7
  }
8
8
  export interface IScatterTooltipItem extends TooltipItem<'scatter'> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/charts-library",
3
- "version": "5.15.0-beta-2",
3
+ "version": "5.15.0",
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": {