pace-chart-lib 1.0.63 → 1.0.64

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.
@@ -9,6 +9,7 @@ interface ICJSAreaChartProps {
9
9
  isChartStacked?: boolean;
10
10
  /** Active theme colour bank from the host application. Falls back to default palette. */
11
11
  colorBank?: string[];
12
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
12
13
  }
13
14
  /**
14
15
  * Chart.js area chart.
@@ -7,6 +7,7 @@ interface ICJSBubbleChartProps {
7
7
  clientHeight: number;
8
8
  /** Active theme colour bank from the host application. Falls back to default palette. */
9
9
  colorBank?: string[];
10
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
10
11
  }
11
12
  /**
12
13
  * Chart.js bubble chart.
@@ -9,6 +9,7 @@ interface ICJSColumnChartProps {
9
9
  isChartStacked?: boolean;
10
10
  /** Active theme colour bank from the host application. Falls back to default palette. */
11
11
  colorBank?: string[];
12
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
12
13
  }
13
14
  /**
14
15
  * Chart.js vertical bar chart.
@@ -7,6 +7,7 @@ interface ICJSDonutChartProps {
7
7
  clientHeight: number;
8
8
  /** Active theme colour bank from the host application. Falls back to default palette. */
9
9
  colorBank?: string[];
10
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
10
11
  }
11
12
  /**
12
13
  * Chart.js doughnut (donut) chart.
@@ -8,6 +8,7 @@ interface ICJSHorizontalBarChartProps {
8
8
  isChartStacked?: boolean;
9
9
  /** Active theme colour bank from the host application. Falls back to default palette. */
10
10
  colorBank?: string[];
11
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
11
12
  }
12
13
  /**
13
14
  * Chart.js horizontal bar chart.
@@ -9,6 +9,7 @@ interface ICJSLineChartProps {
9
9
  isChartStacked?: boolean;
10
10
  /** Active theme colour bank from the host application. Falls back to default palette. */
11
11
  colorBank?: string[];
12
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
12
13
  }
13
14
  /**
14
15
  * Chart.js line chart.
@@ -6,6 +6,7 @@ interface ICJSNormalizedStackAreaChartProps {
6
6
  clientWidth?: number;
7
7
  clientHeight?: number;
8
8
  colorBank?: string[];
9
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
9
10
  }
10
11
  /**
11
12
  * Chart.js 100% normalized stacked area chart.
@@ -6,6 +6,7 @@ interface ICJSNormalizedStackColumnChartProps {
6
6
  clientWidth?: number;
7
7
  clientHeight?: number;
8
8
  colorBank?: string[];
9
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
9
10
  }
10
11
  /**
11
12
  * Chart.js 100% normalized stacked vertical bar chart.
@@ -6,6 +6,7 @@ interface ICJSNormalizedStackHorizontalBarChartProps {
6
6
  clientWidth?: number;
7
7
  clientHeight?: number;
8
8
  colorBank?: string[];
9
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
9
10
  }
10
11
  /**
11
12
  * Chart.js 100% normalized stacked horizontal bar chart.
@@ -6,6 +6,7 @@ interface ICJSNormalizedStackLineChartProps {
6
6
  clientWidth?: number;
7
7
  clientHeight?: number;
8
8
  colorBank?: string[];
9
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
9
10
  }
10
11
  /**
11
12
  * Chart.js 100% normalized stacked line chart.
@@ -7,6 +7,7 @@ interface ICJSPieChartProps {
7
7
  clientHeight: number;
8
8
  /** Active theme colour bank from the host application. Falls back to default palette. */
9
9
  colorBank?: string[];
10
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
10
11
  }
11
12
  /**
12
13
  * Chart.js pie chart.
@@ -7,6 +7,7 @@ interface ICJSPolarAreaChartProps {
7
7
  clientHeight: number;
8
8
  /** Active theme colour bank from the host application. Falls back to default palette. */
9
9
  colorBank?: string[];
10
+ addLocalFilterFromLib?: (clickedLegendData: any) => void;
10
11
  }
11
12
  /**
12
13
  * Chart.js polar area chart.
@@ -6,4 +6,4 @@ import type { TCJSChartType } from "./ChartJSDataTransformer";
6
6
  * All colours, fonts, and visibility flags are derived from formatOptions so the
7
7
  * CJS charts match the styling configured in the host application's right pane.
8
8
  */
9
- export declare function mapFormatOptionsToChartJS(formatOptions: TDefaultChartFormatOptionsType, chartType: TCJSChartType, hasSecondaryAxis?: boolean): ChartOptions;
9
+ export declare function mapFormatOptionsToChartJS(formatOptions: TDefaultChartFormatOptionsType, chartType: TCJSChartType, hasSecondaryAxis?: boolean, addLocalFilterFromLib?: (clickedLegendData: any) => void, legendList?: any[]): ChartOptions;
@@ -58123,9 +58123,14 @@ function formatValueForAxis(value2, displayUnits, decimalPrecision) {
58123
58123
  if (displayUnits === "Billions") return (value2 / 1e9).toFixed(precision) + "B";
58124
58124
  return value2.toFixed(precision);
58125
58125
  }
