@bashem/rn-charts 0.0.4 → 0.0.5
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/README.md +1 -1
- package/lib/module/skia/AreaChart/AreaChart.js +60 -51
- package/lib/module/skia/AreaChart/AreaChart.js.map +1 -1
- package/lib/module/skia/AreaChart/useAreaChart.js +18 -14
- package/lib/module/skia/AreaChart/useAreaChart.js.map +1 -1
- package/lib/module/skia/BarChart/BarChart.js +156 -69
- package/lib/module/skia/BarChart/BarChart.js.map +1 -1
- package/lib/module/skia/BarChart/useBarChart.js +53 -41
- package/lib/module/skia/BarChart/useBarChart.js.map +1 -1
- package/lib/module/skia/Common/HorizontalLabelView.js +121 -0
- package/lib/module/skia/Common/HorizontalLabelView.js.map +1 -0
- package/lib/module/skia/Common/VerticalLabelView.js +100 -0
- package/lib/module/skia/Common/VerticalLabelView.js.map +1 -0
- package/lib/module/skia/Common/useComponentLayout.js +13 -0
- package/lib/module/skia/Common/useComponentLayout.js.map +1 -0
- package/lib/module/skia/HeatMap/DateHeatMap.js +472 -0
- package/lib/module/skia/HeatMap/DateHeatMap.js.map +1 -0
- package/lib/module/skia/HeatMap/HeatMap.js +121 -33
- package/lib/module/skia/HeatMap/HeatMap.js.map +1 -1
- package/lib/module/skia/HeatMap/useHeatMap.js +132 -48
- package/lib/module/skia/HeatMap/useHeatMap.js.map +1 -1
- package/lib/module/skia/PieChart/PieChart.js +21 -17
- package/lib/module/skia/PieChart/PieChart.js.map +1 -1
- package/lib/module/skia/PieChart/usePieChart.js +241 -30
- package/lib/module/skia/PieChart/usePieChart.js.map +1 -1
- package/lib/module/skia/Popup.js +7 -5
- package/lib/module/skia/Popup.js.map +1 -1
- package/lib/module/skia/common.js +4 -41
- package/lib/module/skia/common.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/skia/AreaChart/AreaChart.d.ts +15 -3
- package/lib/typescript/src/skia/AreaChart/AreaChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/AreaChart/useAreaChart.d.ts +13 -14
- package/lib/typescript/src/skia/AreaChart/useAreaChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/BarChart/BarChart.d.ts +16 -2
- package/lib/typescript/src/skia/BarChart/BarChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/BarChart/useBarChart.d.ts +17 -5
- package/lib/typescript/src/skia/BarChart/useBarChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/Common/HorizontalLabelView.d.ts +33 -0
- package/lib/typescript/src/skia/Common/HorizontalLabelView.d.ts.map +1 -0
- package/lib/typescript/src/skia/Common/VerticalLabelView.d.ts +24 -0
- package/lib/typescript/src/skia/Common/VerticalLabelView.d.ts.map +1 -0
- package/lib/typescript/src/skia/Common/useComponentLayout.d.ts +4 -0
- package/lib/typescript/src/skia/Common/useComponentLayout.d.ts.map +1 -0
- package/lib/typescript/src/skia/HeatMap/DateHeatMap.d.ts +1 -0
- package/lib/typescript/src/skia/HeatMap/DateHeatMap.d.ts.map +1 -0
- package/lib/typescript/src/skia/HeatMap/HeatMap.d.ts +28 -12
- package/lib/typescript/src/skia/HeatMap/HeatMap.d.ts.map +1 -1
- package/lib/typescript/src/skia/HeatMap/useHeatMap.d.ts +15 -4
- package/lib/typescript/src/skia/HeatMap/useHeatMap.d.ts.map +1 -1
- package/lib/typescript/src/skia/PieChart/PieChart.d.ts +5 -1
- package/lib/typescript/src/skia/PieChart/PieChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/PieChart/usePieChart.d.ts +6 -1
- package/lib/typescript/src/skia/PieChart/usePieChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/Popup.d.ts.map +1 -1
- package/lib/typescript/src/skia/common.d.ts +3 -10
- package/lib/typescript/src/skia/common.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/index.tsx +6 -4
- package/src/skia/AreaChart/AreaChart.tsx +85 -62
- package/src/skia/AreaChart/useAreaChart.ts +25 -26
- package/src/skia/BarChart/BarChart.tsx +163 -95
- package/src/skia/BarChart/useBarChart.ts +55 -44
- package/src/skia/Common/HorizontalLabelView.tsx +153 -0
- package/src/skia/Common/VerticalLabelView.tsx +113 -0
- package/src/skia/Common/useComponentLayout.ts +14 -0
- package/src/skia/HeatMap/DateHeatMap.tsx +470 -0
- package/src/skia/HeatMap/HeatMap.tsx +168 -54
- package/src/skia/HeatMap/useHeatMap.ts +139 -65
- package/src/skia/PieChart/PieChart.tsx +16 -11
- package/src/skia/PieChart/usePieChart.ts +316 -66
- package/src/skia/Popup.tsx +38 -36
- package/src/skia/common.ts +8 -46
- package/lib/module/skia/Common/VerticalLabel.js +0 -73
- package/lib/module/skia/Common/VerticalLabel.js.map +0 -1
- package/lib/typescript/src/skia/Common/VerticalLabel.d.ts +0 -17
- package/lib/typescript/src/skia/Common/VerticalLabel.d.ts.map +0 -1
- package/src/skia/Common/VerticalLabel.tsx +0 -91
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Experimental Charts Library. ⚠️ Not ready for use.
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
npm install @bashem/rn-charts @shopify/react-native-skia@2.2.12 react-native-gesture-handler@2.28.0
|
|
9
|
+
npm install @bashem/rn-charts @shopify/react-native-skia@2.2.12 react-native-gesture-handler@2.28.0 react-native-reanimated@4.1.1 react-native-worklets@0.5.1
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
|
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// AreaChart.tsx
|
|
4
|
-
import { Canvas, Circle, Group, Path
|
|
5
|
-
import VerticalLabel from "../Common/VerticalLabel.js";
|
|
4
|
+
import { Canvas, Circle, Group, Path } from '@shopify/react-native-skia';
|
|
6
5
|
import { View } from 'react-native';
|
|
7
6
|
import useAreaChart from "./useAreaChart.js";
|
|
8
7
|
import { useState } from 'react';
|
|
9
8
|
import { lighten } from "../../util/colors.js";
|
|
10
9
|
import Popup from "../Popup.js";
|
|
10
|
+
import VerticalLabelView from "../Common/VerticalLabelView.js";
|
|
11
|
+
import HorizontalLabelView from "../Common/HorizontalLabelView.js";
|
|
11
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
function AreaChart(
|
|
13
|
+
function AreaChart({
|
|
14
|
+
xLabelView,
|
|
15
|
+
yLabelView,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
13
18
|
const {
|
|
14
19
|
minValue,
|
|
15
20
|
maxValue,
|
|
16
21
|
canvasHeight,
|
|
17
22
|
areaCanvasHeight,
|
|
18
|
-
|
|
23
|
+
verticalLabelWidth,
|
|
24
|
+
verticalLabelStrokeWidth,
|
|
25
|
+
yLabels,
|
|
26
|
+
setVerticalLabelWidth,
|
|
27
|
+
setHorizontalLabelHeight,
|
|
19
28
|
chartWidth,
|
|
20
29
|
paths,
|
|
21
30
|
xLabelsData,
|
|
22
31
|
paddingLeft,
|
|
23
32
|
paddingTop,
|
|
24
33
|
paddingHorizontal,
|
|
25
|
-
font,
|
|
26
34
|
touchLine,
|
|
27
35
|
touchHandler
|
|
28
36
|
} = useAreaChart(props);
|
|
@@ -34,12 +42,9 @@ function AreaChart(props) {
|
|
|
34
42
|
x: 0,
|
|
35
43
|
y: 0
|
|
36
44
|
});
|
|
37
|
-
console.log('AreaChart render', {
|
|
38
|
-
touchLine
|
|
39
|
-
});
|
|
40
45
|
return /*#__PURE__*/_jsxs(View, {
|
|
41
46
|
style: [style, {
|
|
42
|
-
flexDirection:
|
|
47
|
+
flexDirection: "column"
|
|
43
48
|
}],
|
|
44
49
|
ref: view => {
|
|
45
50
|
view?.measureInWindow((fx, fy) => {
|
|
@@ -54,49 +59,53 @@ function AreaChart(props) {
|
|
|
54
59
|
});
|
|
55
60
|
});
|
|
56
61
|
},
|
|
57
|
-
children: [/*#__PURE__*/
|
|
58
|
-
minValue: minValue,
|
|
59
|
-
maxValue: maxValue,
|
|
60
|
-
styles: {
|
|
61
|
-
height: areaCanvasHeight,
|
|
62
|
-
width: labelWidth,
|
|
63
|
-
fontSize: style?.fontSize
|
|
64
|
-
},
|
|
65
|
-
labelCount: 5
|
|
66
|
-
}), /*#__PURE__*/_jsxs(Canvas, {
|
|
62
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
67
63
|
style: {
|
|
68
|
-
|
|
69
|
-
height: canvasHeight
|
|
64
|
+
flexDirection: "row"
|
|
70
65
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
66
|
+
children: [yLabelView && /*#__PURE__*/_jsx(VerticalLabelView, {
|
|
67
|
+
onLayout: event => {
|
|
68
|
+
setVerticalLabelWidth(event.nativeEvent.layout.width);
|
|
69
|
+
},
|
|
70
|
+
labelPercentages: yLabels,
|
|
71
|
+
styles: {
|
|
72
|
+
height: areaCanvasHeight,
|
|
73
|
+
verticalLabelStyle: props.style?.verticalLabelStyle
|
|
74
|
+
},
|
|
75
|
+
children: percentage => yLabelView(percentage, minValue, maxValue)
|
|
76
|
+
}), /*#__PURE__*/_jsx(Canvas, {
|
|
77
|
+
style: {
|
|
78
|
+
width: chartWidth,
|
|
79
|
+
height: areaCanvasHeight
|
|
80
|
+
},
|
|
81
|
+
onTouchStart: event => touchHandler(event.nativeEvent.locationX, event.nativeEvent.locationY),
|
|
82
|
+
children: paths.map(({
|
|
83
|
+
path,
|
|
84
|
+
points,
|
|
85
|
+
color
|
|
86
|
+
}, index) => {
|
|
87
|
+
return /*#__PURE__*/_jsxs(Group, {
|
|
88
|
+
children: [/*#__PURE__*/_jsx(Path, {
|
|
89
|
+
path: path,
|
|
90
|
+
color: color
|
|
91
|
+
}), style?.showPoints && color && points.map(points => /*#__PURE__*/_jsx(Circle, {
|
|
92
|
+
cx: points.x,
|
|
93
|
+
cy: points.y,
|
|
94
|
+
r: style?.pointRadius ?? 3,
|
|
95
|
+
color: lighten(color, style?.lightenPointsBy ?? 0.3)
|
|
96
|
+
}, `${points.x}-${points.y}`))]
|
|
97
|
+
}, index);
|
|
98
|
+
})
|
|
99
99
|
})]
|
|
100
|
+
}), xLabelView && /*#__PURE__*/_jsx(HorizontalLabelView, {
|
|
101
|
+
labels: xLabelsData.map(labelData => labelData.label),
|
|
102
|
+
positions: xLabelsData.map(labelData => labelData.xPosition),
|
|
103
|
+
style: {
|
|
104
|
+
left: verticalLabelWidth,
|
|
105
|
+
width: chartWidth
|
|
106
|
+
},
|
|
107
|
+
onLayout: event => setHorizontalLabelHeight(event.nativeEvent.layout.height),
|
|
108
|
+
children: label => xLabelView(label.toString())
|
|
100
109
|
}), touchLine && /*#__PURE__*/_jsx(Popup, {
|
|
101
110
|
popupData: touchLine.y.map((y, index) => ({
|
|
102
111
|
x: touchLine.x,
|
|
@@ -107,11 +116,11 @@ function AreaChart(props) {
|
|
|
107
116
|
value: touchLine.values[index]
|
|
108
117
|
}
|
|
109
118
|
})),
|
|
110
|
-
totalWidth: chartWidth +
|
|
119
|
+
totalWidth: chartWidth + verticalLabelWidth + paddingHorizontal,
|
|
111
120
|
totalHeight: canvasHeight,
|
|
112
121
|
touchHandler: (x, y) => {
|
|
113
122
|
console.log('Popup touchHandler', x, y);
|
|
114
|
-
touchHandler(x -
|
|
123
|
+
touchHandler(x - verticalLabelWidth - paddingLeft, y - paddingTop);
|
|
115
124
|
},
|
|
116
125
|
viewOffset: viewOffset,
|
|
117
126
|
popupStyle: popupStyle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Canvas","Circle","Group","Path","
|
|
1
|
+
{"version":3,"names":["Canvas","Circle","Group","Path","View","useAreaChart","useState","lighten","Popup","VerticalLabelView","HorizontalLabelView","jsx","_jsx","jsxs","_jsxs","AreaChart","xLabelView","yLabelView","props","minValue","maxValue","canvasHeight","areaCanvasHeight","verticalLabelWidth","verticalLabelStrokeWidth","yLabels","setVerticalLabelWidth","setHorizontalLabelHeight","chartWidth","paths","xLabelsData","paddingLeft","paddingTop","paddingHorizontal","touchLine","touchHandler","style","popupStyle","viewOffset","setViewOffset","x","y","flexDirection","ref","view","measureInWindow","fx","fy","prev","children","onLayout","event","nativeEvent","layout","width","labelPercentages","styles","height","verticalLabelStyle","percentage","onTouchStart","locationX","locationY","map","path","points","color","index","showPoints","cx","cy","r","pointRadius","lightenPointsBy","labels","labelData","label","positions","xPosition","left","toString","popupData","data","rowIndex","colIndex","col","value","values","totalWidth","totalHeight","console","log"],"sourceRoot":"../../../../src","sources":["skia/AreaChart/AreaChart.tsx"],"mappings":";;AAAA;AACA,SAASA,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4BAA4B;AAExE,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,YAAY,MAAM,mBAAgB;AACzC,SAASC,QAAQ,QAAQ,OAAO;AAChC,SAASC,OAAO,QAAQ,sBAAmB;AAC3C,OAAOC,KAAK,MAA2B,aAAU;AACjD,OAAOC,iBAAiB,MAAmC,gCAA6B;AACxF,OAAOC,mBAAmB,MAAqC,kCAA+B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AA+B/F,SAASC,SAASA,CAAC;EAAEC,UAAU;EAAEC,UAAU;EAAE,GAAGC;AAAsB,CAAC,EAAE;EACvE,MAAM;IACJC,QAAQ;IACRC,QAAQ;IACRC,YAAY;IACZC,gBAAgB;IAChBC,kBAAkB;IAClBC,wBAAwB;IACxBC,OAAO;IACPC,qBAAqB;IACrBC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S,IAAIA,SAAS,CAACG,SAAS,CAAE;MAC7D1C,KAAK,EAAE;QACL2C,IAAI,EAAExD,kBAAkB;QACxB+B,KAAK,EAAE1B;MACT,CAAE;MACFsB,QAAQ,EAAGC,KAAK,IAAKxB,wBAAwB,CAACwB,KAAK,CAACC,WAAW,CAACC,MAAM,CAACI,MAAM,CAAE;MAAAR,QAAA,EAE9E2B,KAAK,IAAI5D,UAAU,CAAC4D,KAAK,CAACI,QAAQ,CAAC,CAAC;IAAC,CACnB,CAAC,EAEvB9C,SAAS,iBACRtB,IAAA,CAACJ,KAAK;MACJyE,SAAS,EAAE/C,SAAS,CAACO,CAAC,CAACsB,GAAG,CAAC,CAACtB,CAAC,EAAE0B,KAAK,MAAM;QACxC3B,CAAC,EAAEN,SAAS,CAACM,CAAC;QACdC,CAAC,EAAEA,CAAC;QACJyC,IAAI,EAAE;UACJC,QAAQ,EAAEhB,KAAK;UACfiB,QAAQ,EAAElD,SAAS,CAACmD,GAAG;UACvBC,KAAK,EAAEpD,SAAS,CAACqD,MAAM,CAACpB,KAAK;QAC/B;MACF,CAAC,CAAC,CAAE;MACJqB,UAAU,EAAE5D,UAAU,GAAGL,kBAAkB,GAAGU,iBAAkB;MAChEwD,WAAW,EAAEpE,YAAa;MAC1Bc,YAAY,EAAEA,CAACK,CAAC,EAAEC,CAAC,KAAK;QACtBiD,OAAO,CAACC,GAAG,CAAC,oBAAoB,EAAEnD,CAAC,EAAEC,CAAC,CAAC;QACvCN,YAAY,CAACK,CAAC,GAAGjB,kBAAkB,GAAGQ,WAAW,EAAEU,CAAC,GAAGT,UAAU,CAAC;MACpE,CAAE;MACFM,UAAU,EAAEA,UAAW;MACvBD,UAAU,EAAEA;IAAW,CACxB,CACF;EAAA,CACG,CAAC;AAEX;AAEA,eAAetB,SAAS","ignoreList":[]}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import { Skia } from "@shopify/react-native-skia";
|
|
4
4
|
import { useMemo, useState } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { getPaddings } from "../common.js";
|
|
6
6
|
import { isDefined } from "../../util/util.js";
|
|
7
7
|
function useAreaChart({
|
|
8
8
|
data,
|
|
9
9
|
xLabels,
|
|
10
10
|
maxValue,
|
|
11
11
|
minValue,
|
|
12
|
-
style
|
|
12
|
+
style,
|
|
13
|
+
yLabels
|
|
13
14
|
}) {
|
|
14
15
|
const height = style?.height ?? 200;
|
|
15
16
|
const width = style?.width ?? 200;
|
|
@@ -20,13 +21,12 @@ function useAreaChart({
|
|
|
20
21
|
paddingVertical
|
|
21
22
|
} = getPaddings(style);
|
|
22
23
|
const canvasHeight = height - paddingVertical;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
} = getCommonStyleFont(style);
|
|
24
|
+
const [verticalLabelWidth, setVerticalLabelWidth] = useState(style?.verticalLabelStyle?.width ?? 0);
|
|
25
|
+
const strokeWidth = style?.strokeWidth ?? 2;
|
|
26
|
+
const verticalLabelStrokeWidth = style?.verticalLabelStyle?.strokeWidth ?? strokeWidth;
|
|
27
|
+
const chartWidth = width - verticalLabelWidth - paddingHorizontal;
|
|
28
|
+
const [horizontalLabelHeight, setHorizontalLabelHeight] = useState(20);
|
|
29
|
+
const areaCanvasHeight = canvasHeight - horizontalLabelHeight;
|
|
30
30
|
const {
|
|
31
31
|
maxValueCalculated,
|
|
32
32
|
minValueCalculated
|
|
@@ -93,7 +93,7 @@ function useAreaChart({
|
|
|
93
93
|
const labels = xLabels.map((label, i) => {
|
|
94
94
|
return {
|
|
95
95
|
label,
|
|
96
|
-
xPosition: i * stepX
|
|
96
|
+
xPosition: i * stepX
|
|
97
97
|
};
|
|
98
98
|
});
|
|
99
99
|
return labels;
|
|
@@ -114,7 +114,7 @@ function useAreaChart({
|
|
|
114
114
|
const values = paths.map(path => path.values[xIndex]);
|
|
115
115
|
setTouchLine({
|
|
116
116
|
col: xIndex,
|
|
117
|
-
x: xIndex * stepX,
|
|
117
|
+
x: xIndex * stepX + verticalLabelWidth,
|
|
118
118
|
y: yValues,
|
|
119
119
|
values
|
|
120
120
|
});
|
|
@@ -127,12 +127,16 @@ function useAreaChart({
|
|
|
127
127
|
paddingTop,
|
|
128
128
|
paddingHorizontal,
|
|
129
129
|
areaCanvasHeight,
|
|
130
|
-
|
|
130
|
+
strokeWidth,
|
|
131
|
+
verticalLabelStrokeWidth,
|
|
132
|
+
yLabels,
|
|
133
|
+
verticalLabelWidth,
|
|
134
|
+
setVerticalLabelWidth,
|
|
131
135
|
maxValue: maxValueCalculated,
|
|
132
136
|
minValue: minValueCalculated,
|
|
133
137
|
xLabelsData,
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
horizontalLabelHeight,
|
|
139
|
+
setHorizontalLabelHeight,
|
|
136
140
|
touchHandler,
|
|
137
141
|
touchLine
|
|
138
142
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Skia","useMemo","useState","
|
|
1
|
+
{"version":3,"names":["Skia","useMemo","useState","getPaddings","isDefined","useAreaChart","data","xLabels","maxValue","minValue","style","yLabels","height","width","paddingLeft","paddingTop","paddingHorizontal","paddingVertical","canvasHeight","verticalLabelWidth","setVerticalLabelWidth","verticalLabelStyle","strokeWidth","verticalLabelStrokeWidth","chartWidth","horizontalLabelHeight","setHorizontalLabelHeight","areaCanvasHeight","maxValueCalculated","minValueCalculated","Number","MIN_VALUE","MAX_VALUE","forEach","datum","values","value","paths","pathData","areaData","stepX","length","p","Path","Make","moveTo","points","y","i","xPos","yPos","Math","max","push","x","lineTo","close","path","color","label","xLabelsData","labels","map","xPosition","touchLine","setTouchLine","undefined","touchHandler","touchedX","touchedY","xIndex","round","yValues","col"],"sourceRoot":"../../../../src","sources":["skia/AreaChart/useAreaChart.ts"],"mappings":";;AAAA,SAASA,IAAI,QAAqB,4BAA4B;AAC9D,SAASC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;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B,WAAW;IACXnC,qBAAqB;IACrBC,wBAAwB;IACxByC,YAAY;IACZH;EACD,CAAC;AACF;AAEA,eAAe3D,YAAY","ignoreList":[]}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
-
import { GestureDetector, Gesture, GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
6
|
-
import { Canvas, Rect,
|
|
5
|
+
import { GestureDetector, Gesture, GestureHandlerRootView, ScrollView } from 'react-native-gesture-handler';
|
|
6
|
+
import { Canvas, Rect, vec, LinearGradient, Group, rect as SKRect } from '@shopify/react-native-skia';
|
|
7
7
|
import useBarChart from "./useBarChart.js";
|
|
8
|
-
import VerticalLabel from "../Common/VerticalLabel.js";
|
|
9
8
|
import Popup from "../Popup.js";
|
|
10
|
-
import
|
|
11
|
-
|
|
9
|
+
import VerticalLabelView from "../Common/VerticalLabelView.js";
|
|
10
|
+
import HorizontalLabelView from "../Common/HorizontalLabelView.js";
|
|
11
|
+
import { useDerivedValue } from "react-native-reanimated";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
function BarChart({
|
|
14
|
+
xLabelView,
|
|
15
|
+
yLabelView,
|
|
16
|
+
yLabelSkiaView,
|
|
17
|
+
barSkiaView,
|
|
18
|
+
onSelectBarSkiaView,
|
|
19
|
+
onSelectBarView,
|
|
20
|
+
...props
|
|
21
|
+
}) {
|
|
12
22
|
const {
|
|
13
23
|
maxValueCalculated,
|
|
14
24
|
minValueCalculated,
|
|
15
|
-
|
|
25
|
+
yLabels,
|
|
16
26
|
canvasWidth,
|
|
17
27
|
paddingRight,
|
|
18
28
|
paddingLeft,
|
|
@@ -20,31 +30,53 @@ function BarChart(props) {
|
|
|
20
30
|
paddingTop,
|
|
21
31
|
rectangles,
|
|
22
32
|
verticalLabelWidth,
|
|
33
|
+
setVerticalLabelWidth,
|
|
23
34
|
chartHeight,
|
|
24
|
-
strokeWidth,
|
|
25
35
|
tooltip,
|
|
26
|
-
|
|
27
|
-
font,
|
|
36
|
+
setBottomLabelHeight,
|
|
28
37
|
onScroll,
|
|
29
38
|
touchHandler,
|
|
30
39
|
totalHeight,
|
|
31
|
-
totalWidth
|
|
40
|
+
totalWidth,
|
|
41
|
+
horizontalStrokeWidth,
|
|
42
|
+
startX,
|
|
43
|
+
offset
|
|
32
44
|
} = useBarChart(props);
|
|
33
|
-
const
|
|
45
|
+
const panGestureRef = useRef(Gesture.Pan());
|
|
46
|
+
const panGesture = Gesture.Pan().onChange(event => {
|
|
34
47
|
onScroll(-event.changeX);
|
|
48
|
+
}).withRef(panGestureRef);
|
|
49
|
+
const tapGesture = Gesture.Tap().runOnJS(true).onStart(event => {
|
|
50
|
+
touchHandler(event.x, event.y);
|
|
35
51
|
});
|
|
36
52
|
const [viewOffset, setViewOffset] = useState({
|
|
37
53
|
x: 0,
|
|
38
54
|
y: 0
|
|
39
55
|
});
|
|
56
|
+
const canvasGestures = Gesture.Exclusive(panGesture, tapGesture);
|
|
57
|
+
const onSelectBarViewMemo = useMemo(() => {
|
|
58
|
+
if (tooltip === undefined) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return onSelectBarView?.(tooltip.data, tooltip.xLabel);
|
|
62
|
+
}, [tooltip]);
|
|
63
|
+
const onSelectBarSkiaViewMemo = useMemo(() => {
|
|
64
|
+
if (tooltip === undefined) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return onSelectBarSkiaView?.(tooltip.rect, tooltip.data, tooltip.xLabel);
|
|
68
|
+
}, [tooltip]);
|
|
69
|
+
const canvasGroupTranslate = useDerivedValue(() => [{
|
|
70
|
+
translateX: -offset.value
|
|
71
|
+
}], []);
|
|
40
72
|
return /*#__PURE__*/_jsx(GestureHandlerRootView, {
|
|
41
73
|
children: /*#__PURE__*/_jsxs(View, {
|
|
42
74
|
style: {
|
|
43
75
|
width: totalWidth,
|
|
44
|
-
flexDirection: '
|
|
76
|
+
flexDirection: 'column',
|
|
45
77
|
backgroundColor: props.style?.backgroundColor,
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
paddingStart: paddingLeft,
|
|
79
|
+
paddingEnd: paddingRight,
|
|
48
80
|
paddingTop: paddingTop,
|
|
49
81
|
paddingBottom: paddingBottom
|
|
50
82
|
},
|
|
@@ -61,64 +93,119 @@ function BarChart(props) {
|
|
|
61
93
|
});
|
|
62
94
|
});
|
|
63
95
|
},
|
|
64
|
-
children: [/*#__PURE__*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
labelCount: 6,
|
|
68
|
-
styles: {
|
|
69
|
-
width: verticalLabelWidth,
|
|
96
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
97
|
+
style: {
|
|
98
|
+
flexDirection: "row",
|
|
70
99
|
height: chartHeight,
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
padding: 0
|
|
101
|
+
},
|
|
102
|
+
children: [(yLabelView || yLabelSkiaView) && /*#__PURE__*/_jsx(VerticalLabelView, {
|
|
103
|
+
onLayout: event => {
|
|
104
|
+
setVerticalLabelWidth(event.nativeEvent.layout.width);
|
|
105
|
+
},
|
|
106
|
+
labelPercentages: yLabels,
|
|
107
|
+
styles: {
|
|
108
|
+
height: chartHeight + horizontalStrokeWidth,
|
|
109
|
+
verticalLabelStyle: props.style?.verticalLabelStyle
|
|
110
|
+
},
|
|
111
|
+
labelSkiaView: (percentage, yPosition) => yLabelSkiaView?.(percentage, yPosition),
|
|
112
|
+
children: percentage => yLabelView?.(percentage, minValueCalculated, maxValueCalculated)
|
|
113
|
+
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
114
|
+
horizontal: true,
|
|
115
|
+
simultaneousHandlers: panGestureRef,
|
|
76
116
|
style: {
|
|
77
|
-
|
|
78
|
-
height: canvasHeight,
|
|
79
|
-
paddingRight: 50,
|
|
80
|
-
backgroundColor: 'red'
|
|
117
|
+
padding: 0
|
|
81
118
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
children: /*#__PURE__*/_jsx(GestureDetector, {
|
|
120
|
+
gesture: canvasGestures,
|
|
121
|
+
children: /*#__PURE__*/_jsxs(Canvas, {
|
|
122
|
+
style: {
|
|
123
|
+
width: canvasWidth,
|
|
124
|
+
height: chartHeight
|
|
125
|
+
},
|
|
126
|
+
children: [/*#__PURE__*/_jsx(Group, {
|
|
127
|
+
transform: canvasGroupTranslate,
|
|
128
|
+
children: rectangles.map((bar, xIndex) => {
|
|
129
|
+
if (bar.bars.length === 0) return null;
|
|
130
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
131
|
+
children: bar.bars.map(({
|
|
132
|
+
rect,
|
|
133
|
+
stackValue
|
|
134
|
+
}, yIndex) => {
|
|
135
|
+
let skiaView = barSkiaView?.(SKRect(rect.x, rect.y, rect.width, rect.height), stackValue, bar.label);
|
|
136
|
+
if (skiaView !== undefined) {
|
|
137
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
138
|
+
children: skiaView
|
|
139
|
+
}, xIndex + "-" + yIndex);
|
|
140
|
+
}
|
|
141
|
+
let currentData = props.data[xIndex].values[yIndex];
|
|
142
|
+
let color = props?.colors?.[currentData.id ?? currentData.label];
|
|
143
|
+
return /*#__PURE__*/_jsx(Rect, {
|
|
144
|
+
x: rect.x,
|
|
145
|
+
y: rect.y,
|
|
146
|
+
width: rect.width,
|
|
147
|
+
height: rect.height,
|
|
148
|
+
color: Array.isArray(color) ? undefined : color,
|
|
149
|
+
children: Array.isArray(color) && /*#__PURE__*/_jsx(LinearGradient, {
|
|
150
|
+
start: vec(rect.x, rect.y),
|
|
151
|
+
end: vec(rect.x + rect.width, rect.y + rect.height),
|
|
152
|
+
colors: color
|
|
153
|
+
})
|
|
154
|
+
}, xIndex + '-' + yIndex);
|
|
155
|
+
})
|
|
156
|
+
}, xIndex);
|
|
157
|
+
})
|
|
158
|
+
}), onSelectBarSkiaViewMemo]
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
})]
|
|
162
|
+
}), xLabelView && /*#__PURE__*/_jsx(HorizontalLabelView, {
|
|
163
|
+
labels: rectangles.map(bar => bar.label),
|
|
164
|
+
positions: rectangles.map(bar => bar.x),
|
|
165
|
+
transform: canvasGroupTranslate,
|
|
166
|
+
xOffset: offset,
|
|
167
|
+
style: {
|
|
168
|
+
left: verticalLabelWidth,
|
|
169
|
+
width: canvasWidth,
|
|
170
|
+
horizontalLabelStyle: props.style?.horizontalLabelStyle
|
|
116
171
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
172
|
+
onLayout: event => setBottomLabelHeight(event.nativeEvent.layout.height),
|
|
173
|
+
children: (_index, data) => xLabelView(data)
|
|
174
|
+
}), tooltip && /*#__PURE__*/_jsxs(_Fragment, {
|
|
175
|
+
children: [onSelectBarViewMemo && /*#__PURE__*/_jsx(View, {
|
|
176
|
+
style: {
|
|
177
|
+
position: "absolute",
|
|
178
|
+
top: tooltip.rect.y + paddingTop,
|
|
179
|
+
left: verticalLabelWidth + paddingLeft + Math.max(0, tooltip.rect.x),
|
|
180
|
+
width: tooltip.rect.width,
|
|
181
|
+
height: tooltip.rect.height,
|
|
182
|
+
overflow: "hidden"
|
|
183
|
+
},
|
|
184
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
185
|
+
style: {
|
|
186
|
+
position: "relative",
|
|
187
|
+
top: 0,
|
|
188
|
+
left: -Math.max(0, -tooltip.rect.x),
|
|
189
|
+
width: tooltip.rect.width,
|
|
190
|
+
height: tooltip.rect.height
|
|
191
|
+
},
|
|
192
|
+
children: onSelectBarViewMemo
|
|
193
|
+
})
|
|
194
|
+
}), /*#__PURE__*/_jsx(Popup, {
|
|
195
|
+
popupData: {
|
|
196
|
+
x: tooltip.centerX,
|
|
197
|
+
y: tooltip.centerY,
|
|
198
|
+
data: tooltip.data
|
|
199
|
+
},
|
|
200
|
+
popupStyle: props.popupStyle,
|
|
201
|
+
totalWidth: totalWidth,
|
|
202
|
+
totalHeight: totalHeight,
|
|
203
|
+
touchHandler: (x, y) => {
|
|
204
|
+
touchHandler(x - verticalLabelWidth - paddingLeft, y);
|
|
205
|
+
},
|
|
206
|
+
onTouchOutside: () => touchHandler(-1, -1),
|
|
207
|
+
viewOffset: viewOffset
|
|
208
|
+
})]
|
|
122
209
|
})]
|
|
123
210
|
})
|
|
124
211
|
});
|