gifted-charts-core 0.0.7 → 0.0.8

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/index.ts CHANGED
@@ -15,6 +15,8 @@ export {
15
15
  RenderBarsPropsType,
16
16
  trianglePropTypes,
17
17
  animatedBarPropTypes,
18
+ FocusedBarConfig,
19
+ CommonPropsFor2Dand3DbarsType,
18
20
  } from "./src/BarChart/types";
19
21
 
20
22
  /************************************************************************************************************************/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "index.ts",
6
6
  "files": [
@@ -1,4 +1,6 @@
1
1
  import { ViewStyle } from "react-native";
2
+ import { getBarFrontColor, getBarWidth } from "../utils";
3
+ import { CommonPropsFor2Dand3DbarsType } from "./types";
2
4
 
3
5
  export const getPropsForAnimated2DWithGradient = (props) => {
4
6
  const {
@@ -29,8 +31,28 @@ export const getPropsForAnimated2DWithGradient = (props) => {
29
31
  frontColor,
30
32
  showGradient,
31
33
  gradientColor,
34
+ selectedIndex,
35
+ focusBarOnPress,
36
+ focusedBarConfig,
32
37
  } = props;
33
38
 
39
+ const isFocused = focusBarOnPress && selectedIndex === index;
40
+ const localBarBorderRadius = item.barBorderRadius ?? barBorderRadius ?? 0;
41
+ const localBarWidth = getBarWidth(
42
+ isFocused,
43
+ focusedBarConfig,
44
+ item.barWidth,
45
+ barWidth
46
+ );
47
+ const localFrontColor = getBarFrontColor(
48
+ isFocused,
49
+ focusedBarConfig,
50
+ item.frontColor,
51
+ frontColor
52
+ );
53
+ const localGradientColor = item.gradientColor || gradientColor;
54
+ const localOpacity = opacity || 1;
55
+
34
56
  const commonStyleForBar: ViewStyle[] = [
35
57
  {
36
58
  position: "absolute",
@@ -38,7 +60,9 @@ export const getPropsForAnimated2DWithGradient = (props) => {
38
60
  height: "100%",
39
61
  borderWidth: barBorderWidth ?? 0,
40
62
  borderColor: barBorderColor,
41
- borderRadius: item.barBorderRadius ?? barBorderRadius ?? 0,
63
+ borderRadius: isFocused
64
+ ? focusedBarConfig?.borderRadius ?? localBarBorderRadius
65
+ : localBarBorderRadius,
42
66
  borderTopLeftRadius:
43
67
  item.barBorderTopLeftRadius ??
44
68
  barBorderTopLeftRadius ??
@@ -62,10 +86,10 @@ export const getPropsForAnimated2DWithGradient = (props) => {
62
86
  },
63
87
  ];
64
88
 
65
- if (roundedBottom) {
89
+ if (roundedBottom || (isFocused && focusedBarConfig?.roundedBottom)) {
66
90
  commonStyleForBar.push({
67
- borderBottomLeftRadius: (item.barWidth || barWidth || 30) / 2,
68
- borderBottomRightRadius: (item.barWidth || barWidth || 30) / 2,
91
+ borderBottomLeftRadius: localBarWidth / 2,
92
+ borderBottomRightRadius: localBarWidth / 2,
69
93
  });
70
94
  }
71
95
 
@@ -78,32 +102,38 @@ export const getPropsForAnimated2DWithGradient = (props) => {
78
102
  });
79
103
  }
80
104
 
81
- if (roundedTop) {
105
+ if (roundedTop || (isFocused && focusedBarConfig?.roundedTop)) {
82
106
  commonStyleForBar.push({
83
- borderTopLeftRadius: (item.barWidth || barWidth || 30) / 2,
84
- borderTopRightRadius: (item.barWidth || barWidth || 30) / 2,
107
+ borderTopLeftRadius: localBarWidth / 2,
108
+ borderTopRightRadius: localBarWidth / 2,
85
109
  });
86
110
  }
87
111
  const barStyleWithBackground: ViewStyle[] = [
88
112
  ...commonStyleForBar,
89
113
  {
90
- backgroundColor: item.frontColor || props.frontColor || "black",
114
+ backgroundColor: localFrontColor,
91
115
  },
92
116
  ];
93
117
 
94
- const commonPropsFor2Dand3Dbars = {
118
+ const commonPropsFor2Dand3Dbars: CommonPropsFor2Dand3DbarsType = {
95
119
  barBackgroundPattern: item.barBackgroundPattern || barBackgroundPattern,
96
- barInnerComponent: localBarInnerComponent,
120
+ barInnerComponent: isFocused
121
+ ? focusedBarConfig?.barInnerComponent ?? localBarInnerComponent
122
+ : localBarInnerComponent,
97
123
  patternId: item.patternId || patternId,
98
- width: item.barWidth || barWidth || 30,
124
+ width: localBarWidth,
99
125
  barStyle: barStyle,
100
126
  item: item,
101
127
  index: index,
102
128
 
103
- frontColor: item.frontColor || frontColor || "",
129
+ frontColor: localFrontColor,
104
130
  showGradient: item.showGradient || showGradient || false,
105
- gradientColor: item.gradientColor || gradientColor,
106
- opacity: opacity || 1,
131
+ gradientColor: isFocused
132
+ ? focusedBarConfig?.gradientColor ?? localGradientColor
133
+ : localGradientColor,
134
+ opacity: isFocused
135
+ ? focusedBarConfig?.opacity ?? localOpacity
136
+ : localOpacity,
107
137
  height: barHeight,
108
138
  intactTopLabel,
109
139
  showValuesAsTopLabel: !!showValuesAsTopLabel,
@@ -115,5 +145,8 @@ export const getPropsForAnimated2DWithGradient = (props) => {
115
145
  commonStyleForBar,
116
146
  barStyleWithBackground,
117
147
  commonPropsFor2Dand3Dbars,
148
+ isFocused,
149
+ focusedBarConfig,
150
+ localFrontColor,
118
151
  };
119
152
  };
@@ -5,6 +5,8 @@ import {
5
5
  getAxesAndRulesProps,
6
6
  getExtendedContainerHeightWithPadding,
7
7
  getLineConfigForBarChart,
8
+ getMaxValue,
9
+ getNoOfSections,
8
10
  getSecondaryDataWithOffsetIncluded,
9
11
  getXForLineInBar,
10
12
  getYForLineInBar,
@@ -96,7 +98,11 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
96
98
  const lineConfig2 = props.lineConfig2
97
99
  ? getLineConfigForBarChart(props.lineConfig2, initialSpacing)
98
100
  : defaultLineConfig;
99
- const noOfSections = props.noOfSections ?? AxesAndRulesDefaults.noOfSections;
101
+ const noOfSections = getNoOfSections(
102
+ props.noOfSections,
103
+ props.maxValue,
104
+ props.stepValue
105
+ );
100
106
  const containerHeight =
101
107
  heightFromProps ??
102
108
  ((props.stepHeight ?? 0) * noOfSections ||
@@ -179,7 +185,12 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
179
185
  props.showFractionalValues
180
186
  );
181
187
 
182
- const maxValue = props.maxValue ?? maxAndMin.maxItem;
188
+ const maxValue = getMaxValue(
189
+ props.maxValue,
190
+ props.stepValue,
191
+ noOfSections,
192
+ maxAndMin.maxItem
193
+ );
183
194
  const secondaryMaxValue = lineConfig.isSecondary
184
195
  ? secondaryMaxAndMin.maxItem
185
196
  : maxValue;
@@ -591,6 +602,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
591
602
  patternId: props.patternId,
592
603
  onPress: props.onPress,
593
604
  onLongPress: props.onLongPress,
605
+ focusBarOnPress: props.focusBarOnPress,
606
+ focusedBarConfig: props.focusedBarConfig,
594
607
  xAxisTextNumberOfLines: xAxisTextNumberOfLines,
595
608
  xAxisLabelsHeight: props.xAxisLabelsHeight,
596
609
  xAxisLabelsVerticalShift,
@@ -298,7 +298,22 @@ export type BarChartPropsType = {
298
298
  onEndReached?: () => void;
299
299
  onStartReached?: () => void;
300
300
  endReachedOffset?: number;
301
+
302
+ focusBarOnPress?: boolean;
303
+ focusedBarConfig?: FocusedBarConfig;
301
304
  };
305
+
306
+ export type FocusedBarConfig = {
307
+ color?: ColorValue;
308
+ gradientColor?: ColorValue;
309
+ width?: number;
310
+ borderRadius?: number;
311
+ roundedTop?: boolean;
312
+ roundedBottom?: boolean;
313
+ opacity?: number;
314
+ barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
315
+ }
316
+
302
317
  type lineConfigType = {
303
318
  initialSpacing?: number;
304
319
  spacing?: number;
@@ -555,6 +570,29 @@ export type animatedBarPropTypes = {
555
570
  barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
556
571
  patternId?: String;
557
572
  barStyle?: object;
558
- item: any;
573
+ item: barDataItem;
559
574
  index: number;
575
+ selectedIndex: number;
576
+ focusBarOnPress?: boolean;
577
+ focusedBarConfig?: FocusedBarConfig;
560
578
  };
579
+
580
+ export type CommonPropsFor2Dand3DbarsType = {
581
+ barBackgroundPattern: Function;
582
+ barInnerComponent: (item?: barDataItem, index?: number) => ReactNode;
583
+ patternId: String;
584
+ width: number;
585
+ barStyle: object;
586
+ item: barDataItem;
587
+ index: number;
588
+
589
+ frontColor: ColorValue;
590
+ showGradient: boolean;
591
+ gradientColor: ColorValue;
592
+ opacity: number;
593
+ height: number;
594
+ intactTopLabel: boolean;
595
+ showValuesAsTopLabel: boolean;
596
+ topLabelContainerStyle: any;
597
+ topLabelTextStyle: any;
598
+ }
@@ -17,6 +17,8 @@ import {
17
17
  getAxesAndRulesProps,
18
18
  getCurvePathWithSegments,
19
19
  getExtendedContainerHeightWithPadding,
20
+ getMaxValue,
21
+ getNoOfSections,
20
22
  getPathWithHighlight,
21
23
  getSecondaryDataWithOffsetIncluded,
22
24
  getSegmentString,
@@ -95,7 +97,11 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
95
97
 
96
98
  const [selectedIndex, setSelectedIndex] = useState(-1);
97
99
 
98
- const noOfSections = props.noOfSections || 10;
100
+ const noOfSections = getNoOfSections(
101
+ props.noOfSections,
102
+ props.maxValue,
103
+ props.stepValue
104
+ );
99
105
  const containerHeight =
100
106
  props.height ??
101
107
  ((props.stepHeight ?? 0) * noOfSections ||
@@ -412,7 +418,13 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
412
418
  props.showFractionalValues
413
419
  );
414
420
 
415
- const maxValue = props.maxValue || maxItem;
421
+ const maxValue = getMaxValue(
422
+ props.maxValue,
423
+ props.stepValue,
424
+ noOfSections,
425
+ maxItem
426
+ );
427
+
416
428
  const mostNegativeValue = props.mostNegativeValue || minItem;
417
429
 
418
430
  const overflowTop = props.overflowTop ?? 0;
@@ -1,16 +1,42 @@
1
1
  import { useState } from "react";
2
2
  import { animatedBarPropTypes } from "../../BarChart/types";
3
3
  import { BarDefaults } from "../../utils/constants";
4
+ import { getBarSideColor, getBarTopColor } from "../../utils";
4
5
 
5
6
  export const useAnimatedThreeDBar = (props: animatedBarPropTypes) => {
7
+ const { focusBarOnPress, index, selectedIndex, focusedBarConfig, item } =
8
+ props;
9
+ const isFocused = focusBarOnPress && index === selectedIndex;
10
+ const localFrontColor = props.frontColor || BarDefaults.threeDBarFrontColor;
11
+ const localGradientColor =
12
+ props.gradientColor || BarDefaults.threeDBarGradientColor;
13
+ const localSideColor = props.sideColor || BarDefaults.threeDBarSideColor;
14
+ const localTopColor = props.topColor || BarDefaults.threeDBarTopColor;
15
+ const localOpacity = props.opacity || 1;
6
16
  const {
7
17
  isAnimated,
8
18
  showGradient = props.showGradient || false,
9
- gradientColor = props.gradientColor || BarDefaults.threeDBarGradientColor,
10
- frontColor = props.frontColor || BarDefaults.threeDBarFrontColor,
11
- sideColor = props.sideColor || BarDefaults.threeDBarSideColor,
12
- topColor = props.topColor || BarDefaults.threeDBarTopColor,
13
- opacity = props.opacity || 1,
19
+ gradientColor = isFocused
20
+ ? focusedBarConfig?.gradientColor ?? localGradientColor
21
+ : localGradientColor,
22
+ frontColor = isFocused
23
+ ? focusedBarConfig?.color ?? localFrontColor
24
+ : localFrontColor,
25
+ sideColor = getBarSideColor(
26
+ isFocused,
27
+ focusedBarConfig,
28
+ item.sideColor,
29
+ localSideColor
30
+ ),
31
+ topColor = getBarTopColor(
32
+ isFocused,
33
+ focusBarOnPress,
34
+ item.topColor,
35
+ localTopColor
36
+ ),
37
+ opacity = isFocused
38
+ ? focusedBarConfig?.opacity ?? localOpacity
39
+ : localOpacity,
14
40
  } = props;
15
41
 
16
42
  const [initialRender, setInitialRender] = useState(isAnimated);
@@ -18,9 +44,15 @@ export const useAnimatedThreeDBar = (props: animatedBarPropTypes) => {
18
44
  return {
19
45
  showGradient,
20
46
  gradientColor,
21
- frontColor: frontColor?.toString()?.trim?.()?.length ? frontColor : BarDefaults.threeDBarFrontColor,
22
- sideColor: sideColor?.toString()?.trim?.()?.length ? sideColor : BarDefaults.threeDBarSideColor,
23
- topColor: topColor?.toString()?.trim?.()?.length ? topColor : BarDefaults.threeDBarTopColor,
47
+ frontColor: frontColor?.toString()?.trim?.()?.length
48
+ ? frontColor
49
+ : BarDefaults.threeDBarFrontColor,
50
+ sideColor: sideColor?.toString()?.trim?.()?.length
51
+ ? sideColor
52
+ : BarDefaults.threeDBarSideColor,
53
+ topColor: topColor?.toString()?.trim?.()?.length
54
+ ? topColor
55
+ : BarDefaults.threeDBarTopColor,
24
56
  opacity,
25
57
  initialRender,
26
58
  setInitialRender,
@@ -151,6 +151,9 @@ export const BarDefaults = {
151
151
  threeDBarSideColor: "#887A24",
152
152
  threeDBarTopColor: "#D9E676",
153
153
  endReachedOffset: defaultEndReachedOffset,
154
+ focusedBarFrontColor: 'lightgreen',
155
+ focusedBarSideColor: '#776913',
156
+ focusedBarTopColor: '#C8D565',
154
157
  };
155
158
 
156
159
  export const defaultLineConfig: defaultLineConfigType = {
@@ -1,15 +1,22 @@
1
1
  import {
2
+ AxesAndRulesDefaults,
3
+ BarDefaults,
2
4
  RANGE_ENTER,
3
5
  RANGE_EXIT,
4
6
  STOP,
5
7
  defaultLineConfig,
6
8
  loc,
7
- } from './constants';
8
- import {arrowConfigType, CurveType, LineProperties, LineSegment} from './types';
9
+ } from "./constants";
10
+ import {
11
+ arrowConfigType,
12
+ CurveType,
13
+ LineProperties,
14
+ LineSegment,
15
+ } from "./types";
9
16
 
10
- const versionString = require('react-native/package.json').version;
17
+ const versionString = require("react-native/package.json").version;
11
18
 
12
- const versionAr = versionString?.split?.('.') ?? '';
19
+ const versionAr = versionString?.split?.(".") ?? "";
13
20
  const msb = Number(versionAr[0]);
14
21
  const mid = Number(versionAr[1]);
15
22
  const lsb = Number(versionAr[2]);
@@ -22,11 +29,11 @@ export const rnVersion =
22
29
  export const getCumulativeWidth = (
23
30
  data: any,
24
31
  index: number,
25
- spacing: number,
32
+ spacing: number
26
33
  ) => {
27
34
  let cumWidth = 0;
28
35
  for (let i = 0; i < index; i++) {
29
- let {barWidth} = data[i];
36
+ let { barWidth } = data[i];
30
37
  barWidth = barWidth || 30;
31
38
  cumWidth += barWidth + (spacing ?? 20);
32
39
  }
@@ -37,8 +44,8 @@ export const getLighterColor = (color: String) => {
37
44
  let r,
38
45
  g,
39
46
  b,
40
- lighter = '#';
41
- if (color.startsWith('#')) {
47
+ lighter = "#";
48
+ if (color.startsWith("#")) {
42
49
  if (color.length < 7) {
43
50
  r = parseInt(color[1], 16);
44
51
  g = parseInt(color[2], 16);
@@ -77,8 +84,8 @@ export const getLighterColor = (color: String) => {
77
84
  return lighter;
78
85
  };
79
86
 
80
- export const svgQuadraticCurvePath = points => {
81
- let path = 'M' + points[0][0] + ',' + points[0][1];
87
+ export const svgQuadraticCurvePath = (points) => {
88
+ let path = "M" + points[0][0] + "," + points[0][1];
82
89
 
83
90
  for (let i = 0; i < points.length - 1; i++) {
84
91
  const xMid = (points[i][0] + points[i + 1][0]) / 2;
@@ -86,21 +93,21 @@ export const svgQuadraticCurvePath = points => {
86
93
  const cpX1 = (xMid + points[i][0]) / 2;
87
94
  const cpX2 = (xMid + points[i + 1][0]) / 2;
88
95
  path +=
89
- 'Q ' +
96
+ "Q " +
90
97
  cpX1 +
91
- ', ' +
98
+ ", " +
92
99
  points[i][1] +
93
- ', ' +
100
+ ", " +
94
101
  xMid +
95
- ', ' +
102
+ ", " +
96
103
  yMid +
97
- (' Q ' +
104
+ (" Q " +
98
105
  cpX2 +
99
- ', ' +
106
+ ", " +
100
107
  points[i + 1][1] +
101
- ', ' +
108
+ ", " +
102
109
  points[i + 1][0] +
103
- ', ' +
110
+ ", " +
104
111
  points[i + 1][1]);
105
112
  }
106
113
 
@@ -110,9 +117,9 @@ export const svgQuadraticCurvePath = points => {
110
117
  export const svgPath = (
111
118
  points: Array<Array<number>>,
112
119
  curveType: CurveType,
113
- curvature: number,
120
+ curvature: number
114
121
  ) => {
115
- if (!points?.length) return '';
122
+ if (!points?.length) return "";
116
123
  if (curveType === CurveType.QUADRATIC) {
117
124
  return svgQuadraticCurvePath(points);
118
125
  }
@@ -124,7 +131,7 @@ export const svgPath = (
124
131
  `M${point[0]},${point[1]}`
125
132
  : // else
126
133
  `${acc} ${bezierCommand(point, i, a, curvature)}`,
127
- '',
134
+ ""
128
135
  );
129
136
  return d;
130
137
  };
@@ -143,7 +150,7 @@ const controlPoint = (
143
150
  current: Array<number>,
144
151
  previous: Array<number>,
145
152
  next: Array<number>,
146
- reverse?: any,
153
+ reverse?: any
147
154
  ) => {
148
155
  // When 'current' is the first or last point of the array
149
156
  // 'previous' or 'next' don't exist.
@@ -167,7 +174,7 @@ export const bezierCommand = (
167
174
  point: Array<number>,
168
175
  i: number,
169
176
  a: Array<Array<number>>,
170
- curvature: number,
177
+ curvature: number
171
178
  ) => {
172
179
  // start control point
173
180
  const [cpsX, cpsY] = controlPoint(curvature, a[i - 1], a[i - 2], point);
@@ -180,40 +187,40 @@ export const getSegmentString = (
180
187
  lineSegment,
181
188
  index,
182
189
  startDelimeter,
183
- endDelimeter,
190
+ endDelimeter
184
191
  ) => {
185
- const segment = lineSegment?.find(segment => segment.startIndex === index);
186
- return segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '';
192
+ const segment = lineSegment?.find((segment) => segment.startIndex === index);
193
+ return segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : "";
187
194
  };
188
195
 
189
196
  export const getCurvePathWithSegments = (
190
197
  path: string,
191
198
  lineSegment: LineSegment[] | undefined,
192
199
  startDelimeter,
193
- endDelimeter,
200
+ endDelimeter
194
201
  ) => {
195
202
  if (!lineSegment?.length) return path;
196
- let newPath = '';
197
- const pathArray = path.split('C');
203
+ let newPath = "";
204
+ const pathArray = path.split("C");
198
205
  for (let i = 0; i < pathArray.length; i++) {
199
- const segment = lineSegment?.find(segment => segment.startIndex === i);
206
+ const segment = lineSegment?.find((segment) => segment.startIndex === i);
200
207
  newPath +=
201
- (pathArray[i].startsWith('M') ? '' : 'C') +
208
+ (pathArray[i].startsWith("M") ? "" : "C") +
202
209
  pathArray[i] +
203
- (segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '');
210
+ (segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : "");
204
211
  }
205
212
  return newPath;
206
213
  };
207
214
 
208
215
  export const getPreviousSegmentsLastPoint = (isCurved, previousSegment) => {
209
216
  const prevSegmentLastPoint = isCurved
210
- ? previousSegment.substring(previousSegment.trim().lastIndexOf(' '))
217
+ ? previousSegment.substring(previousSegment.trim().lastIndexOf(" "))
211
218
  : previousSegment
212
- .substring(previousSegment.lastIndexOf('L'))
213
- .replace('L', 'M');
219
+ .substring(previousSegment.lastIndexOf("L"))
220
+ .replace("L", "M");
214
221
 
215
222
  return (
216
- (prevSegmentLastPoint.trim()[0] === 'M' ? '' : 'M') + prevSegmentLastPoint
223
+ (prevSegmentLastPoint.trim()[0] === "M" ? "" : "M") + prevSegmentLastPoint
217
224
  );
218
225
  };
219
226
 
@@ -224,10 +231,10 @@ export const getPathWithHighlight = (
224
231
  startIndex,
225
232
  endIndex,
226
233
  getX,
227
- getY,
234
+ getY
228
235
  ) => {
229
- let path = '';
230
- const {from, to} = highlightedRange;
236
+ let path = "";
237
+ const { from, to } = highlightedRange;
231
238
  const currentPointRegion =
232
239
  data[i].value < from ? loc.DOWN : data[i].value > to ? loc.UP : loc.IN;
233
240
 
@@ -236,8 +243,8 @@ export const getPathWithHighlight = (
236
243
  data[i + 1].value < from
237
244
  ? loc.DOWN
238
245
  : data[i + 1].value > to
239
- ? loc.UP
240
- : loc.IN;
246
+ ? loc.UP
247
+ : loc.IN;
241
248
  if (
242
249
  currentPointRegion !== nextPointRegion ||
243
250
  (i === startIndex && currentPointRegion === loc.IN)
@@ -256,11 +263,11 @@ export const getPathWithHighlight = (
256
263
  x = x1;
257
264
 
258
265
  path +=
259
- 'L' +
266
+ "L" +
260
267
  x +
261
- ' ' +
268
+ " " +
262
269
  y +
263
- ' ' +
270
+ " " +
264
271
  RANGE_ENTER +
265
272
  JSON.stringify(highlightedRange) +
266
273
  STOP;
@@ -269,12 +276,12 @@ export const getPathWithHighlight = (
269
276
  y = getY(to);
270
277
  x = (y - y1) / m + x1;
271
278
 
272
- path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
279
+ path += "L" + x + " " + y + " " + RANGE_EXIT;
273
280
  } else if (nextPointRegion === loc.DOWN) {
274
281
  y = getY(from);
275
282
  x = (y - y1) / m + x1;
276
283
 
277
- path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
284
+ path += "L" + x + " " + y + " " + RANGE_EXIT;
278
285
  }
279
286
  } else if (currentPointRegion !== nextPointRegion) {
280
287
  if (currentPointRegion === loc.DOWN && nextPointRegion === loc.UP) {
@@ -283,18 +290,18 @@ export const getPathWithHighlight = (
283
290
  x = (y - y1) / m + x1;
284
291
 
285
292
  path +=
286
- 'L' +
293
+ "L" +
287
294
  x +
288
- ' ' +
295
+ " " +
289
296
  y +
290
- ' ' +
297
+ " " +
291
298
  RANGE_ENTER +
292
299
  JSON.stringify(highlightedRange) +
293
300
  STOP;
294
301
  y = getY(to);
295
302
  x = (y - y1) / m + x1;
296
303
 
297
- path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
304
+ path += "L" + x + " " + y + " " + RANGE_EXIT;
298
305
  } else if (
299
306
  currentPointRegion === loc.UP &&
300
307
  nextPointRegion === loc.DOWN
@@ -304,18 +311,18 @@ export const getPathWithHighlight = (
304
311
  x = (y - y1) / m + x1;
305
312
 
306
313
  path +=
307
- 'L' +
314
+ "L" +
308
315
  x +
309
- ' ' +
316
+ " " +
310
317
  y +
311
- ' ' +
318
+ " " +
312
319
  RANGE_ENTER +
313
320
  JSON.stringify(highlightedRange) +
314
321
  STOP;
315
322
  y = getY(from);
316
323
  x = (y - y1) / m + x1;
317
324
 
318
- path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
325
+ path += "L" + x + " " + y + " " + RANGE_EXIT;
319
326
  } else {
320
327
  if (
321
328
  (currentPointRegion === loc.UP && nextPointRegion === loc.IN) ||
@@ -336,7 +343,7 @@ export const getPathWithHighlight = (
336
343
  ? RANGE_ENTER + JSON.stringify(highlightedRange) + STOP
337
344
  : RANGE_EXIT;
338
345
 
339
- path += 'L' + x + ' ' + y + ' ' + prefix;
346
+ path += "L" + x + " " + y + " " + prefix;
340
347
  }
341
348
  }
342
349
  }
@@ -357,7 +364,7 @@ export const getRegionPathObjects = (
357
364
  isCurved,
358
365
  startDelimeter,
359
366
  stop,
360
- endDelimeter,
367
+ endDelimeter
361
368
  ) => {
362
369
  const ar: [any] = [{}];
363
370
  let tempStr = points;
@@ -383,7 +390,7 @@ export const getRegionPathObjects = (
383
390
 
384
391
  const segmentConfigString = tempStr.substring(
385
392
  startDelimeterIndex + startDelimeter.length,
386
- stopIndex,
393
+ stopIndex
387
394
  );
388
395
 
389
396
  const segmentConfig = JSON.parse(segmentConfigString);
@@ -393,7 +400,7 @@ export const getRegionPathObjects = (
393
400
  const previousSegment = ar[ar.length - 1].d;
394
401
  const moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(
395
402
  isCurved,
396
- previousSegment,
403
+ previousSegment
397
404
  );
398
405
 
399
406
  /********************** segment line *****************/
@@ -418,15 +425,15 @@ export const getRegionPathObjects = (
418
425
 
419
426
  if (
420
427
  nextDelimiterIndex !== -1 &&
421
- stringUptoNextSegment.indexOf(isCurved ? 'C' : 'L') !== -1
428
+ stringUptoNextSegment.indexOf(isCurved ? "C" : "L") !== -1
422
429
  ) {
423
430
  const previousSegment = ar[ar.length - 1].d;
424
431
  const moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(
425
432
  isCurved,
426
- previousSegment,
433
+ previousSegment
427
434
  );
428
435
  const lineSvgProps: LineProperties = {
429
- d: moveToLastPointOfPreviousSegment + ' ' + stringUptoNextSegment,
436
+ d: moveToLastPointOfPreviousSegment + " " + stringUptoNextSegment,
430
437
  color,
431
438
  strokeWidth: currentLineThickness || thickness,
432
439
  };
@@ -443,7 +450,7 @@ export const getRegionPathObjects = (
443
450
  const previousSegment = ar[ar.length - 1].d;
444
451
  const moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(
445
452
  isCurved,
446
- previousSegment,
453
+ previousSegment
447
454
  );
448
455
  const lineSvgProps: LineProperties = {
449
456
  d: moveToLastPointOfPreviousSegment + tempStr,
@@ -468,7 +475,7 @@ export const getSegmentedPathObjects = (
468
475
  strokeDashArray,
469
476
  isCurved,
470
477
  startDelimeter,
471
- endDelimeter,
478
+ endDelimeter
472
479
  ) => {
473
480
  const ar: [any] = [{}];
474
481
  let tempStr = points;
@@ -493,21 +500,21 @@ export const getSegmentedPathObjects = (
493
500
 
494
501
  const segmentConfigString = tempStr.substring(
495
502
  startDelimeterIndex + startDelimeter.length,
496
- endDelimeterIndex,
503
+ endDelimeterIndex
497
504
  );
498
505
 
499
506
  const segmentConfig = JSON.parse(segmentConfigString);
500
507
 
501
- const {startIndex, endIndex} = segmentConfig;
508
+ const { startIndex, endIndex } = segmentConfig;
502
509
  const segmentLength = endIndex - startIndex;
503
510
  let segment = tempStr.substring(endDelimeterIndex + endDelimeter.length);
504
511
  let c = 0,
505
512
  s = 0,
506
513
  i;
507
514
  for (i = 0; i < segment.length; i++) {
508
- if (segment[i] === (isCurved ? 'C' : 'L')) c++;
515
+ if (segment[i] === (isCurved ? "C" : "L")) c++;
509
516
  if (c === segmentLength) {
510
- if (segment[i] === ' ') s++;
517
+ if (segment[i] === " ") s++;
511
518
  if (s === (isCurved ? 3 : 2)) break;
512
519
  }
513
520
  }
@@ -516,7 +523,7 @@ export const getSegmentedPathObjects = (
516
523
  const previousSegment = ar[ar.length - 1].d;
517
524
  const moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(
518
525
  isCurved,
519
- previousSegment,
526
+ previousSegment
520
527
  );
521
528
 
522
529
  /********************** segment line *****************/
@@ -541,15 +548,15 @@ export const getSegmentedPathObjects = (
541
548
 
542
549
  if (
543
550
  nextDelimiterIndex !== -1 &&
544
- stringUptoNextSegment.indexOf(isCurved ? 'C' : 'L') !== -1
551
+ stringUptoNextSegment.indexOf(isCurved ? "C" : "L") !== -1
545
552
  ) {
546
553
  const previousSegment = ar[ar.length - 1].d;
547
554
  const moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(
548
555
  isCurved,
549
- previousSegment,
556
+ previousSegment
550
557
  );
551
558
  const lineSvgProps: LineProperties = {
552
- d: moveToLastPointOfPreviousSegment + ' ' + stringUptoNextSegment,
559
+ d: moveToLastPointOfPreviousSegment + " " + stringUptoNextSegment,
553
560
  color,
554
561
  strokeWidth: currentLineThickness || thickness,
555
562
  };
@@ -566,7 +573,7 @@ export const getSegmentedPathObjects = (
566
573
  const previousSegment = ar[ar.length - 1].d;
567
574
  const moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(
568
575
  isCurved,
569
- previousSegment,
576
+ previousSegment
570
577
  );
571
578
  const lineSvgProps: LineProperties = {
572
579
  d: moveToLastPointOfPreviousSegment + tempStr,
@@ -590,7 +597,7 @@ export const getArrowPoints = (
590
597
  y1: number,
591
598
  arrowLength?: number,
592
599
  arrowWidth?: number,
593
- showArrowBase?: boolean,
600
+ showArrowBase?: boolean
594
601
  ) => {
595
602
  let dataLineSlope = (arrowTipY - y1) / (arrowTipX - x1);
596
603
  let d = arrowLength ?? 0;
@@ -620,10 +627,10 @@ export const getArrowPoints = (
620
627
  interSectionY + arrowBaseSlope * (interSectionX - arrowBasex1);
621
628
  }
622
629
  let arrowPoints = ` M${interSectionX} ${interSectionY}`;
623
- arrowPoints += ` ${showArrowBase ? 'L' : 'M'}${arrowBasex1} ${arrowBaseY1}`;
630
+ arrowPoints += ` ${showArrowBase ? "L" : "M"}${arrowBasex1} ${arrowBaseY1}`;
624
631
  arrowPoints += ` L${arrowTipX} ${arrowTipY}`;
625
632
  arrowPoints += ` M${interSectionX} ${interSectionY}`;
626
- arrowPoints += ` ${showArrowBase ? 'L' : 'M'}${arrowBaseX2} ${arrowBaseY2}`;
633
+ arrowPoints += ` ${showArrowBase ? "L" : "M"}${arrowBaseX2} ${arrowBaseY2}`;
627
634
  arrowPoints += ` L${arrowTipX} ${arrowTipY}`;
628
635
 
629
636
  return arrowPoints;
@@ -632,7 +639,7 @@ export const getArrowPoints = (
632
639
  export const getAxesAndRulesProps = (
633
640
  props: any,
634
641
  stepValue: number,
635
- maxValue?: number,
642
+ maxValue?: number
636
643
  ) => {
637
644
  const axesAndRulesProps = {
638
645
  yAxisSide: props.yAxisSide,
@@ -700,7 +707,7 @@ export const getAxesAndRulesProps = (
700
707
  formatYLabel: props.formatYLabel,
701
708
  };
702
709
  if (props.secondaryYAxis && maxValue !== undefined) {
703
- axesAndRulesProps.secondaryYAxis = {...props.secondaryYAxis, maxValue};
710
+ axesAndRulesProps.secondaryYAxis = { ...props.secondaryYAxis, maxValue };
704
711
  }
705
712
 
706
713
  return axesAndRulesProps;
@@ -708,15 +715,15 @@ export const getAxesAndRulesProps = (
708
715
 
709
716
  export const getExtendedContainerHeightWithPadding = (
710
717
  containerHeight: number,
711
- overflowTop?: number,
718
+ overflowTop?: number
712
719
  ) => containerHeight + (overflowTop ?? 0) + 10;
713
720
 
714
721
  export const getSecondaryDataWithOffsetIncluded = (
715
722
  secondaryData?: any,
716
- secondaryYAxis?: any,
723
+ secondaryYAxis?: any
717
724
  ) => {
718
725
  if (secondaryData && secondaryYAxis?.yAxisOffset) {
719
- return secondaryData?.map(item => {
726
+ return secondaryData?.map((item) => {
720
727
  item.value = item.value - (secondaryYAxis?.yAxisOffset ?? 0);
721
728
  return item;
722
729
  });
@@ -728,7 +735,7 @@ export const getArrowProperty = (
728
735
  property: string,
729
736
  count: number,
730
737
  props: any,
731
- defaultArrowConfig: arrowConfigType,
738
+ defaultArrowConfig: arrowConfigType
732
739
  ) => {
733
740
  return (
734
741
  props[`arrowConfig${count}`]?.[`${property}`] ??
@@ -739,160 +746,160 @@ export const getArrowProperty = (
739
746
 
740
747
  export const getAllArrowProperties = (
741
748
  props: any,
742
- defaultArrowConfig: arrowConfigType,
749
+ defaultArrowConfig: arrowConfigType
743
750
  ) => {
744
- const arrowLength1 = getArrowProperty('length', 1, props, defaultArrowConfig);
745
- const arrowWidth1 = getArrowProperty('width', 1, props, defaultArrowConfig);
751
+ const arrowLength1 = getArrowProperty("length", 1, props, defaultArrowConfig);
752
+ const arrowWidth1 = getArrowProperty("width", 1, props, defaultArrowConfig);
746
753
  const arrowStrokeWidth1 = getArrowProperty(
747
- 'strokeWidth',
754
+ "strokeWidth",
748
755
  1,
749
756
  props,
750
- defaultArrowConfig,
757
+ defaultArrowConfig
751
758
  );
752
759
  const arrowStrokeColor1 = getArrowProperty(
753
- 'strokeColor',
760
+ "strokeColor",
754
761
  1,
755
762
  props,
756
- defaultArrowConfig,
763
+ defaultArrowConfig
757
764
  );
758
765
  const arrowFillColor1 = getArrowProperty(
759
- 'fillColor',
766
+ "fillColor",
760
767
  1,
761
768
  props,
762
- defaultArrowConfig,
769
+ defaultArrowConfig
763
770
  );
764
771
  const showArrowBase1 = getArrowProperty(
765
- 'showArrowBase',
772
+ "showArrowBase",
766
773
  1,
767
774
  props,
768
- defaultArrowConfig,
775
+ defaultArrowConfig
769
776
  );
770
777
 
771
- const arrowLength2 = getArrowProperty('length', 2, props, defaultArrowConfig);
772
- const arrowWidth2 = getArrowProperty('width', 2, props, defaultArrowConfig);
778
+ const arrowLength2 = getArrowProperty("length", 2, props, defaultArrowConfig);
779
+ const arrowWidth2 = getArrowProperty("width", 2, props, defaultArrowConfig);
773
780
  const arrowStrokeWidth2 = getArrowProperty(
774
- 'strokeWidth',
781
+ "strokeWidth",
775
782
  2,
776
783
  props,
777
- defaultArrowConfig,
784
+ defaultArrowConfig
778
785
  );
779
786
  const arrowStrokeColor2 = getArrowProperty(
780
- 'strokeColor',
787
+ "strokeColor",
781
788
  2,
782
789
  props,
783
- defaultArrowConfig,
790
+ defaultArrowConfig
784
791
  );
785
792
  const arrowFillColor2 = getArrowProperty(
786
- 'fillColor',
793
+ "fillColor",
787
794
  2,
788
795
  props,
789
- defaultArrowConfig,
796
+ defaultArrowConfig
790
797
  );
791
798
  const showArrowBase2 = getArrowProperty(
792
- 'showArrowBase',
799
+ "showArrowBase",
793
800
  2,
794
801
  props,
795
- defaultArrowConfig,
802
+ defaultArrowConfig
796
803
  );
797
804
 
798
- const arrowLength3 = getArrowProperty('length', 3, props, defaultArrowConfig);
799
- const arrowWidth3 = getArrowProperty('width', 3, props, defaultArrowConfig);
805
+ const arrowLength3 = getArrowProperty("length", 3, props, defaultArrowConfig);
806
+ const arrowWidth3 = getArrowProperty("width", 3, props, defaultArrowConfig);
800
807
  const arrowStrokeWidth3 = getArrowProperty(
801
- 'strokeWidth',
808
+ "strokeWidth",
802
809
  3,
803
810
  props,
804
- defaultArrowConfig,
811
+ defaultArrowConfig
805
812
  );
806
813
  const arrowStrokeColor3 = getArrowProperty(
807
- 'strokeColor',
814
+ "strokeColor",
808
815
  3,
809
816
  props,
810
- defaultArrowConfig,
817
+ defaultArrowConfig
811
818
  );
812
819
  const arrowFillColor3 = getArrowProperty(
813
- 'fillColor',
820
+ "fillColor",
814
821
  3,
815
822
  props,
816
- defaultArrowConfig,
823
+ defaultArrowConfig
817
824
  );
818
825
  const showArrowBase3 = getArrowProperty(
819
- 'showArrowBase',
826
+ "showArrowBase",
820
827
  3,
821
828
  props,
822
- defaultArrowConfig,
829
+ defaultArrowConfig
823
830
  );
824
831
 
825
- const arrowLength4 = getArrowProperty('length', 4, props, defaultArrowConfig);
826
- const arrowWidth4 = getArrowProperty('width', 4, props, defaultArrowConfig);
832
+ const arrowLength4 = getArrowProperty("length", 4, props, defaultArrowConfig);
833
+ const arrowWidth4 = getArrowProperty("width", 4, props, defaultArrowConfig);
827
834
  const arrowStrokeWidth4 = getArrowProperty(
828
- 'strokeWidth',
835
+ "strokeWidth",
829
836
  4,
830
837
  props,
831
- defaultArrowConfig,
838
+ defaultArrowConfig
832
839
  );
833
840
  const arrowStrokeColor4 = getArrowProperty(
834
- 'strokeColor',
841
+ "strokeColor",
835
842
  4,
836
843
  props,
837
- defaultArrowConfig,
844
+ defaultArrowConfig
838
845
  );
839
846
  const arrowFillColor4 = getArrowProperty(
840
- 'fillColor',
847
+ "fillColor",
841
848
  4,
842
849
  props,
843
- defaultArrowConfig,
850
+ defaultArrowConfig
844
851
  );
845
852
  const showArrowBase4 = getArrowProperty(
846
- 'showArrowBase',
853
+ "showArrowBase",
847
854
  4,
848
855
  props,
849
- defaultArrowConfig,
856
+ defaultArrowConfig
850
857
  );
851
858
 
852
- const arrowLength5 = getArrowProperty('length', 5, props, defaultArrowConfig);
853
- const arrowWidth5 = getArrowProperty('width', 5, props, defaultArrowConfig);
859
+ const arrowLength5 = getArrowProperty("length", 5, props, defaultArrowConfig);
860
+ const arrowWidth5 = getArrowProperty("width", 5, props, defaultArrowConfig);
854
861
  const arrowStrokeWidth5 = getArrowProperty(
855
- 'strokeWidth',
862
+ "strokeWidth",
856
863
  5,
857
864
  props,
858
- defaultArrowConfig,
865
+ defaultArrowConfig
859
866
  );
860
867
  const arrowStrokeColor5 = getArrowProperty(
861
- 'strokeColor',
868
+ "strokeColor",
862
869
  5,
863
870
  props,
864
- defaultArrowConfig,
871
+ defaultArrowConfig
865
872
  );
866
873
  const arrowFillColor5 = getArrowProperty(
867
- 'fillColor',
874
+ "fillColor",
868
875
  5,
869
876
  props,
870
- defaultArrowConfig,
877
+ defaultArrowConfig
871
878
  );
872
879
  const showArrowBase5 = getArrowProperty(
873
- 'showArrowBase',
880
+ "showArrowBase",
874
881
  5,
875
882
  props,
876
- defaultArrowConfig,
883
+ defaultArrowConfig
877
884
  );
878
885
 
879
886
  const arrowLengthsFromSet = props.dataSet?.map(
880
- item => item?.arrowConfig?.length ?? arrowLength1,
887
+ (item) => item?.arrowConfig?.length ?? arrowLength1
881
888
  );
882
889
  const arrowWidthsFromSet = props.dataSet?.map(
883
- item => item?.arrowConfig?.arrowWidth ?? arrowWidth1,
890
+ (item) => item?.arrowConfig?.arrowWidth ?? arrowWidth1
884
891
  );
885
892
  const arrowStrokeWidthsFromSet = props.dataSet?.map(
886
- item => item?.arrowConfig?.arrowStrokeWidth ?? arrowStrokeWidth1,
893
+ (item) => item?.arrowConfig?.arrowStrokeWidth ?? arrowStrokeWidth1
887
894
  );
888
895
  const arrowStrokeColorsFromSet = props.dataSet?.map(
889
- item => item?.arrowConfig?.arrowStrokeColor ?? arrowStrokeColor1,
896
+ (item) => item?.arrowConfig?.arrowStrokeColor ?? arrowStrokeColor1
890
897
  );
891
898
  const arrowFillColorsFromSet = props.dataSet?.map(
892
- item => item?.arrowConfig?.arrowFillColor ?? arrowFillColor1,
899
+ (item) => item?.arrowConfig?.arrowFillColor ?? arrowFillColor1
893
900
  );
894
901
  const showArrowBasesFromSet = props.dataSet?.map(
895
- item => item?.arrowConfig?.showArrowBase ?? showArrowBase1,
902
+ (item) => item?.arrowConfig?.showArrowBase ?? showArrowBase1
896
903
  );
897
904
 
898
905
  return {
@@ -944,7 +951,7 @@ export const maxAndMinUtil = (
944
951
  maxItem: number,
945
952
  minItem: number,
946
953
  roundToDigits?: number,
947
- showFractionalValues?: boolean,
954
+ showFractionalValues?: boolean
948
955
  ): MaxAndMin => {
949
956
  if (showFractionalValues || roundToDigits) {
950
957
  maxItem *= 10 * (roundToDigits || 1);
@@ -965,16 +972,16 @@ export const maxAndMinUtil = (
965
972
  }
966
973
  }
967
974
 
968
- return {maxItem, minItem};
975
+ return { maxItem, minItem };
969
976
  };
970
977
 
971
978
  export const computeMaxAndMinItems = (
972
979
  data: any,
973
980
  roundToDigits?: number,
974
- showFractionalValues?: boolean,
981
+ showFractionalValues?: boolean
975
982
  ): MaxAndMin => {
976
983
  if (!data?.length) {
977
- return {maxItem: 0, minItem: 0};
984
+ return { maxItem: 0, minItem: 0 };
978
985
  }
979
986
  let maxItem = 0,
980
987
  minItem = 0;
@@ -1000,9 +1007,9 @@ export const getLabelTextUtil = (
1000
1007
  yAxisLabelPrefix?: string,
1001
1008
  yAxisLabelSuffix?: string,
1002
1009
  roundToDigits?: number,
1003
- formatYLabel?: (label: string) => string,
1010
+ formatYLabel?: (label: string) => string
1004
1011
  ) => {
1005
- let label = '';
1012
+ let label = "";
1006
1013
  if (
1007
1014
  showFractionalValues ||
1008
1015
  (yAxisLabelTexts && yAxisLabelTexts[index] !== undefined)
@@ -1013,14 +1020,14 @@ export const getLabelTextUtil = (
1013
1020
  ? val
1014
1021
  : (Number(val) + (yAxisOffset ?? 0)).toFixed(roundToDigits);
1015
1022
  } else {
1016
- label = yAxisOffset?.toString() ?? '0';
1023
+ label = yAxisOffset?.toString() ?? "0";
1017
1024
  }
1018
1025
  } else {
1019
1026
  if (val) {
1020
- label = val.toString().split('.')[0];
1027
+ label = val.toString().split(".")[0];
1021
1028
  label = (Number(label) + (yAxisOffset ?? 0)).toString();
1022
1029
  } else {
1023
- label = yAxisOffset?.toString() ?? '0';
1030
+ label = yAxisOffset?.toString() ?? "0";
1024
1031
  }
1025
1032
  }
1026
1033
 
@@ -1037,7 +1044,7 @@ export const getXForLineInBar = (
1037
1044
  currentBarWidth: number,
1038
1045
  yAxisLabelWidth: number,
1039
1046
  lineConfig: any,
1040
- spacing: number,
1047
+ spacing: number
1041
1048
  ) =>
1042
1049
  yAxisLabelWidth +
1043
1050
  firstBarWidth / 2 +
@@ -1050,8 +1057,8 @@ export const getXForLineInBar = (
1050
1057
  export const getYForLineInBar = (value, shiftY, containerHeight, maxValue) =>
1051
1058
  containerHeight - shiftY - (value * containerHeight) / maxValue;
1052
1059
 
1053
- export const clone = obj => {
1054
- if (obj === null || typeof obj !== 'object' || 'isActiveClone' in obj)
1060
+ export const clone = (obj) => {
1061
+ if (obj === null || typeof obj !== "object" || "isActiveClone" in obj)
1055
1062
  return obj;
1056
1063
 
1057
1064
  let temp;
@@ -1060,9 +1067,9 @@ export const clone = obj => {
1060
1067
 
1061
1068
  for (let key in obj) {
1062
1069
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
1063
- obj['isActiveClone'] = null;
1070
+ obj["isActiveClone"] = null;
1064
1071
  temp[key] = clone(obj[key]);
1065
- delete obj['isActiveClone'];
1072
+ delete obj["isActiveClone"];
1066
1073
  }
1067
1074
  }
1068
1075
  return temp;
@@ -1134,4 +1141,61 @@ export const getLineConfigForBarChart = (lineConfig, barInitialSpacing) => {
1134
1141
  customDataPoint: lineConfig.customDataPoint,
1135
1142
  isSecondary: lineConfig.isSecondary ?? defaultLineConfig.isSecondary,
1136
1143
  };
1137
- };
1144
+ };
1145
+
1146
+ export const getNoOfSections = (noOfSections, maxValue, stepValue) =>
1147
+ maxValue && stepValue
1148
+ ? maxValue / stepValue
1149
+ : noOfSections ?? AxesAndRulesDefaults.noOfSections;
1150
+
1151
+ export const getMaxValue = (maxValue, stepValue, noOfSections, maxItem) =>
1152
+ maxValue ?? (stepValue ? stepValue * noOfSections : maxItem);
1153
+
1154
+ export const getBarFrontColor = (
1155
+ isFocused,
1156
+ focusedBarConfig,
1157
+ itemFrontColor,
1158
+ frontColor
1159
+ ) => {
1160
+ if (isFocused) {
1161
+ return focusedBarConfig?.frontColor ?? BarDefaults.focusedBarFrontColor;
1162
+ }
1163
+ return itemFrontColor || frontColor || "";
1164
+ };
1165
+
1166
+ export const getBarSideColor = (
1167
+ isFocused,
1168
+ focusedBarConfig,
1169
+ itemSideColor,
1170
+ sideColor
1171
+ ) => {
1172
+ if (isFocused) {
1173
+ return focusedBarConfig?.sideColor ?? BarDefaults.focusedBarSideColor;
1174
+ }
1175
+ return itemSideColor || sideColor;
1176
+ };
1177
+
1178
+ export const getBarTopColor = (
1179
+ isFocused,
1180
+ focusedBarConfig,
1181
+ itemTopColor,
1182
+ topColor
1183
+ ) => {
1184
+ if (isFocused) {
1185
+ return focusedBarConfig?.topColor ?? BarDefaults.focusedBarTopColor;
1186
+ }
1187
+ return itemTopColor || topColor;
1188
+ };
1189
+
1190
+ export const getBarWidth = (
1191
+ isFocused,
1192
+ focusedBarConfig,
1193
+ itemBarWidth,
1194
+ barWidth
1195
+ ) => {
1196
+ const localBarWidth = itemBarWidth || barWidth || BarDefaults.barWidth;
1197
+ if (isFocused) {
1198
+ return focusedBarConfig?.width ?? localBarWidth;
1199
+ }
1200
+ return localBarWidth;
1201
+ };