58126
- function mapFormatOptionsToChartJS(formatOptions, chartType, hasSecondaryAxis = false) {
58126
+ function findLegendFromAlias(legendList, alias) {
58127
+ return legendList.find((d) => d.alias == alias);
58128
+ }
58129
+ function mapFormatOptionsToChartJS(formatOptions, chartType, hasSecondaryAxis = false, addLocalFilterFromLib, legendList) {
58127
58130
  const isCircular = chartType === "pie" || chartType === "doughnut" || chartType === "polarArea";
58128
58131
  const isHorizontal = chartType === "horizontalBar";
58132
+ let lastClickTime = 0;
58133
+ const DOUBLE_CLICK_DELAY = 300;
58129
58134
  const gridColor = formatOptions.plotArea?.gridLinesColor ?? "#e0e0e0";
58130
58135
  const legendLabelColor = formatOptions.legends?.legendFontColor ?? "#333333";
58131
58136
  const opts = {
@@ -58150,6 +58155,21 @@ function mapFormatOptionsToChartJS(formatOptions, chartType, hasSecondaryAxis =
58150
58155
  usePointStyle: false,
58151
58156
  boxWidth: 12,
58152
58157
  padding: 16
58158
+ },
58159
+ onClick: function(e, legendItem, legend) {
58160
+ if (addLocalFilterFromLib) {
58161
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
58162
+ const timeDiff = currentTime - lastClickTime;
58163
+ if (timeDiff < DOUBLE_CLICK_DELAY) {
58164
+ const actualLegend = findLegendFromAlias(legendList, legendItem.text);
58165
+ if (actualLegend) {
58166
+ addLocalFilterFromLib(actualLegend);
58167
+ }
58168
+ lastClickTime = 0;
58169
+ } else {
58170
+ lastClickTime = currentTime;
58171
+ }
58172
+ }
58153
58173
  }
58154
58174
  },
58155
58175
  // ---- Tooltip ----
@@ -73551,9 +73571,14 @@ const CJSColumnChart = ({
73551
73571
  clientWidth = 0,
73552
73572
  clientHeight = 0,
73553
73573
  isChartStacked,
73554
- colorBank
73574
+ colorBank,
73555
73575
  //= CJS_DEFAULT_COLORS,
73576
+ addLocalFilterFromLib
73556
73577
  }) => {
73578
+ const legendList = useMemo(
73579
+ () => data.ChartData?.map((s2) => s2.properties),
73580
+ [data]
73581
+ );
73557
73582
  const hasSecondaryAxis = useMemo(
73558
73583
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73559
73584
  [data]
@@ -73563,7 +73588,7 @@ const CJSColumnChart = ({
73563
73588
  [data, formatOptions, colorBank]
73564
73589
  );
73565
73590
  const chartOptions = useMemo(() => {
73566
- const opts = mapFormatOptionsToChartJS(formatOptions, "bar", hasSecondaryAxis);
73591
+ const opts = mapFormatOptionsToChartJS(formatOptions, "bar", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73567
73592
  if (isChartStacked) {
73568
73593
  opts.scales ??= {};
73569
73594
  opts.scales.x ??= {};
@@ -73592,8 +73617,13 @@ const CJSHorizontalBarChart = ({
73592
73617
  clientWidth = 0,
73593
73618
  clientHeight = 0,
73594
73619
  isChartStacked,
73595
- colorBank = CJS_DEFAULT_COLORS
73620
+ colorBank = CJS_DEFAULT_COLORS,
73621
+ addLocalFilterFromLib
73596
73622
  }) => {
73623
+ const legendList = useMemo(
73624
+ () => data.ChartData?.map((s2) => s2.properties),
73625
+ [data]
73626
+ );
73597
73627
  const hasSecondaryAxis = useMemo(
73598
73628
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73599
73629
  [data]
@@ -73603,7 +73633,7 @@ const CJSHorizontalBarChart = ({
73603
73633
  [data, formatOptions, colorBank]
73604
73634
  );
73605
73635
  const chartOptions = useMemo(() => {
73606
- const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", hasSecondaryAxis);
73636
+ const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73607
73637
  opts.indexAxis = "y";
73608
73638
  if (isChartStacked) {
73609
73639
  opts.scales ??= {};
@@ -73633,8 +73663,13 @@ const CJSLineChart = ({
73633
73663
  clientWidth = 0,
73634
73664
  clientHeight = 0,
73635
73665
  isChartStacked,
73636
- colorBank = CJS_DEFAULT_COLORS
73666
+ colorBank = CJS_DEFAULT_COLORS,
73667
+ addLocalFilterFromLib
73637
73668
  }) => {
73669
+ const legendList = useMemo(
73670
+ () => data.ChartData?.map((s2) => s2.properties),
73671
+ [data]
73672
+ );
73638
73673
  const hasSecondaryAxis = useMemo(
73639
73674
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73640
73675
  [data]
@@ -73644,7 +73679,7 @@ const CJSLineChart = ({
73644
73679
  [data, formatOptions, colorBank]
73645
73680
  );
73646
73681
  const chartOptions = useMemo(() => {
73647
- const opts = mapFormatOptionsToChartJS(formatOptions, "line", hasSecondaryAxis);
73682
+ const opts = mapFormatOptionsToChartJS(formatOptions, "line", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73648
73683
  if (isChartStacked) {
73649
73684
  opts.scales ??= {};
73650
73685
  opts.scales.y ??= {};
@@ -73671,8 +73706,13 @@ const CJSAreaChart = ({
73671
73706
  clientWidth = 0,
73672
73707
  clientHeight = 0,
73673
73708
  isChartStacked,
73674
- colorBank = CJS_DEFAULT_COLORS
73709
+ colorBank,
73710
+ addLocalFilterFromLib
73675
73711
  }) => {
73712
+ const legendList = useMemo(
73713
+ () => data.ChartData?.map((s2) => s2.properties),
73714
+ [data]
73715
+ );
73676
73716
  const hasSecondaryAxis = useMemo(
73677
73717
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73678
73718
  [data]
@@ -73682,7 +73722,7 @@ const CJSAreaChart = ({
73682
73722
  [data, formatOptions, colorBank]
73683
73723
  );
73684
73724
  const chartOptions = useMemo(() => {
73685
- const opts = mapFormatOptionsToChartJS(formatOptions, "area", hasSecondaryAxis);
73725
+ const opts = mapFormatOptionsToChartJS(formatOptions, "area", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73686
73726
  if (isChartStacked) {
73687
73727
  opts.scales ??= {};
73688
73728
  opts.scales.y ??= {};
@@ -73708,14 +73748,19 @@ const CJSPieChart = ({
73708
73748
  formatOptions,
73709
73749
  clientWidth,
73710
73750
  clientHeight,
73711
- colorBank
73751
+ colorBank,
73752
+ addLocalFilterFromLib
73712
73753
  }) => {
73754
+ const legendList = useMemo(
73755
+ () => data.LegendList ?? [],
73756
+ [data]
73757
+ );
73713
73758
  const chartData = useMemo(
73714
73759
  () => transformToChartJSData(data, "pie", formatOptions, colorBank),
73715
73760
  [data, formatOptions, colorBank]
73716
73761
  );
73717
73762
  const chartOptions = useMemo(
73718
- () => mapFormatOptionsToChartJS(formatOptions, "pie", false),
73763
+ () => mapFormatOptionsToChartJS(formatOptions, "pie", false, addLocalFilterFromLib, legendList),
73719
73764
  [formatOptions]
73720
73765
  );
73721
73766
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -73735,14 +73780,19 @@ const CJSDonutChart = ({
73735
73780
  formatOptions,
73736
73781
  clientWidth,
73737
73782
  clientHeight,
73738
- colorBank = CJS_DEFAULT_COLORS
73783
+ colorBank = CJS_DEFAULT_COLORS,
73784
+ addLocalFilterFromLib
73739
73785
  }) => {
73786
+ const legendList = useMemo(
73787
+ () => data.LegendList ?? [],
73788
+ [data]
73789
+ );
73740
73790
  const chartData = useMemo(
73741
73791
  () => transformToChartJSData(data, "doughnut", formatOptions, colorBank),
73742
73792
  [data, formatOptions, colorBank]
73743
73793
  );
73744
73794
  const chartOptions = useMemo(() => {
73745
- const base = mapFormatOptionsToChartJS(formatOptions, "doughnut", false);
73795
+ const base = mapFormatOptionsToChartJS(formatOptions, "doughnut", false, addLocalFilterFromLib, legendList);
73746
73796
  const rawInner = formatOptions.plotArea?.innerRadius;
73747
73797
  if (rawInner !== void 0 && rawInner !== null) {
73748
73798
  base.cutout = `${rawInner}%`;
@@ -73793,14 +73843,19 @@ const CJSBubbleChart = ({
73793
73843
  formatOptions,
73794
73844
  clientWidth,
73795
73845
  clientHeight,
73796
- colorBank = CJS_DEFAULT_COLORS
73846
+ colorBank = CJS_DEFAULT_COLORS,
73847
+ addLocalFilterFromLib
73797
73848
  }) => {
73849
+ const legendList = useMemo(
73850
+ () => data.ChartData?.map((s2) => s2.properties),
73851
+ [data]
73852
+ );
73798
73853
  const chartData = useMemo(
73799
73854
  () => transformToChartJSData(data, "bubble", formatOptions, colorBank),
73800
73855
  [data, formatOptions, colorBank]
73801
73856
  );
73802
73857
  const chartOptions = useMemo(
73803
- () => mapFormatOptionsToChartJS(formatOptions, "bubble", false),
73858
+ () => mapFormatOptionsToChartJS(formatOptions, "bubble", false, addLocalFilterFromLib, legendList),
73804
73859
  [formatOptions]
73805
73860
  );
73806
73861
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -73868,15 +73923,20 @@ const CJSPolarAreaChart = ({
73868
73923
  formatOptions,
73869
73924
  clientWidth,
73870
73925
  clientHeight,
73871
- colorBank = CJS_DEFAULT_COLORS
73926
+ colorBank = CJS_DEFAULT_COLORS,
73927
+ addLocalFilterFromLib
73872
73928
  }) => {
73929
+ const legendList = useMemo(
73930
+ () => data.LegendList ?? [],
73931
+ [data]
73932
+ );
73873
73933
  const chartData = useMemo(
73874
73934
  // Reuse the circular builder (same shape as pie)
73875
73935
  () => transformToChartJSData(data, "polarArea", formatOptions, colorBank),
73876
73936
  [data, formatOptions, colorBank]
73877
73937
  );
73878
73938
  const chartOptions = useMemo(() => {
73879
- const opts = mapFormatOptionsToChartJS(formatOptions, "polarArea", false);
73939
+ const opts = mapFormatOptionsToChartJS(formatOptions, "polarArea", false, addLocalFilterFromLib, legendList);
73880
73940
  delete opts.scales;
73881
73941
  const xAxisFontStyle = formatOptions.xAxisLabel?.xAxisLabelFontStyle;
73882
73942
  const isItalic = Array.isArray(xAxisFontStyle) ? xAxisFontStyle.includes("Italic") || xAxisFontStyle.includes("italic") : false;
@@ -73917,8 +73977,13 @@ const CJSNormalizedStackColumnChart = ({
73917
73977
  formatOptions,
73918
73978
  clientWidth = 0,
73919
73979
  clientHeight = 0,
73920
- colorBank = CJS_DEFAULT_COLORS
73980
+ colorBank = CJS_DEFAULT_COLORS,
73981
+ addLocalFilterFromLib
73921
73982
  }) => {
73983
+ const legendList = useMemo(
73984
+ () => data.ChartData?.map((s2) => s2.properties),
73985
+ [data]
73986
+ );
73922
73987
  const chartData = useMemo(
73923
73988
  () => transformToNormalizedChartJSData(data, "bar", formatOptions, colorBank),
73924
73989
  [data, formatOptions, colorBank]
@@ -73928,7 +73993,7 @@ const CJSNormalizedStackColumnChart = ({
73928
73993
  [chartData]
73929
73994
  );
73930
73995
  const chartOptions = useMemo(() => {
73931
- const opts = mapFormatOptionsToChartJS(formatOptions, "bar", false);
73996
+ const opts = mapFormatOptionsToChartJS(formatOptions, "bar", false, addLocalFilterFromLib, legendList);
73932
73997
  opts.scales ??= {};
73933
73998
  opts.scales.x ??= {};
73934
73999
  opts.scales.y ??= {};
@@ -73959,8 +74024,13 @@ const CJSNormalizedStackHorizontalBarChart = ({
73959
74024
  formatOptions,
73960
74025
  clientWidth = 0,
73961
74026
  clientHeight = 0,
73962
- colorBank = CJS_DEFAULT_COLORS
74027
+ colorBank = CJS_DEFAULT_COLORS,
74028
+ addLocalFilterFromLib
73963
74029
  }) => {
74030
+ const legendList = useMemo(
74031
+ () => data.ChartData?.map((s2) => s2.properties),
74032
+ [data]
74033
+ );
73964
74034
  const chartData = useMemo(
73965
74035
  () => transformToNormalizedChartJSData(data, "horizontalBar", formatOptions, colorBank),
73966
74036
  [data, formatOptions, colorBank]
@@ -73970,7 +74040,7 @@ const CJSNormalizedStackHorizontalBarChart = ({
73970
74040
  [chartData]
73971
74041
  );
73972
74042
  const chartOptions = useMemo(() => {
73973
- const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", false);
74043
+ const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", false, addLocalFilterFromLib, legendList);
73974
74044
  opts.indexAxis = "y";
73975
74045
  opts.scales ??= {};
73976
74046
  opts.scales.x ??= {};
@@ -74002,8 +74072,13 @@ const CJSNormalizedStackLineChart = ({
74002
74072
  formatOptions,
74003
74073
  clientWidth = 0,
74004
74074
  clientHeight = 0,
74005
- colorBank = CJS_DEFAULT_COLORS
74075
+ colorBank = CJS_DEFAULT_COLORS,
74076
+ addLocalFilterFromLib
74006
74077
  }) => {
74078
+ const legendList = useMemo(
74079
+ () => data.ChartData?.map((s2) => s2.properties),
74080
+ [data]
74081
+ );
74007
74082
  const chartData = useMemo(
74008
74083
  () => transformToNormalizedChartJSData(data, "line", formatOptions, colorBank),
74009
74084
  [data, formatOptions, colorBank]
@@ -74013,7 +74088,7 @@ const CJSNormalizedStackLineChart = ({
74013
74088
  [chartData]
74014
74089
  );
74015
74090
  const chartOptions = useMemo(() => {
74016
- const opts = mapFormatOptionsToChartJS(formatOptions, "line", false);
74091
+ const opts = mapFormatOptionsToChartJS(formatOptions, "line", false, addLocalFilterFromLib, legendList);
74017
74092
  opts.scales ??= {};
74018
74093
  opts.scales.y ??= {};
74019
74094
  opts.scales.y.stacked = true;
@@ -74042,8 +74117,13 @@ const CJSNormalizedStackAreaChart = ({
74042
74117
  formatOptions,
74043
74118
  clientWidth = 0,
74044
74119
  clientHeight = 0,
74045
- colorBank = CJS_DEFAULT_COLORS
74120
+ colorBank = CJS_DEFAULT_COLORS,
74121
+ addLocalFilterFromLib
74046
74122
  }) => {
74123
+ const legendList = useMemo(
74124
+ () => data.ChartData?.map((s2) => s2.properties),
74125
+ [data]
74126
+ );
74047
74127
  const chartData = useMemo(
74048
74128
  () => transformToNormalizedChartJSData(data, "area", formatOptions, colorBank),
74049
74129
  [data, formatOptions, colorBank]
@@ -74053,7 +74133,7 @@ const CJSNormalizedStackAreaChart = ({
74053
74133
  [chartData]
74054
74134
  );
74055
74135
  const chartOptions = useMemo(() => {
74056
- const opts = mapFormatOptionsToChartJS(formatOptions, "area", false);
74136
+ const opts = mapFormatOptionsToChartJS(formatOptions, "area", false, addLocalFilterFromLib, legendList);
74057
74137
  opts.scales ??= {};
74058
74138
  opts.scales.y ??= {};
74059
74139
  opts.scales.y.stacked = true;
@@ -58126,9 +58126,14 @@
58126
58126
  if (displayUnits === "Billions") return (value2 / 1e9).toFixed(precision) + "B";
58127
58127
  return value2.toFixed(precision);
58128
58128
  }
58129
- function mapFormatOptionsToChartJS(formatOptions, chartType, hasSecondaryAxis = false) {
58129
+ function findLegendFromAlias(legendList, alias) {
58130
+ return legendList.find((d) => d.alias == alias);
58131
+ }
58132
+ function mapFormatOptionsToChartJS(formatOptions, chartType, hasSecondaryAxis = false, addLocalFilterFromLib, legendList) {
58130
58133
  const isCircular = chartType === "pie" || chartType === "doughnut" || chartType === "polarArea";
58131
58134
  const isHorizontal = chartType === "horizontalBar";
58135
+ let lastClickTime = 0;
58136
+ const DOUBLE_CLICK_DELAY = 300;
58132
58137
  const gridColor = formatOptions.plotArea?.gridLinesColor ?? "#e0e0e0";
58133
58138
  const legendLabelColor = formatOptions.legends?.legendFontColor ?? "#333333";
58134
58139
  const opts = {
@@ -58153,6 +58158,21 @@
58153
58158
  usePointStyle: false,
58154
58159
  boxWidth: 12,
58155
58160
  padding: 16
58161
+ },
58162
+ onClick: function(e, legendItem, legend) {
58163
+ if (addLocalFilterFromLib) {
58164
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
58165
+ const timeDiff = currentTime - lastClickTime;
58166
+ if (timeDiff < DOUBLE_CLICK_DELAY) {
58167
+ const actualLegend = findLegendFromAlias(legendList, legendItem.text);
58168
+ if (actualLegend) {
58169
+ addLocalFilterFromLib(actualLegend);
58170
+ }
58171
+ lastClickTime = 0;
58172
+ } else {
58173
+ lastClickTime = currentTime;
58174
+ }
58175
+ }
58156
58176
  }
58157
58177
  },
58158
58178
  // ---- Tooltip ----
@@ -73554,9 +73574,14 @@ ${formattedValue}` : formattedValue;
73554
73574
  clientWidth = 0,
73555
73575
  clientHeight = 0,
73556
73576
  isChartStacked,
73557
- colorBank
73577
+ colorBank,
73558
73578
  //= CJS_DEFAULT_COLORS,
73579
+ addLocalFilterFromLib
73559
73580
  }) => {
73581
+ const legendList = require$$0$1.useMemo(
73582
+ () => data.ChartData?.map((s2) => s2.properties),
73583
+ [data]
73584
+ );
73560
73585
  const hasSecondaryAxis = require$$0$1.useMemo(
73561
73586
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73562
73587
  [data]
@@ -73566,7 +73591,7 @@ ${formattedValue}` : formattedValue;
73566
73591
  [data, formatOptions, colorBank]
73567
73592
  );
73568
73593
  const chartOptions = require$$0$1.useMemo(() => {
73569
- const opts = mapFormatOptionsToChartJS(formatOptions, "bar", hasSecondaryAxis);
73594
+ const opts = mapFormatOptionsToChartJS(formatOptions, "bar", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73570
73595
  if (isChartStacked) {
73571
73596
  opts.scales ??= {};
73572
73597
  opts.scales.x ??= {};
@@ -73595,8 +73620,13 @@ ${formattedValue}` : formattedValue;
73595
73620
  clientWidth = 0,
73596
73621
  clientHeight = 0,
73597
73622
  isChartStacked,
73598
- colorBank = CJS_DEFAULT_COLORS
73623
+ colorBank = CJS_DEFAULT_COLORS,
73624
+ addLocalFilterFromLib
73599
73625
  }) => {
73626
+ const legendList = require$$0$1.useMemo(
73627
+ () => data.ChartData?.map((s2) => s2.properties),
73628
+ [data]
73629
+ );
73600
73630
  const hasSecondaryAxis = require$$0$1.useMemo(
73601
73631
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73602
73632
  [data]
@@ -73606,7 +73636,7 @@ ${formattedValue}` : formattedValue;
73606
73636
  [data, formatOptions, colorBank]
73607
73637
  );
73608
73638
  const chartOptions = require$$0$1.useMemo(() => {
73609
- const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", hasSecondaryAxis);
73639
+ const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73610
73640
  opts.indexAxis = "y";
73611
73641
  if (isChartStacked) {
73612
73642
  opts.scales ??= {};
@@ -73636,8 +73666,13 @@ ${formattedValue}` : formattedValue;
73636
73666
  clientWidth = 0,
73637
73667
  clientHeight = 0,
73638
73668
  isChartStacked,
73639
- colorBank = CJS_DEFAULT_COLORS
73669
+ colorBank = CJS_DEFAULT_COLORS,
73670
+ addLocalFilterFromLib
73640
73671
  }) => {
73672
+ const legendList = require$$0$1.useMemo(
73673
+ () => data.ChartData?.map((s2) => s2.properties),
73674
+ [data]
73675
+ );
73641
73676
  const hasSecondaryAxis = require$$0$1.useMemo(
73642
73677
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73643
73678
  [data]
@@ -73647,7 +73682,7 @@ ${formattedValue}` : formattedValue;
73647
73682
  [data, formatOptions, colorBank]
73648
73683
  );
73649
73684
  const chartOptions = require$$0$1.useMemo(() => {
73650
- const opts = mapFormatOptionsToChartJS(formatOptions, "line", hasSecondaryAxis);
73685
+ const opts = mapFormatOptionsToChartJS(formatOptions, "line", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73651
73686
  if (isChartStacked) {
73652
73687
  opts.scales ??= {};
73653
73688
  opts.scales.y ??= {};
@@ -73674,8 +73709,13 @@ ${formattedValue}` : formattedValue;
73674
73709
  clientWidth = 0,
73675
73710
  clientHeight = 0,
73676
73711
  isChartStacked,
73677
- colorBank = CJS_DEFAULT_COLORS
73712
+ colorBank,
73713
+ addLocalFilterFromLib
73678
73714
  }) => {
73715
+ const legendList = require$$0$1.useMemo(
73716
+ () => data.ChartData?.map((s2) => s2.properties),
73717
+ [data]
73718
+ );
73679
73719
  const hasSecondaryAxis = require$$0$1.useMemo(
73680
73720
  () => data.ChartData?.some((s2) => s2.Axis === "Secondary" || s2.properties?.axis === "Secondary"),
73681
73721
  [data]
@@ -73685,7 +73725,7 @@ ${formattedValue}` : formattedValue;
73685
73725
  [data, formatOptions, colorBank]
73686
73726
  );
73687
73727
  const chartOptions = require$$0$1.useMemo(() => {
73688
- const opts = mapFormatOptionsToChartJS(formatOptions, "area", hasSecondaryAxis);
73728
+ const opts = mapFormatOptionsToChartJS(formatOptions, "area", hasSecondaryAxis, addLocalFilterFromLib, legendList);
73689
73729
  if (isChartStacked) {
73690
73730
  opts.scales ??= {};
73691
73731
  opts.scales.y ??= {};
@@ -73711,14 +73751,19 @@ ${formattedValue}` : formattedValue;
73711
73751
  formatOptions,
73712
73752
  clientWidth,
73713
73753
  clientHeight,
73714
- colorBank
73754
+ colorBank,
73755
+ addLocalFilterFromLib
73715
73756
  }) => {
73757
+ const legendList = require$$0$1.useMemo(
73758
+ () => data.LegendList ?? [],
73759
+ [data]
73760
+ );
73716
73761
  const chartData = require$$0$1.useMemo(
73717
73762
  () => transformToChartJSData(data, "pie", formatOptions, colorBank),
73718
73763
  [data, formatOptions, colorBank]
73719
73764
  );
73720
73765
  const chartOptions = require$$0$1.useMemo(
73721
- () => mapFormatOptionsToChartJS(formatOptions, "pie", false),
73766
+ () => mapFormatOptionsToChartJS(formatOptions, "pie", false, addLocalFilterFromLib, legendList),
73722
73767
  [formatOptions]
73723
73768
  );
73724
73769
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -73738,14 +73783,19 @@ ${formattedValue}` : formattedValue;
73738
73783
  formatOptions,
73739
73784
  clientWidth,
73740
73785
  clientHeight,
73741
- colorBank = CJS_DEFAULT_COLORS
73786
+ colorBank = CJS_DEFAULT_COLORS,
73787
+ addLocalFilterFromLib
73742
73788
  }) => {
73789
+ const legendList = require$$0$1.useMemo(
73790
+ () => data.LegendList ?? [],
73791
+ [data]
73792
+ );
73743
73793
  const chartData = require$$0$1.useMemo(
73744
73794
  () => transformToChartJSData(data, "doughnut", formatOptions, colorBank),
73745
73795
  [data, formatOptions, colorBank]
73746
73796
  );
73747
73797
  const chartOptions = require$$0$1.useMemo(() => {
73748
- const base = mapFormatOptionsToChartJS(formatOptions, "doughnut", false);
73798
+ const base = mapFormatOptionsToChartJS(formatOptions, "doughnut", false, addLocalFilterFromLib, legendList);
73749
73799
  const rawInner = formatOptions.plotArea?.innerRadius;
73750
73800
  if (rawInner !== void 0 && rawInner !== null) {
73751
73801
  base.cutout = `${rawInner}%`;
@@ -73796,14 +73846,19 @@ ${formattedValue}` : formattedValue;
73796
73846
  formatOptions,
73797
73847
  clientWidth,
73798
73848
  clientHeight,
73799
- colorBank = CJS_DEFAULT_COLORS
73849
+ colorBank = CJS_DEFAULT_COLORS,
73850
+ addLocalFilterFromLib
73800
73851
  }) => {
73852
+ const legendList = require$$0$1.useMemo(
73853
+ () => data.ChartData?.map((s2) => s2.properties),
73854
+ [data]
73855
+ );
73801
73856
  const chartData = require$$0$1.useMemo(
73802
73857
  () => transformToChartJSData(data, "bubble", formatOptions, colorBank),
73803
73858
  [data, formatOptions, colorBank]
73804
73859
  );
73805
73860
  const chartOptions = require$$0$1.useMemo(
73806
- () => mapFormatOptionsToChartJS(formatOptions, "bubble", false),
73861
+ () => mapFormatOptionsToChartJS(formatOptions, "bubble", false, addLocalFilterFromLib, legendList),
73807
73862
  [formatOptions]
73808
73863
  );
73809
73864
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -73871,15 +73926,20 @@ ${formattedValue}` : formattedValue;
73871
73926
  formatOptions,
73872
73927
  clientWidth,
73873
73928
  clientHeight,
73874
- colorBank = CJS_DEFAULT_COLORS
73929
+ colorBank = CJS_DEFAULT_COLORS,
73930
+ addLocalFilterFromLib
73875
73931
  }) => {
73932
+ const legendList = require$$0$1.useMemo(
73933
+ () => data.LegendList ?? [],
73934
+ [data]
73935
+ );
73876
73936
  const chartData = require$$0$1.useMemo(
73877
73937
  // Reuse the circular builder (same shape as pie)
73878
73938
  () => transformToChartJSData(data, "polarArea", formatOptions, colorBank),
73879
73939
  [data, formatOptions, colorBank]
73880
73940
  );
73881
73941
  const chartOptions = require$$0$1.useMemo(() => {
73882
- const opts = mapFormatOptionsToChartJS(formatOptions, "polarArea", false);
73942
+ const opts = mapFormatOptionsToChartJS(formatOptions, "polarArea", false, addLocalFilterFromLib, legendList);
73883
73943
  delete opts.scales;
73884
73944
  const xAxisFontStyle = formatOptions.xAxisLabel?.xAxisLabelFontStyle;
73885
73945
  const isItalic = Array.isArray(xAxisFontStyle) ? xAxisFontStyle.includes("Italic") || xAxisFontStyle.includes("italic") : false;
@@ -73920,8 +73980,13 @@ ${formattedValue}` : formattedValue;
73920
73980
  formatOptions,
73921
73981
  clientWidth = 0,
73922
73982
  clientHeight = 0,
73923
- colorBank = CJS_DEFAULT_COLORS
73983
+ colorBank = CJS_DEFAULT_COLORS,
73984
+ addLocalFilterFromLib
73924
73985
  }) => {
73986
+ const legendList = require$$0$1.useMemo(
73987
+ () => data.ChartData?.map((s2) => s2.properties),
73988
+ [data]
73989
+ );
73925
73990
  const chartData = require$$0$1.useMemo(
73926
73991
  () => transformToNormalizedChartJSData(data, "bar", formatOptions, colorBank),
73927
73992
  [data, formatOptions, colorBank]
@@ -73931,7 +73996,7 @@ ${formattedValue}` : formattedValue;
73931
73996
  [chartData]
73932
73997
  );
73933
73998
  const chartOptions = require$$0$1.useMemo(() => {
73934
- const opts = mapFormatOptionsToChartJS(formatOptions, "bar", false);
73999
+ const opts = mapFormatOptionsToChartJS(formatOptions, "bar", false, addLocalFilterFromLib, legendList);
73935
74000
  opts.scales ??= {};
73936
74001
  opts.scales.x ??= {};
73937
74002
  opts.scales.y ??= {};
@@ -73962,8 +74027,13 @@ ${formattedValue}` : formattedValue;
73962
74027
  formatOptions,
73963
74028
  clientWidth = 0,
73964
74029
  clientHeight = 0,
73965
- colorBank = CJS_DEFAULT_COLORS
74030
+ colorBank = CJS_DEFAULT_COLORS,
74031
+ addLocalFilterFromLib
73966
74032
  }) => {
74033
+ const legendList = require$$0$1.useMemo(
74034
+ () => data.ChartData?.map((s2) => s2.properties),
74035
+ [data]
74036
+ );
73967
74037
  const chartData = require$$0$1.useMemo(
73968
74038
  () => transformToNormalizedChartJSData(data, "horizontalBar", formatOptions, colorBank),
73969
74039
  [data, formatOptions, colorBank]
@@ -73973,7 +74043,7 @@ ${formattedValue}` : formattedValue;
73973
74043
  [chartData]
73974
74044
  );
73975
74045
  const chartOptions = require$$0$1.useMemo(() => {
73976
- const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", false);
74046
+ const opts = mapFormatOptionsToChartJS(formatOptions, "horizontalBar", false, addLocalFilterFromLib, legendList);
73977
74047
  opts.indexAxis = "y";
73978
74048
  opts.scales ??= {};
73979
74049
  opts.scales.x ??= {};
@@ -74005,8 +74075,13 @@ ${formattedValue}` : formattedValue;
74005
74075
  formatOptions,
74006
74076
  clientWidth = 0,
74007
74077
  clientHeight = 0,
74008
- colorBank = CJS_DEFAULT_COLORS
74078
+ colorBank = CJS_DEFAULT_COLORS,
74079
+ addLocalFilterFromLib
74009
74080
  }) => {
74081
+ const legendList = require$$0$1.useMemo(
74082
+ () => data.ChartData?.map((s2) => s2.properties),
74083
+ [data]
74084
+ );
74010
74085
  const chartData = require$$0$1.useMemo(
74011
74086
  () => transformToNormalizedChartJSData(data, "line", formatOptions, colorBank),
74012
74087
  [data, formatOptions, colorBank]
@@ -74016,7 +74091,7 @@ ${formattedValue}` : formattedValue;
74016
74091
  [chartData]
74017
74092
  );
74018
74093
  const chartOptions = require$$0$1.useMemo(() => {
74019
- const opts = mapFormatOptionsToChartJS(formatOptions, "line", false);
74094
+ const opts = mapFormatOptionsToChartJS(formatOptions, "line", false, addLocalFilterFromLib, legendList);
74020
74095
  opts.scales ??= {};
74021
74096
  opts.scales.y ??= {};
74022
74097
  opts.scales.y.stacked = true;
@@ -74045,8 +74120,13 @@ ${formattedValue}` : formattedValue;
74045
74120
  formatOptions,
74046
74121
  clientWidth = 0,
74047
74122
  clientHeight = 0,
74048
- colorBank = CJS_DEFAULT_COLORS
74123
+ colorBank = CJS_DEFAULT_COLORS,
74124
+ addLocalFilterFromLib
74049
74125
  }) => {
74126
+ const legendList = require$$0$1.useMemo(
74127
+ () => data.ChartData?.map((s2) => s2.properties),
74128
+ [data]
74129
+ );
74050
74130
  const chartData = require$$0$1.useMemo(
74051
74131
  () => transformToNormalizedChartJSData(data, "area", formatOptions, colorBank),
74052
74132
  [data, formatOptions, colorBank]
@@ -74056,7 +74136,7 @@ ${formattedValue}` : formattedValue;
74056
74136
  [chartData]
74057
74137
  );
74058
74138
  const chartOptions = require$$0$1.useMemo(() => {
74059
- const opts = mapFormatOptionsToChartJS(formatOptions, "area", false);
74139
+ const opts = mapFormatOptionsToChartJS(formatOptions, "area", false, addLocalFilterFromLib, legendList);
74060
74140
  opts.scales ??= {};
74061
74141
  opts.scales.y ??= {};
74062
74142
  opts.scales.y.stacked = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pace-chart-lib",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "A simple React + Vite + TS UI library with a Button using custom fonts via SCSS.",
5
5
  "license": "MIT",
6
6
  "type": "module",