gifted-charts-core 0.1.18 → 0.1.20
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/package.json +10 -10
- package/src/BarChart/RenderStackBars.d.ts +1 -2
- package/src/BarChart/index.d.ts +2 -3
- package/src/BarChart/index.js +1 -0
- package/src/BarChart/index.ts +1 -0
- package/src/BarChart/types.d.ts +7 -0
- package/src/BarChart/types.ts +7 -0
- package/src/LineChart/LineChartBiColor.d.ts +0 -1
- package/src/LineChart/LineChartBiColor.js +1 -0
- package/src/LineChart/LineChartBiColor.ts +1 -0
- package/src/LineChart/index.d.ts +0 -1
- package/src/LineChart/index.js +1 -0
- package/src/LineChart/index.ts +1 -0
- package/src/PopulationPyramid/index.d.ts +3 -3
- package/src/components/AnimatedThreeDBar/index.d.ts +0 -1
- package/src/components/BarAndLineChartsWrapper/index.d.ts +3 -38
- package/src/components/BarAndLineChartsWrapper/index.js +4 -3
- package/src/components/BarAndLineChartsWrapper/index.ts +8 -5
- package/src/index.d.ts +1 -1
- package/src/index.ts +3 -1
- package/src/utils/constants.d.ts +2 -1
- package/src/utils/constants.js +32 -28
- package/src/utils/constants.ts +33 -29
- package/src/utils/index.d.ts +1 -1
- package/src/utils/index.js +6 -2
- package/src/utils/index.ts +9 -1
- package/src/utils/types.d.ts +37 -1
- package/src/utils/types.ts +40 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gifted-charts-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -12,20 +12,20 @@
|
|
|
12
12
|
"lint": "eslint src/**/*.ts"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@testing-library/jest-dom": "^
|
|
16
|
-
"@testing-library/react": "^
|
|
17
|
-
"@testing-library/user-event": "^
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
19
|
-
"@types/react": "^18.
|
|
20
|
-
"@types/react-dom": "^18.
|
|
21
|
-
"@types/react-native": "^0.
|
|
15
|
+
"@testing-library/jest-dom": "^6.4.8",
|
|
16
|
+
"@testing-library/react": "^16.0.0",
|
|
17
|
+
"@testing-library/user-event": "^14.5.2",
|
|
18
|
+
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
19
|
+
"@types/react": "^18.3.3",
|
|
20
|
+
"@types/react-dom": "^18.3.0",
|
|
21
|
+
"@types/react-native": "^0.73.0",
|
|
22
22
|
"eslint": "^8.56.0",
|
|
23
|
-
"eslint-config-
|
|
23
|
+
"eslint-config-love": "^62.0.0",
|
|
24
24
|
"eslint-plugin-import": "^2.29.1",
|
|
25
25
|
"eslint-plugin-n": "^16.6.2",
|
|
26
26
|
"eslint-plugin-promise": "^6.1.1",
|
|
27
27
|
"eslint-plugin-react": "^7.33.2",
|
|
28
|
-
"typescript": "^5.
|
|
28
|
+
"typescript": "^5.5.4"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "*",
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { type StackedBarChartPropsType, type stackDataItem } from './types';
|
|
3
2
|
export declare const useRenderStackBars: (props: StackedBarChartPropsType) => {
|
|
4
3
|
cotainsNegative: boolean;
|
|
5
4
|
noAnimation: boolean;
|
|
6
|
-
localBarInnerComponent: ((item?: stackDataItem
|
|
5
|
+
localBarInnerComponent: ((item?: stackDataItem, index?: number) => import("react").ReactNode) | undefined;
|
|
7
6
|
borderRadius: number | undefined;
|
|
8
7
|
borderTopLeftRadius: number | undefined;
|
|
9
8
|
borderTopRightRadius: number | undefined;
|
package/src/BarChart/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { type lineConfigType, type BarChartPropsType, type barDataItem, type stackDataItem } from './types';
|
|
3
2
|
import { type BarAndLineChartsWrapperTypes, type secondaryYAxisType } from '../utils/types';
|
|
4
3
|
import { type Animated } from 'react-native';
|
|
@@ -75,7 +74,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
75
74
|
rtl: boolean;
|
|
76
75
|
intactTopLabel: boolean;
|
|
77
76
|
barBorderColor: import("react-native").ColorValue;
|
|
78
|
-
barInnerComponent: ((item?:
|
|
77
|
+
barInnerComponent: ((item?: stackDataItem | barDataItem, index?: number) => import("react").ReactNode) | undefined;
|
|
79
78
|
xAxisTextNumberOfLines: number;
|
|
80
79
|
selectedIndex: number;
|
|
81
80
|
setSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
@@ -148,7 +147,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
148
147
|
barBorderTopRightRadius: number | undefined;
|
|
149
148
|
barBorderBottomLeftRadius: number | undefined;
|
|
150
149
|
barBorderBottomRightRadius: number | undefined;
|
|
151
|
-
barInnerComponent: ((item?:
|
|
150
|
+
barInnerComponent: ((item?: stackDataItem | barDataItem, index?: number) => import("react").ReactNode) | undefined;
|
|
152
151
|
color: import("react-native").ColorValue | undefined;
|
|
153
152
|
showGradient: boolean | undefined;
|
|
154
153
|
gradientColor: import("react-native").ColorValue | undefined;
|
package/src/BarChart/index.js
CHANGED
|
@@ -490,6 +490,7 @@ export var useBarChart = function (props) {
|
|
|
490
490
|
scrollAnimation: scrollAnimation,
|
|
491
491
|
scrollEventThrottle: scrollEventThrottle,
|
|
492
492
|
indicatorColor: props.indicatorColor,
|
|
493
|
+
selectedIndex: selectedIndex,
|
|
493
494
|
setSelectedIndex: setSelectedIndex,
|
|
494
495
|
spacing: spacing,
|
|
495
496
|
showLine: showLine,
|
package/src/BarChart/index.ts
CHANGED
package/src/BarChart/types.d.ts
CHANGED
|
@@ -335,6 +335,10 @@ export interface lineConfigType {
|
|
|
335
335
|
arrowConfig?: arrowType;
|
|
336
336
|
customDataPoint?: Function;
|
|
337
337
|
isSecondary?: boolean;
|
|
338
|
+
focusEnabled?: boolean;
|
|
339
|
+
focusedDataPointColor?: ColorValue;
|
|
340
|
+
focusedDataPointRadius?: number;
|
|
341
|
+
focusedDataPointIndex?: number;
|
|
338
342
|
}
|
|
339
343
|
export interface defaultLineConfigType {
|
|
340
344
|
initialSpacing: number;
|
|
@@ -364,6 +368,9 @@ export interface defaultLineConfigType {
|
|
|
364
368
|
arrowConfig: arrowType;
|
|
365
369
|
customDataPoint?: Function;
|
|
366
370
|
isSecondary: boolean;
|
|
371
|
+
focusEnabled: boolean;
|
|
372
|
+
focusedDataPointColor: ColorValue;
|
|
373
|
+
focusedDataPointRadius: number;
|
|
367
374
|
}
|
|
368
375
|
interface arrowType {
|
|
369
376
|
length?: number;
|
package/src/BarChart/types.ts
CHANGED
|
@@ -374,6 +374,10 @@ export interface lineConfigType {
|
|
|
374
374
|
arrowConfig?: arrowType
|
|
375
375
|
customDataPoint?: Function
|
|
376
376
|
isSecondary?: boolean
|
|
377
|
+
focusEnabled?: boolean
|
|
378
|
+
focusedDataPointColor?: ColorValue
|
|
379
|
+
focusedDataPointRadius?: number
|
|
380
|
+
focusedDataPointIndex?: number
|
|
377
381
|
}
|
|
378
382
|
export interface defaultLineConfigType {
|
|
379
383
|
initialSpacing: number
|
|
@@ -403,6 +407,9 @@ export interface defaultLineConfigType {
|
|
|
403
407
|
arrowConfig: arrowType
|
|
404
408
|
customDataPoint?: Function
|
|
405
409
|
isSecondary: boolean
|
|
410
|
+
focusEnabled: boolean
|
|
411
|
+
focusedDataPointColor: ColorValue
|
|
412
|
+
focusedDataPointRadius: number
|
|
406
413
|
}
|
|
407
414
|
interface arrowType {
|
|
408
415
|
length?: number
|
|
@@ -398,6 +398,7 @@ export var useLineChartBiColor = function (props) {
|
|
|
398
398
|
scrollAnimation: scrollAnimation,
|
|
399
399
|
scrollEventThrottle: scrollEventThrottle,
|
|
400
400
|
indicatorColor: props.indicatorColor,
|
|
401
|
+
selectedIndex: selectedIndex,
|
|
401
402
|
setSelectedIndex: setSelectedIndex,
|
|
402
403
|
spacing: spacing,
|
|
403
404
|
showLine: false,
|
package/src/LineChart/index.d.ts
CHANGED
package/src/LineChart/index.js
CHANGED
|
@@ -1081,6 +1081,7 @@ export var useLineChart = function (props) {
|
|
|
1081
1081
|
scrollAnimation: scrollAnimation,
|
|
1082
1082
|
scrollEventThrottle: scrollEventThrottle,
|
|
1083
1083
|
indicatorColor: props.indicatorColor,
|
|
1084
|
+
selectedIndex: selectedIndex,
|
|
1084
1085
|
setSelectedIndex: setSelectedIndex,
|
|
1085
1086
|
spacing: spacing,
|
|
1086
1087
|
showLine: false,
|
package/src/LineChart/index.ts
CHANGED
|
@@ -110,10 +110,10 @@ export declare const usePopulationPyramid: (props: extendedPopulationPyramidProp
|
|
|
110
110
|
leftXAfterMid: number;
|
|
111
111
|
rightXAfterMid: number;
|
|
112
112
|
yAxisLineProps: {
|
|
113
|
-
framework?: Framework.reactNative
|
|
113
|
+
framework?: Framework.reactNative;
|
|
114
114
|
} & import("./types").RulesProps;
|
|
115
115
|
midAxisLineCommonProps: {
|
|
116
|
-
framework?: Framework.reactNative
|
|
116
|
+
framework?: Framework.reactNative;
|
|
117
117
|
} & import("./types").RulesProps;
|
|
118
118
|
xAxisLabelY: number;
|
|
119
119
|
xAxisIndicesCommonProps: {
|
|
@@ -123,7 +123,7 @@ export declare const usePopulationPyramid: (props: extendedPopulationPyramidProp
|
|
|
123
123
|
strokeWidth: number;
|
|
124
124
|
};
|
|
125
125
|
verticalLinesCommonProps: {
|
|
126
|
-
framework?: Framework.reactNative
|
|
126
|
+
framework?: Framework.reactNative;
|
|
127
127
|
} & import("./types").RulesProps;
|
|
128
128
|
xAxisLabelsCommonProps: {
|
|
129
129
|
y: number;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type BarAndLineChartsWrapperTypes, type horizSectionPropTypes } from '../../utils/types';
|
|
1
|
+
import { LineInBarChartPropsType, type BarAndLineChartsWrapperTypes, type horizSectionPropTypes } from '../../utils/types';
|
|
3
2
|
import { type NativeScrollEvent } from 'react-native';
|
|
4
3
|
export declare const useBarAndLineChartsWrapper: (props: BarAndLineChartsWrapperTypes) => {
|
|
5
4
|
containerHeightIncludingBelowXAxis: any;
|
|
@@ -59,40 +58,6 @@ export declare const useBarAndLineChartsWrapper: (props: BarAndLineChartsWrapper
|
|
|
59
58
|
totalWidth: number;
|
|
60
59
|
xAxisLabelsVerticalShift: any;
|
|
61
60
|
};
|
|
62
|
-
lineInBarChartProps:
|
|
63
|
-
|
|
64
|
-
initialSpacing: number;
|
|
65
|
-
spacing: number;
|
|
66
|
-
containerHeight: number;
|
|
67
|
-
lineConfig: any;
|
|
68
|
-
maxValue: any;
|
|
69
|
-
animatedWidth: any;
|
|
70
|
-
lineBehindBars: boolean;
|
|
71
|
-
points: string | any[];
|
|
72
|
-
arrowPoints: any;
|
|
73
|
-
data: any[];
|
|
74
|
-
totalWidth: number;
|
|
75
|
-
barWidth: number | undefined;
|
|
76
|
-
labelsExtraHeight: number;
|
|
77
|
-
scrollEventThrottle: number;
|
|
78
|
-
xAxisLabelsVerticalShift: any;
|
|
79
|
-
};
|
|
80
|
-
lineInBarChartProps2: {
|
|
81
|
-
lineConfig: any;
|
|
82
|
-
points: string | any[];
|
|
83
|
-
data: (import("../..").lineDataItem | import("../..").barDataItem | import("../..").stackDataItem)[] | undefined;
|
|
84
|
-
yAxisLabelWidth: number;
|
|
85
|
-
initialSpacing: number;
|
|
86
|
-
spacing: number;
|
|
87
|
-
containerHeight: number;
|
|
88
|
-
maxValue: any;
|
|
89
|
-
animatedWidth: any;
|
|
90
|
-
lineBehindBars: boolean;
|
|
91
|
-
arrowPoints: any;
|
|
92
|
-
totalWidth: number;
|
|
93
|
-
barWidth: number | undefined;
|
|
94
|
-
labelsExtraHeight: number;
|
|
95
|
-
scrollEventThrottle: number;
|
|
96
|
-
xAxisLabelsVerticalShift: any;
|
|
97
|
-
};
|
|
61
|
+
lineInBarChartProps: LineInBarChartPropsType;
|
|
62
|
+
lineInBarChartProps2: LineInBarChartPropsType;
|
|
98
63
|
};
|
|
@@ -38,7 +38,7 @@ import { useEffect, useState } from 'react';
|
|
|
38
38
|
import { AxesAndRulesDefaults, BarDefaults } from '../../utils/constants';
|
|
39
39
|
export var useBarAndLineChartsWrapper = function (props) {
|
|
40
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
|
41
|
-
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL;
|
|
41
|
+
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex;
|
|
42
42
|
var yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop;
|
|
43
43
|
var hideOrigin = (_a = axesAndRulesProps.hideOrigin) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.hideOrigin;
|
|
44
44
|
var yAxisSide = (_b = axesAndRulesProps.yAxisSide) !== null && _b !== void 0 ? _b : AxesAndRulesDefaults.yAxisSide;
|
|
@@ -169,9 +169,10 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
169
169
|
barWidth: barWidth,
|
|
170
170
|
labelsExtraHeight: labelsExtraHeight,
|
|
171
171
|
scrollEventThrottle: scrollEventThrottle,
|
|
172
|
-
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift
|
|
172
|
+
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
|
|
173
|
+
selectedIndex: selectedIndex
|
|
173
174
|
};
|
|
174
|
-
var lineInBarChartProps2 = __assign(__assign({}, lineInBarChartProps), { lineConfig: lineConfig2, points: points2, data: lineData2 });
|
|
175
|
+
var lineInBarChartProps2 = __assign(__assign({}, lineInBarChartProps), { lineConfig: lineConfig2, points: points2, data: lineData2 !== null && lineData2 !== void 0 ? lineData2 : [] });
|
|
175
176
|
var extendedContainerHeight = containerHeight + overflowTop + 10;
|
|
176
177
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
177
178
|
var verticalLinesProps = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
import { AxesAndRulesDefaults, BarDefaults } from '../../utils/constants'
|
|
3
3
|
import {
|
|
4
|
+
LineInBarChartPropsType,
|
|
4
5
|
type BarAndLineChartsWrapperTypes,
|
|
5
6
|
type horizSectionPropTypes
|
|
6
7
|
} from '../../utils/types'
|
|
@@ -61,7 +62,8 @@ export const useBarAndLineChartsWrapper = (
|
|
|
61
62
|
|
|
62
63
|
scrollEventThrottle,
|
|
63
64
|
endReachedOffset,
|
|
64
|
-
isRTL
|
|
65
|
+
isRTL,
|
|
66
|
+
selectedIndex
|
|
65
67
|
} = props
|
|
66
68
|
|
|
67
69
|
const yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop
|
|
@@ -237,7 +239,7 @@ export const useBarAndLineChartsWrapper = (
|
|
|
237
239
|
secondaryXAxis
|
|
238
240
|
}
|
|
239
241
|
|
|
240
|
-
const lineInBarChartProps = {
|
|
242
|
+
const lineInBarChartProps: LineInBarChartPropsType = {
|
|
241
243
|
yAxisLabelWidth,
|
|
242
244
|
initialSpacing,
|
|
243
245
|
spacing,
|
|
@@ -253,13 +255,14 @@ export const useBarAndLineChartsWrapper = (
|
|
|
253
255
|
barWidth,
|
|
254
256
|
labelsExtraHeight,
|
|
255
257
|
scrollEventThrottle,
|
|
256
|
-
xAxisLabelsVerticalShift
|
|
258
|
+
xAxisLabelsVerticalShift,
|
|
259
|
+
selectedIndex
|
|
257
260
|
}
|
|
258
|
-
const lineInBarChartProps2 = {
|
|
261
|
+
const lineInBarChartProps2: LineInBarChartPropsType = {
|
|
259
262
|
...lineInBarChartProps,
|
|
260
263
|
lineConfig: lineConfig2,
|
|
261
264
|
points: points2,
|
|
262
|
-
data: lineData2
|
|
265
|
+
data: lineData2 ?? []
|
|
263
266
|
}
|
|
264
267
|
const extendedContainerHeight = containerHeight + overflowTop + 10
|
|
265
268
|
const containerHeightIncludingBelowXAxis =
|
package/src/index.d.ts
CHANGED
|
@@ -35,4 +35,4 @@ export { getTopAndLeftForStripAndLabel } from './components/common/StripAndLabel
|
|
|
35
35
|
/***********************************************************************************************************************/
|
|
36
36
|
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset } from './utils';
|
|
37
37
|
export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
|
|
38
|
-
export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, Framework, type XAxisConfig } from './utils/types';
|
|
38
|
+
export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, Framework, type XAxisConfig, type LineInBarChartPropsType, type DataPointProps } from './utils/types';
|
package/src/index.ts
CHANGED
package/src/utils/constants.d.ts
CHANGED
|
@@ -119,7 +119,6 @@ export declare const BarDefaults: {
|
|
|
119
119
|
focusedBarSideColor: string;
|
|
120
120
|
focusedBarTopColor: string;
|
|
121
121
|
};
|
|
122
|
-
export declare const defaultLineConfig: defaultLineConfigType;
|
|
123
122
|
export declare const LineDefaults: {
|
|
124
123
|
color: string;
|
|
125
124
|
curvature: number;
|
|
@@ -145,6 +144,7 @@ export declare const LineDefaults: {
|
|
|
145
144
|
dataPointsColor2: string;
|
|
146
145
|
dataPointsColor3: string;
|
|
147
146
|
dataPointsShape: string;
|
|
147
|
+
focusedDataPointColor: string;
|
|
148
148
|
textFontSize: number;
|
|
149
149
|
textColor: string;
|
|
150
150
|
startFillColor: string;
|
|
@@ -165,6 +165,7 @@ export declare const LineDefaults: {
|
|
|
165
165
|
edgePosition: EdgePosition;
|
|
166
166
|
endReachedOffset: number;
|
|
167
167
|
};
|
|
168
|
+
export declare const defaultLineConfig: defaultLineConfigType;
|
|
168
169
|
export declare const defaultPointerConfig: {
|
|
169
170
|
height: number;
|
|
170
171
|
width: number;
|
package/src/utils/constants.js
CHANGED
|
@@ -130,34 +130,6 @@ export var BarDefaults = {
|
|
|
130
130
|
focusedBarSideColor: '#776913',
|
|
131
131
|
focusedBarTopColor: '#C8D565'
|
|
132
132
|
};
|
|
133
|
-
export var defaultLineConfig = {
|
|
134
|
-
initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
|
|
135
|
-
curved: false,
|
|
136
|
-
curvature: defaultCurvature,
|
|
137
|
-
curveType: defaultCurveType,
|
|
138
|
-
isAnimated: false,
|
|
139
|
-
animationDuration: defaultAnimationDuration,
|
|
140
|
-
thickness: 1,
|
|
141
|
-
color: 'black',
|
|
142
|
-
hideDataPoints: false,
|
|
143
|
-
dataPointsShape: 'circular',
|
|
144
|
-
dataPointsWidth: 4,
|
|
145
|
-
dataPointsHeight: 4,
|
|
146
|
-
dataPointsColor: 'black',
|
|
147
|
-
dataPointsRadius: 3,
|
|
148
|
-
textColor: 'gray',
|
|
149
|
-
textFontSize: 10,
|
|
150
|
-
textShiftX: 0,
|
|
151
|
-
textShiftY: 0,
|
|
152
|
-
shiftX: 0,
|
|
153
|
-
shiftY: 0,
|
|
154
|
-
delay: 0,
|
|
155
|
-
startIndex: 0,
|
|
156
|
-
endIndex: 0, // gets updated to lineData.length - 1
|
|
157
|
-
showArrow: false,
|
|
158
|
-
arrowConfig: defaultArrowConfig,
|
|
159
|
-
isSecondary: false
|
|
160
|
-
};
|
|
161
133
|
// Line chart specific
|
|
162
134
|
export var LineDefaults = {
|
|
163
135
|
color: 'black',
|
|
@@ -184,6 +156,7 @@ export var LineDefaults = {
|
|
|
184
156
|
dataPointsColor2: 'blue',
|
|
185
157
|
dataPointsColor3: 'red',
|
|
186
158
|
dataPointsShape: 'circular',
|
|
159
|
+
focusedDataPointColor: 'orange',
|
|
187
160
|
textFontSize: 10,
|
|
188
161
|
textColor: 'gray',
|
|
189
162
|
startFillColor: 'gray',
|
|
@@ -204,6 +177,37 @@ export var LineDefaults = {
|
|
|
204
177
|
edgePosition: EdgePosition.AFTER_DATA_POINT,
|
|
205
178
|
endReachedOffset: defaultEndReachedOffset
|
|
206
179
|
};
|
|
180
|
+
export var defaultLineConfig = {
|
|
181
|
+
initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
|
|
182
|
+
curved: false,
|
|
183
|
+
curvature: defaultCurvature,
|
|
184
|
+
curveType: defaultCurveType,
|
|
185
|
+
isAnimated: false,
|
|
186
|
+
animationDuration: defaultAnimationDuration,
|
|
187
|
+
thickness: 1,
|
|
188
|
+
color: 'black',
|
|
189
|
+
hideDataPoints: false,
|
|
190
|
+
dataPointsShape: 'circular',
|
|
191
|
+
dataPointsWidth: 4,
|
|
192
|
+
dataPointsHeight: 4,
|
|
193
|
+
dataPointsColor: 'black',
|
|
194
|
+
dataPointsRadius: 3,
|
|
195
|
+
textColor: 'gray',
|
|
196
|
+
textFontSize: 10,
|
|
197
|
+
textShiftX: 0,
|
|
198
|
+
textShiftY: 0,
|
|
199
|
+
shiftX: 0,
|
|
200
|
+
shiftY: 0,
|
|
201
|
+
delay: 0,
|
|
202
|
+
startIndex: 0,
|
|
203
|
+
endIndex: 0, // gets updated to lineData.length - 1
|
|
204
|
+
showArrow: false,
|
|
205
|
+
arrowConfig: defaultArrowConfig,
|
|
206
|
+
isSecondary: false,
|
|
207
|
+
focusEnabled: false,
|
|
208
|
+
focusedDataPointColor: LineDefaults.focusedDataPointColor,
|
|
209
|
+
focusedDataPointRadius: LineDefaults.dataPointsRadius,
|
|
210
|
+
};
|
|
207
211
|
export var defaultPointerConfig = {
|
|
208
212
|
height: 0,
|
|
209
213
|
width: 0,
|
package/src/utils/constants.ts
CHANGED
|
@@ -156,35 +156,6 @@ export const BarDefaults = {
|
|
|
156
156
|
focusedBarTopColor: '#C8D565'
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
export const defaultLineConfig: defaultLineConfigType = {
|
|
160
|
-
initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
|
|
161
|
-
curved: false,
|
|
162
|
-
curvature: defaultCurvature,
|
|
163
|
-
curveType: defaultCurveType,
|
|
164
|
-
isAnimated: false,
|
|
165
|
-
animationDuration: defaultAnimationDuration,
|
|
166
|
-
thickness: 1,
|
|
167
|
-
color: 'black',
|
|
168
|
-
hideDataPoints: false,
|
|
169
|
-
dataPointsShape: 'circular',
|
|
170
|
-
dataPointsWidth: 4,
|
|
171
|
-
dataPointsHeight: 4,
|
|
172
|
-
dataPointsColor: 'black',
|
|
173
|
-
dataPointsRadius: 3,
|
|
174
|
-
textColor: 'gray',
|
|
175
|
-
textFontSize: 10,
|
|
176
|
-
textShiftX: 0,
|
|
177
|
-
textShiftY: 0,
|
|
178
|
-
shiftX: 0,
|
|
179
|
-
shiftY: 0,
|
|
180
|
-
delay: 0,
|
|
181
|
-
startIndex: 0,
|
|
182
|
-
endIndex: 0, // gets updated to lineData.length - 1
|
|
183
|
-
showArrow: false,
|
|
184
|
-
arrowConfig: defaultArrowConfig,
|
|
185
|
-
isSecondary: false
|
|
186
|
-
}
|
|
187
|
-
|
|
188
159
|
// Line chart specific
|
|
189
160
|
|
|
190
161
|
export const LineDefaults = {
|
|
@@ -213,6 +184,7 @@ export const LineDefaults = {
|
|
|
213
184
|
dataPointsColor2: 'blue',
|
|
214
185
|
dataPointsColor3: 'red',
|
|
215
186
|
dataPointsShape: 'circular',
|
|
187
|
+
focusedDataPointColor: 'orange',
|
|
216
188
|
|
|
217
189
|
textFontSize: 10,
|
|
218
190
|
textColor: 'gray',
|
|
@@ -237,6 +209,38 @@ export const LineDefaults = {
|
|
|
237
209
|
endReachedOffset: defaultEndReachedOffset
|
|
238
210
|
}
|
|
239
211
|
|
|
212
|
+
export const defaultLineConfig: defaultLineConfigType = {
|
|
213
|
+
initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
|
|
214
|
+
curved: false,
|
|
215
|
+
curvature: defaultCurvature,
|
|
216
|
+
curveType: defaultCurveType,
|
|
217
|
+
isAnimated: false,
|
|
218
|
+
animationDuration: defaultAnimationDuration,
|
|
219
|
+
thickness: 1,
|
|
220
|
+
color: 'black',
|
|
221
|
+
hideDataPoints: false,
|
|
222
|
+
dataPointsShape: 'circular',
|
|
223
|
+
dataPointsWidth: 4,
|
|
224
|
+
dataPointsHeight: 4,
|
|
225
|
+
dataPointsColor: 'black',
|
|
226
|
+
dataPointsRadius: 3,
|
|
227
|
+
textColor: 'gray',
|
|
228
|
+
textFontSize: 10,
|
|
229
|
+
textShiftX: 0,
|
|
230
|
+
textShiftY: 0,
|
|
231
|
+
shiftX: 0,
|
|
232
|
+
shiftY: 0,
|
|
233
|
+
delay: 0,
|
|
234
|
+
startIndex: 0,
|
|
235
|
+
endIndex: 0, // gets updated to lineData.length - 1
|
|
236
|
+
showArrow: false,
|
|
237
|
+
arrowConfig: defaultArrowConfig,
|
|
238
|
+
isSecondary: false,
|
|
239
|
+
focusEnabled: false,
|
|
240
|
+
focusedDataPointColor: LineDefaults.focusedDataPointColor,
|
|
241
|
+
focusedDataPointRadius: LineDefaults.dataPointsRadius,
|
|
242
|
+
}
|
|
243
|
+
|
|
240
244
|
export const defaultPointerConfig = {
|
|
241
245
|
height: 0,
|
|
242
246
|
width: 0,
|
package/src/utils/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ interface MaxAndMin {
|
|
|
81
81
|
}
|
|
82
82
|
export declare const maxAndMinUtil: (maxItem: number, minItem: number, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
|
|
83
83
|
export declare const computeMaxAndMinItems: (data: any[] | undefined, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
|
|
84
|
-
export declare const getLabelTextUtil: (val: string, index: number, showFractionalValues?: boolean, yAxisLabelTexts?: string[], yAxisOffset?: number, yAxisLabelPrefix?: string, yAxisLabelSuffix?: string, roundToDigits?: number, formatYLabel?: (
|
|
84
|
+
export declare const getLabelTextUtil: (val: string, index: number, showFractionalValues?: boolean, yAxisLabelTexts?: string[], yAxisOffset?: number, yAxisLabelPrefix?: string, yAxisLabelSuffix?: string, roundToDigits?: number, formatYLabel?: (label: string) => string) => string;
|
|
85
85
|
export declare const getXForLineInBar: (index: number, firstBarWidth: number, currentBarWidth: number, yAxisLabelWidth: number, lineConfig: any, spacing: number) => number;
|
|
86
86
|
export declare const getYForLineInBar: (value: number | undefined, shiftY: number | undefined, containerHeight: number, maxValue: number) => number;
|
|
87
87
|
export declare const clone: (obj: any) => any;
|
package/src/utils/index.js
CHANGED
|
@@ -749,7 +749,7 @@ export var clone = function (obj) {
|
|
|
749
749
|
return temp;
|
|
750
750
|
};
|
|
751
751
|
export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
|
|
752
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
752
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22;
|
|
753
753
|
return {
|
|
754
754
|
initialSpacing: (_b = (_a = lineConfig.initialSpacing) !== null && _a !== void 0 ? _a : barInitialSpacing) !== null && _b !== void 0 ? _b : defaultLineConfig.initialSpacing,
|
|
755
755
|
spacing: lineConfig.spacing,
|
|
@@ -787,7 +787,11 @@ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
|
|
|
787
787
|
showArrowBase: (_17 = (_16 = lineConfig.arrowConfig) === null || _16 === void 0 ? void 0 : _16.showArrowBase) !== null && _17 !== void 0 ? _17 : (_18 = defaultLineConfig.arrowConfig) === null || _18 === void 0 ? void 0 : _18.showArrowBase
|
|
788
788
|
},
|
|
789
789
|
customDataPoint: lineConfig.customDataPoint,
|
|
790
|
-
isSecondary: (_19 = lineConfig.isSecondary) !== null && _19 !== void 0 ? _19 : defaultLineConfig.isSecondary
|
|
790
|
+
isSecondary: (_19 = lineConfig.isSecondary) !== null && _19 !== void 0 ? _19 : defaultLineConfig.isSecondary,
|
|
791
|
+
focusEnabled: (_20 = lineConfig.focusEnabled) !== null && _20 !== void 0 ? _20 : defaultLineConfig.focusEnabled,
|
|
792
|
+
focusedDataPointColor: (_21 = lineConfig.focusedDataPointColor) !== null && _21 !== void 0 ? _21 : defaultLineConfig.focusedDataPointColor,
|
|
793
|
+
focusedDataPointRadius: (_22 = lineConfig.focusedDataPointRadius) !== null && _22 !== void 0 ? _22 : defaultLineConfig.focusedDataPointRadius,
|
|
794
|
+
focusedDataPointIndex: lineConfig.focusedDataPointIndex
|
|
791
795
|
};
|
|
792
796
|
};
|
|
793
797
|
export var getNoOfSections = function (noOfSections, maxValue, stepValue) {
|
package/src/utils/index.ts
CHANGED
|
@@ -1241,7 +1241,15 @@ export const getLineConfigForBarChart = (
|
|
|
1241
1241
|
defaultLineConfig.arrowConfig?.showArrowBase
|
|
1242
1242
|
},
|
|
1243
1243
|
customDataPoint: lineConfig.customDataPoint,
|
|
1244
|
-
isSecondary: lineConfig.isSecondary ?? defaultLineConfig.isSecondary
|
|
1244
|
+
isSecondary: lineConfig.isSecondary ?? defaultLineConfig.isSecondary,
|
|
1245
|
+
focusEnabled: lineConfig.focusEnabled ?? defaultLineConfig.focusEnabled,
|
|
1246
|
+
focusedDataPointColor:
|
|
1247
|
+
lineConfig.focusedDataPointColor ??
|
|
1248
|
+
defaultLineConfig.focusedDataPointColor,
|
|
1249
|
+
focusedDataPointRadius:
|
|
1250
|
+
lineConfig.focusedDataPointRadius ??
|
|
1251
|
+
defaultLineConfig.focusedDataPointRadius,
|
|
1252
|
+
focusedDataPointIndex: lineConfig.focusedDataPointIndex
|
|
1245
1253
|
}
|
|
1246
1254
|
}
|
|
1247
1255
|
|
package/src/utils/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ColorValue } from 'react-native';
|
|
2
2
|
import { type chartTypes, type yAxisSides } from './constants';
|
|
3
3
|
import { type lineDataItem } from '../LineChart/types';
|
|
4
|
-
import { type barDataItem, type stackDataItem } from '../BarChart/types';
|
|
4
|
+
import { lineConfigType, type barDataItem, type stackDataItem } from '../BarChart/types';
|
|
5
5
|
export declare enum Framework {
|
|
6
6
|
reactJS = 0,
|
|
7
7
|
reactNative = 1
|
|
@@ -98,6 +98,41 @@ export interface secondaryLineConfigType {
|
|
|
98
98
|
arrowConfig?: arrowConfigType;
|
|
99
99
|
isSecondary?: boolean;
|
|
100
100
|
}
|
|
101
|
+
export interface ExtendedLineConfigType extends lineConfigType {
|
|
102
|
+
startIndex: number;
|
|
103
|
+
endIndex: number;
|
|
104
|
+
dataPointsHeight: number;
|
|
105
|
+
}
|
|
106
|
+
export interface LineInBarChartPropsType {
|
|
107
|
+
yAxisLabelWidth: number;
|
|
108
|
+
initialSpacing: number;
|
|
109
|
+
spacing: number;
|
|
110
|
+
containerHeight: number;
|
|
111
|
+
lineConfig: ExtendedLineConfigType;
|
|
112
|
+
maxValue: number;
|
|
113
|
+
animatedWidth: number;
|
|
114
|
+
lineBehindBars: boolean;
|
|
115
|
+
points: any;
|
|
116
|
+
arrowPoints: any;
|
|
117
|
+
data: any[];
|
|
118
|
+
totalWidth: number;
|
|
119
|
+
barWidth?: number;
|
|
120
|
+
labelsExtraHeight: number;
|
|
121
|
+
scrollEventThrottle: number;
|
|
122
|
+
xAxisLabelsVerticalShift: number;
|
|
123
|
+
selectedIndex: number;
|
|
124
|
+
}
|
|
125
|
+
export interface DataPointProps {
|
|
126
|
+
data: any[];
|
|
127
|
+
lineConfig: ExtendedLineConfigType;
|
|
128
|
+
barWidth?: number;
|
|
129
|
+
containerHeight: number;
|
|
130
|
+
maxValue: number;
|
|
131
|
+
firstBarWidth: number;
|
|
132
|
+
yAxisLabelWidth: number;
|
|
133
|
+
spacing: number;
|
|
134
|
+
selectedIndex: number;
|
|
135
|
+
}
|
|
101
136
|
export interface referenceConfigType {
|
|
102
137
|
thickness?: number;
|
|
103
138
|
width?: number;
|
|
@@ -213,6 +248,7 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
213
248
|
scrollToIndex: number | undefined;
|
|
214
249
|
scrollAnimation: boolean;
|
|
215
250
|
indicatorColor: 'black' | 'default' | 'white' | undefined;
|
|
251
|
+
selectedIndex: number;
|
|
216
252
|
setSelectedIndex: any;
|
|
217
253
|
spacing: number;
|
|
218
254
|
showLine: boolean;
|
package/src/utils/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ColorValue } from 'react-native'
|
|
2
2
|
import { type chartTypes, type yAxisSides } from './constants'
|
|
3
3
|
import { type lineDataItem } from '../LineChart/types'
|
|
4
|
-
import { type barDataItem, type stackDataItem } from '../BarChart/types'
|
|
4
|
+
import { lineConfigType, type barDataItem, type stackDataItem } from '../BarChart/types'
|
|
5
5
|
|
|
6
6
|
export enum Framework {
|
|
7
7
|
reactJS,
|
|
@@ -112,6 +112,44 @@ export interface secondaryLineConfigType {
|
|
|
112
112
|
isSecondary?: boolean
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
export interface ExtendedLineConfigType extends lineConfigType {
|
|
116
|
+
startIndex: number
|
|
117
|
+
endIndex: number
|
|
118
|
+
dataPointsHeight: number
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface LineInBarChartPropsType {
|
|
122
|
+
yAxisLabelWidth: number
|
|
123
|
+
initialSpacing: number
|
|
124
|
+
spacing: number
|
|
125
|
+
containerHeight: number
|
|
126
|
+
lineConfig: ExtendedLineConfigType
|
|
127
|
+
maxValue: number
|
|
128
|
+
animatedWidth: number
|
|
129
|
+
lineBehindBars: boolean
|
|
130
|
+
points: any
|
|
131
|
+
arrowPoints: any
|
|
132
|
+
data: any[]
|
|
133
|
+
totalWidth: number
|
|
134
|
+
barWidth?: number
|
|
135
|
+
labelsExtraHeight: number
|
|
136
|
+
scrollEventThrottle: number
|
|
137
|
+
xAxisLabelsVerticalShift: number
|
|
138
|
+
selectedIndex: number
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface DataPointProps {
|
|
142
|
+
data: any[];
|
|
143
|
+
lineConfig: ExtendedLineConfigType;
|
|
144
|
+
barWidth?: number;
|
|
145
|
+
containerHeight: number;
|
|
146
|
+
maxValue: number;
|
|
147
|
+
firstBarWidth: number;
|
|
148
|
+
yAxisLabelWidth: number;
|
|
149
|
+
spacing: number;
|
|
150
|
+
selectedIndex: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
115
153
|
export interface referenceConfigType {
|
|
116
154
|
thickness?: number
|
|
117
155
|
width?: number
|
|
@@ -239,6 +277,7 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
239
277
|
scrollToIndex: number | undefined
|
|
240
278
|
scrollAnimation: boolean
|
|
241
279
|
indicatorColor: 'black' | 'default' | 'white' | undefined
|
|
280
|
+
selectedIndex: number
|
|
242
281
|
setSelectedIndex: any
|
|
243
282
|
spacing: number
|
|
244
283
|
showLine: boolean
|