@adiba-banking-cloud/backoffice 0.0.97 → 0.0.98

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.
@@ -11225,7 +11225,8 @@ const initChart$2 = props => {
11225
11225
  type: "column",
11226
11226
  borderRadius: 8,
11227
11227
  backgroundColor: props?.bgColor || "rgba(255, 255, 255, 0)",
11228
- plotBackgroundColor: props?.plotBgColor || "rgba(255, 255, 255, 0)"
11228
+ plotBackgroundColor: props?.plotBgColor || "rgba(255, 255, 255, 0)",
11229
+ inverted: props?.inverted || false
11229
11230
  },
11230
11231
  tooltip: {
11231
11232
  backgroundColor: "#0F193D",
@@ -11376,7 +11377,8 @@ const EqualizerColumn = props => {
11376
11377
  bgColor: props.bgColor,
11377
11378
  plotBgColor: props.plotBgColor,
11378
11379
  colors: [props.color || "blue"],
11379
- title: props.title
11380
+ title: props.title,
11381
+ inverted: props.inverted
11380
11382
  };
11381
11383
  return /*#__PURE__*/React.createElement(Column, chartOptions);
11382
11384
  };
@@ -11390,7 +11392,8 @@ const SimpleColumn = props => {
11390
11392
  bgColor: props.bgColor,
11391
11393
  plotBgColor: props.plotBgColor,
11392
11394
  colors: [props.color || "gray"],
11393
- title: props.title
11395
+ title: props.title,
11396
+ inverted: props.inverted
11394
11397
  };
11395
11398
  return /*#__PURE__*/React.createElement(Column, chartOptions);
11396
11399
  };
@@ -11518,7 +11521,16 @@ const initSeries$2 = props => {
11518
11521
  };
11519
11522
  };
11520
11523
 
