@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
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type CommonStyle } from '../common';
|
|
2
|
-
interface VerticalLabelStyles extends CommonStyle {
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
strokeWidth?: number;
|
|
6
|
-
strokeColor?: string;
|
|
7
|
-
textColor?: string;
|
|
8
|
-
}
|
|
9
|
-
interface VerticalLabelProps {
|
|
10
|
-
minValue: number;
|
|
11
|
-
maxValue: number;
|
|
12
|
-
labelCount: number;
|
|
13
|
-
styles: VerticalLabelStyles;
|
|
14
|
-
}
|
|
15
|
-
declare function VerticalLabel({ minValue, maxValue, labelCount, styles, }: VerticalLabelProps): import("react").JSX.Element;
|
|
16
|
-
export default VerticalLabel;
|
|
17
|
-
//# sourceMappingURL=VerticalLabel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalLabel.d.ts","sourceRoot":"","sources":["../../../../../src/skia/Common/VerticalLabel.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtD,UAAU,mBAAoB,SAAQ,WAAW;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,iBAAS,aAAa,CAAC,EACrB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,MAAM,GACP,EAAE,kBAAkB,+BAiEpB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Canvas, Line, Text, Skia } from '@shopify/react-native-skia';
|
|
2
|
-
import { getFont, type CommonStyle } from '../common';
|
|
3
|
-
|
|
4
|
-
interface VerticalLabelStyles extends CommonStyle {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
strokeWidth?: number;
|
|
8
|
-
strokeColor?: string;
|
|
9
|
-
textColor?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface VerticalLabelProps {
|
|
13
|
-
minValue: number;
|
|
14
|
-
maxValue: number;
|
|
15
|
-
labelCount: number;
|
|
16
|
-
styles: VerticalLabelStyles;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function VerticalLabel({
|
|
20
|
-
minValue,
|
|
21
|
-
maxValue,
|
|
22
|
-
labelCount,
|
|
23
|
-
styles,
|
|
24
|
-
}: VerticalLabelProps) {
|
|
25
|
-
const {
|
|
26
|
-
width,
|
|
27
|
-
height,
|
|
28
|
-
strokeWidth = 2,
|
|
29
|
-
strokeColor = 'white',
|
|
30
|
-
textColor = 'white',
|
|
31
|
-
paddingTop = 0,
|
|
32
|
-
paddingRight = 0,
|
|
33
|
-
paddingBottom = 0,
|
|
34
|
-
paddingLeft = 0,
|
|
35
|
-
fontSize = 12,
|
|
36
|
-
backgroundColor,
|
|
37
|
-
} = styles;
|
|
38
|
-
|
|
39
|
-
// Generate evenly spaced values
|
|
40
|
-
const stepValue =
|
|
41
|
-
labelCount > 1 ? (maxValue - minValue) / (labelCount - 1) : 0;
|
|
42
|
-
const labels = Array.from(
|
|
43
|
-
{ length: labelCount },
|
|
44
|
-
(_, i) => minValue + i * stepValue
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const font = getFont(fontSize);
|
|
48
|
-
|
|
49
|
-
const usableHeight = height - paddingTop - paddingBottom - fontSize;
|
|
50
|
-
const stepY = labelCount > 1 ? usableHeight / (labelCount - 1) : 0;
|
|
51
|
-
|
|
52
|
-
// Precompute text paint
|
|
53
|
-
const paint = Skia.Paint();
|
|
54
|
-
paint.setColor(Skia.Color(textColor));
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Canvas style={{ width, height, backgroundColor }}>
|
|
58
|
-
<Line
|
|
59
|
-
p1={{ x: width - paddingRight - strokeWidth / 2, y: paddingTop }}
|
|
60
|
-
p2={{
|
|
61
|
-
x: width - paddingRight - strokeWidth / 2,
|
|
62
|
-
y: height - paddingBottom,
|
|
63
|
-
}}
|
|
64
|
-
color={strokeColor}
|
|
65
|
-
strokeWidth={strokeWidth}
|
|
66
|
-
/>
|
|
67
|
-
|
|
68
|
-
{labels.map((label, i) => {
|
|
69
|
-
const y = height - paddingBottom - stepY * i;
|
|
70
|
-
const text = label.toFixed(0);
|
|
71
|
-
|
|
72
|
-
// measure text width for right-align
|
|
73
|
-
const textWidth = font.measureText(text).width;
|
|
74
|
-
const x = width - paddingRight - strokeWidth - 4 - textWidth;
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<Text
|
|
78
|
-
key={i}
|
|
79
|
-
x={x}
|
|
80
|
-
y={y}
|
|
81
|
-
text={text}
|
|
82
|
-
font={font}
|
|
83
|
-
color={textColor}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
})}
|
|
87
|
-
</Canvas>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export default VerticalLabel;
|