11524
+ const isMultiAxis = props => {
11525
+ return "yAxisConfig" in props;
11526
+ };
11527
+ const isStacked = props => {
11528
+ // StackedAreaChartProps doesn't have yAxisConfig, but has multiple series
11529
+ return !("yAxisConfig" in props) && props.series.length > 1;
11530
+ };
11521
11531
  const initChart$1 = props => {
11532
+ const isMulti = isMultiAxis(props);
11533
+ const isStackedChart = isStacked(props);
11522
11534
  return {
11523
11535
  chart: {
11524
11536
  type: "areaspline",
@@ -11533,7 +11545,45 @@ const initChart$1 = props => {
11533
11545
  style: {
11534
11546
  color: "white"
11535
11547
  },
11536
- format: props.series.length > 1 ? "<b>{key}</b><br/>{series.name}: <b>{y}</b><br/>" + "Total: <b>{point.stackTotal}</b>" : "<b>{key}</b><br/>{series.name}: {y}<br/>"
11548
+ formatter: function () {
11549
+ const point = this.point;
11550
+ const series = this.series;
11551
+ const key = this.key || this.x;
11552
+ if (isStackedChart) {
11553
+ const stackedProps = props;
11554
+ const aggregator = stackedProps.aggregator || "sum";
11555
+ const stackTotal = point.stackTotal || point.y;
11556
+ if (aggregator === "average") {
11557
+ const seriesCount = props.series.length;
11558
+ const average = (stackTotal / seriesCount).toFixed(2);
11559
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Average: <b>${average}</b>`;
11560
+ } else {
11561
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Total: <b>${stackTotal}</b>`;
11562
+ }
11563
+ }
11564
+ if (isMulti) {
11565
+ const multiProps = props;
11566
+ const aggregator = multiProps.aggregator || "sum";
11567
+ const chart = this.series.chart;
11568
+ const allSeries = chart.series;
11569
+ const pointIndex = series.data.indexOf(point);
11570
+ let sum = 0;
11571
+ let count = 0;
11572
+ allSeries.forEach(s => {
11573
+ if (s.data && s.data[pointIndex] && s.data[pointIndex].y !== null && s.data[pointIndex].y !== undefined) {
11574
+ sum += s.data[pointIndex].y;
11575
+ count++;
11576
+ }
11577
+ });
11578
+ if (aggregator === "average") {
11579
+ const average = count > 0 ? (sum / count).toFixed(2) : "0.00";
11580
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Average: <b>${average}</b>`;
11581
+ } else {
11582
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Total: <b>${sum}</b>`;
11583
+ }
11584
+ }
11585
+ return `<b>${key}</b><br/>${series.name}: ${point.y}<br/>`;
11586
+ }
11537
11587
  },
11538
11588
  credits: {
11539
11589
  enabled: false
@@ -11551,8 +11601,8 @@ const initChart$1 = props => {
11551
11601
  },
11552
11602
  legend: {
11553
11603
  enabled: props.withLegend,
11554
- align: "right",
11555
- verticalAlign: "top"
11604
+ align: props.legendPosition?.align || "right",
11605
+ verticalAlign: props.legendPosition?.verticalAlign || "top"
11556
11606
  }
11557
11607
  };
11558
11608
  };
@@ -11589,7 +11639,9 @@ const SimpleArea = props => {
11589
11639
  bgColor: props.bgColor,
11590
11640
  plotBgColor: props.plotBgColor,
11591
11641
  colors: [props.color || "gray"],
11592
- title: props.title
11642
+ title: props.title,
11643
+ legendPosition: props.legendPosition,
11644
+ showYAxis: props.showYAxis
11593
11645
  };
11594
11646
  return /*#__PURE__*/React.createElement(Area, chartOptions);
11595
11647
  };
@@ -11626,12 +11678,27 @@ const initSeries$1 = props => {
11626
11678
  const labels = {
11627
11679
  color: "#575E77"
11628
11680
  };
11629
- return {
11681
+ const yAxis = {
11630
11682
  ...defaults,
11631
11683
  ...{
11632
11684
  labels
11633
11685
  }
11634
11686
  };
11687
+
11688
+ // Hide yAxis if showYAxis is false
11689
+ if (props.showYAxis === false) {
11690
+ return {
11691
+ ...yAxis,
11692
+ visible: false,
11693
+ labels: {
11694
+ enabled: false
11695
+ },
11696
+ title: {
11697
+ text: null
11698
+ }
11699
+ };
11700
+ }
11701
+ return yAxis;
11635
11702
  };
11636
11703
  const renderPlot = () => {
11637
11704
  const areaspline = {
@@ -11204,7 +11204,8 @@ const initChart$2 = props => {
11204
11204
  type: "column",
11205
11205
  borderRadius: 8,
11206
11206
  backgroundColor: props?.bgColor || "rgba(255, 255, 255, 0)",
11207
- plotBackgroundColor: props?.plotBgColor || "rgba(255, 255, 255, 0)"
11207
+ plotBackgroundColor: props?.plotBgColor || "rgba(255, 255, 255, 0)",
11208
+ inverted: props?.inverted || false
11208
11209
  },
11209
11210
  tooltip: {
11210
11211
  backgroundColor: "#0F193D",
@@ -11355,7 +11356,8 @@ const EqualizerColumn = props => {
11355
11356
  bgColor: props.bgColor,
11356
11357
  plotBgColor: props.plotBgColor,
11357
11358
  colors: [props.color || "blue"],
11358
- title: props.title
11359
+ title: props.title,
11360
+ inverted: props.inverted
11359
11361
  };
11360
11362
  return /*#__PURE__*/React.createElement(Column, chartOptions);
11361
11363
  };
@@ -11369,7 +11371,8 @@ const SimpleColumn = props => {
11369
11371
  bgColor: props.bgColor,
11370
11372
  plotBgColor: props.plotBgColor,
11371
11373
  colors: [props.color || "gray"],
11372
- title: props.title
11374
+ title: props.title,
11375
+ inverted: props.inverted
11373
11376
  };
11374
11377
  return /*#__PURE__*/React.createElement(Column, chartOptions);
11375
11378
  };
@@ -11497,7 +11500,16 @@ const initSeries$2 = props => {
11497
11500
  };
11498
11501
  };
11499
11502
 
11503
+ const isMultiAxis = props => {
11504
+ return "yAxisConfig" in props;
11505
+ };
11506
+ const isStacked = props => {
11507
+ // StackedAreaChartProps doesn't have yAxisConfig, but has multiple series
11508
+ return !("yAxisConfig" in props) && props.series.length > 1;
11509
+ };
11500
11510
  const initChart$1 = props => {
11511
+ const isMulti = isMultiAxis(props);
11512
+ const isStackedChart = isStacked(props);
11501
11513
  return {
11502
11514
  chart: {
11503
11515
  type: "areaspline",
@@ -11512,7 +11524,45 @@ const initChart$1 = props => {
11512
11524
  style: {
11513
11525
  color: "white"
11514
11526
  },
11515
- format: props.series.length > 1 ? "<b>{key}</b><br/>{series.name}: <b>{y}</b><br/>" + "Total: <b>{point.stackTotal}</b>" : "<b>{key}</b><br/>{series.name}: {y}<br/>"
11527
+ formatter: function () {
11528
+ const point = this.point;
11529
+ const series = this.series;
11530
+ const key = this.key || this.x;
11531
+ if (isStackedChart) {
11532
+ const stackedProps = props;
11533
+ const aggregator = stackedProps.aggregator || "sum";
11534
+ const stackTotal = point.stackTotal || point.y;
11535
+ if (aggregator === "average") {
11536
+ const seriesCount = props.series.length;
11537
+ const average = (stackTotal / seriesCount).toFixed(2);
11538
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Average: <b>${average}</b>`;
11539
+ } else {
11540
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Total: <b>${stackTotal}</b>`;
11541
+ }
11542
+ }
11543
+ if (isMulti) {
11544
+ const multiProps = props;
11545
+ const aggregator = multiProps.aggregator || "sum";
11546
+ const chart = this.series.chart;
11547
+ const allSeries = chart.series;
11548
+ const pointIndex = series.data.indexOf(point);
11549
+ let sum = 0;
11550
+ let count = 0;
11551
+ allSeries.forEach(s => {
11552
+ if (s.data && s.data[pointIndex] && s.data[pointIndex].y !== null && s.data[pointIndex].y !== undefined) {
11553
+ sum += s.data[pointIndex].y;
11554
+ count++;
11555
+ }
11556
+ });
11557
+ if (aggregator === "average") {
11558
+ const average = count > 0 ? (sum / count).toFixed(2) : "0.00";
11559
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Average: <b>${average}</b>`;
11560
+ } else {
11561
+ return `<b>${key}</b><br/>${series.name}: <b>${point.y}</b><br/>` + `Total: <b>${sum}</b>`;
11562
+ }
11563
+ }
11564
+ return `<b>${key}</b><br/>${series.name}: ${point.y}<br/>`;
11565
+ }
11516
11566
  },
11517
11567
  credits: {
11518
11568
  enabled: false
@@ -11530,8 +11580,8 @@ const initChart$1 = props => {
11530
11580
  },
11531
11581
  legend: {
11532
11582
  enabled: props.withLegend,
11533
- align: "right",
11534
- verticalAlign: "top"
11583
+ align: props.legendPosition?.align || "right",
11584
+ verticalAlign: props.legendPosition?.verticalAlign || "top"
11535
11585
  }
11536
11586
  };
11537
11587
  };
@@ -11568,7 +11618,9 @@ const SimpleArea = props => {
11568
11618
  bgColor: props.bgColor,
11569
11619
  plotBgColor: props.plotBgColor,
11570
11620
  colors: [props.color || "gray"],
11571
- title: props.title
11621
+ title: props.title,
11622
+ legendPosition: props.legendPosition,
11623
+ showYAxis: props.showYAxis
11572
11624
  };
11573
11625
  return /*#__PURE__*/React.createElement(Area, chartOptions);
11574
11626
  };
@@ -11605,12 +11657,27 @@ const initSeries$1 = props => {
11605
11657
  const labels = {
11606
11658
  color: "#575E77"
11607
11659
  };
11608
- return {
11660
+ const yAxis = {
11609
11661
  ...defaults,
11610
11662
  ...{
11611
11663
  labels
11612
11664
  }
11613
11665
  };
11666
+
11667
+ // Hide yAxis if showYAxis is false
11668
+ if (props.showYAxis === false) {
11669
+ return {
11670
+ ...yAxis,
11671
+ visible: false,
11672
+ labels: {
11673
+ enabled: false
11674
+ },
11675
+ title: {
11676
+ text: null
11677
+ }
11678
+ };
11679
+ }
11680
+ return yAxis;
11614
11681
  };
11615
11682
  const renderPlot = () => {
11616
11683
  const areaspline = {
@@ -1,3 +1,5 @@
1
1
  import React from "react";
2
- import { SimpleAreaChartProps } from "./Area.types";
2
+ import { SimpleAreaChartProps, MultiAxisAreaChartProps, StackedAreaChartProps } from "./Area.types";
3
3
  export declare const SimpleArea: React.FC<SimpleAreaChartProps>;
4
+ export declare const MultiAxisArea: React.FC<MultiAxisAreaChartProps>;
5
+ export declare const StackedArea: React.FC<StackedAreaChartProps>;
@@ -1,2 +1,2 @@
1
- import { AreaChartConfig, AreaChartProps } from "./Area.types";
2
- export declare const initChart: (props: AreaChartProps) => AreaChartConfig;
1
+ import { AreaChartConfig, AreaChartProps, MultiAxisAreaChartProps, StackedAreaChartProps } from "./Area.types";
2
+ export declare const initChart: (props: AreaChartProps | MultiAxisAreaChartProps | StackedAreaChartProps) => AreaChartConfig;
@@ -4,3 +4,5 @@ import { SimpleArea } from "./Area";
4
4
  declare const _default: Meta<typeof SimpleArea>;
5
5
  export default _default;
6
6
  export declare const SimpleAreaChart: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("./Area.types").SimpleAreaChartProps>;
7
+ export declare const MultiAxisAreaChart: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("./Area.types").MultiAxisAreaChartProps>;
8
+ export declare const StackedAreaChart: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("./Area.types").StackedAreaChartProps>;
@@ -17,6 +17,11 @@ export interface AreaChartProps {
17
17
  series: number[][];
18
18
  withLegend: boolean;
19
19
  withCrossHair: boolean;
20
+ legendPosition?: {
21
+ align?: "left" | "center" | "right";
22
+ verticalAlign?: "top" | "middle" | "bottom";
23
+ };
24
+ showYAxis?: boolean;
20
25
  }
21
26
  export interface SimpleAreaChartProps {
22
27
  bgColor?: string;
@@ -28,6 +33,11 @@ export interface SimpleAreaChartProps {
28
33
  series: number[];
29
34
  withLegend: boolean;
30
35
  withCrossHair: boolean;
36
+ legendPosition?: {
37
+ align?: "left" | "center" | "right";
38
+ verticalAlign?: "top" | "middle" | "bottom";
39
+ };
40
+ showYAxis?: boolean;
31
41
  }
32
42
  export interface ChartSeriesArea {
33
43
  xAxis: {
@@ -46,7 +56,13 @@ export interface ChartSeriesArea {
46
56
  gridLineDashStyle?: string;
47
57
  gridLineWidth?: number;
48
58
  labels: object;
49
- };
59
+ } | Array<{
60
+ allowDecimals: boolean;
61
+ title: object;
62
+ gridLineDashStyle?: string;
63
+ gridLineWidth?: number;
64
+ labels: object;
65
+ }>;
50
66
  series: AreaChartSeries[];
51
67
  plotOptions: object;
52
68
  }
@@ -56,4 +72,49 @@ export interface AreaChartSeries {
56
72
  color: string;
57
73
  enableMouseTracking?: boolean;
58
74
  showInLegend?: boolean;
75
+ yAxis?: number;
76
+ }
77
+ export interface MultiAxisAreaChartProps {
78
+ bgColor?: string;
79
+ plotBgColor?: string;
80
+ colors?: string[];
81
+ title?: string;
82
+ xAxisLabel: string[];
83
+ yAxisLabel: string[];
84
+ series: number[][];
85
+ withLegend: boolean;
86
+ withCrossHair: boolean;
87
+ legendPosition?: {
88
+ align?: "left" | "center" | "right";
89
+ verticalAlign?: "top" | "middle" | "bottom";
90
+ };
91
+ showYAxis?: boolean | boolean[];
92
+ aggregator?: "sum" | "average";
93
+ yAxisConfig?: Array<{
94
+ title?: string;
95
+ allowDecimals?: boolean;
96
+ gridLineDashStyle?: string;
97
+ gridLineWidth?: number;
98
+ labels?: {
99
+ color?: string;
100
+ formatter?: (ctx: any) => string;
101
+ };
102
+ }>;
103
+ }
104
+ export interface StackedAreaChartProps {
105
+ bgColor?: string;
106
+ plotBgColor?: string;
107
+ colors?: string[];
108
+ title?: string;
109
+ xAxisLabel: string[];
110
+ yAxisLabel: string[];
111
+ series: number[][];
112
+ withLegend: boolean;
113
+ withCrossHair: boolean;
114
+ legendPosition?: {
115
+ align?: "left" | "center" | "right";
116
+ verticalAlign?: "top" | "middle" | "bottom";
117
+ };
118
+ showYAxis?: boolean;
119
+ aggregator?: "sum" | "average";
59
120
  }
@@ -8,6 +8,7 @@ export interface ChartProps {
8
8
  series: number[][];
9
9
  withLegend: boolean;
10
10
  equalizer: boolean;
11
+ inverted?: boolean;
11
12
  }
12
13
  export interface SimpleChartProps {
13
14
  bgColor?: string;
@@ -18,6 +19,7 @@ export interface SimpleChartProps {
18
19
  yAxisLabel: string;
19
20
  series: number[];
20
21
  withLegend: boolean;
22
+ inverted?: boolean;
21
23
  }
22
24
  export interface ChartConfig {
23
25
  chart: object;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adiba-banking-cloud/backoffice",
3
3
  "author": "TUROG Technologies",
4
- "version": "0.0.97",
4
+ "version": "0.0.98",
5
5
  "description": "An ADIBA component library for backoffice and dashboard applications",
6
6
  "license": "ISC",
7
7
  "main": "build/index.cjs.js",