@bashem/rn-charts 0.0.2
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/LICENSE +20 -0
- package/README.md +35 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/skia/AreaChart/AreaChart.js +122 -0
- package/lib/module/skia/AreaChart/AreaChart.js.map +1 -0
- package/lib/module/skia/AreaChart/useAreaChart.js +141 -0
- package/lib/module/skia/AreaChart/useAreaChart.js.map +1 -0
- package/lib/module/skia/BarChart/BarChart.js +127 -0
- package/lib/module/skia/BarChart/BarChart.js.map +1 -0
- package/lib/module/skia/BarChart/useBarChart.js +172 -0
- package/lib/module/skia/BarChart/useBarChart.js.map +1 -0
- package/lib/module/skia/Common/VerticalLabel.js +73 -0
- package/lib/module/skia/Common/VerticalLabel.js.map +1 -0
- package/lib/module/skia/HeatMap/HeatMap.js +76 -0
- package/lib/module/skia/HeatMap/HeatMap.js.map +1 -0
- package/lib/module/skia/HeatMap/useHeatMap.js +139 -0
- package/lib/module/skia/HeatMap/useHeatMap.js.map +1 -0
- package/lib/module/skia/PieChart/PieChart.js +96 -0
- package/lib/module/skia/PieChart/PieChart.js.map +1 -0
- package/lib/module/skia/PieChart/usePieChart.js +103 -0
- package/lib/module/skia/PieChart/usePieChart.js.map +1 -0
- package/lib/module/skia/Popup.js +58 -0
- package/lib/module/skia/Popup.js.map +1 -0
- package/lib/module/skia/Progress/LinearProgress.js +69 -0
- package/lib/module/skia/Progress/LinearProgress.js.map +1 -0
- package/lib/module/skia/Progress/SemiCircleProgress.js +70 -0
- package/lib/module/skia/Progress/SemiCircleProgress.js.map +1 -0
- package/lib/module/skia/RadarChart/RadarChart.js +98 -0
- package/lib/module/skia/RadarChart/RadarChart.js.map +1 -0
- package/lib/module/skia/RadarChart/useRadarChart.js +164 -0
- package/lib/module/skia/RadarChart/useRadarChart.js.map +1 -0
- package/lib/module/skia/common.js +65 -0
- package/lib/module/skia/common.js.map +1 -0
- package/lib/module/util/colors.js +182 -0
- package/lib/module/util/colors.js.map +1 -0
- package/lib/module/util/util.js +71 -0
- package/lib/module/util/util.js.map +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +10 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/skia/AreaChart/AreaChart.d.ts +25 -0
- package/lib/typescript/src/skia/AreaChart/AreaChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/AreaChart/useAreaChart.d.ts +47 -0
- package/lib/typescript/src/skia/AreaChart/useAreaChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/BarChart/BarChart.d.ts +30 -0
- package/lib/typescript/src/skia/BarChart/BarChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/BarChart/useBarChart.d.ts +41 -0
- package/lib/typescript/src/skia/BarChart/useBarChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/Common/VerticalLabel.d.ts +17 -0
- package/lib/typescript/src/skia/Common/VerticalLabel.d.ts.map +1 -0
- package/lib/typescript/src/skia/HeatMap/HeatMap.d.ts +33 -0
- package/lib/typescript/src/skia/HeatMap/HeatMap.d.ts.map +1 -0
- package/lib/typescript/src/skia/HeatMap/useHeatMap.d.ts +25 -0
- package/lib/typescript/src/skia/HeatMap/useHeatMap.d.ts.map +1 -0
- package/lib/typescript/src/skia/PieChart/PieChart.d.ts +27 -0
- package/lib/typescript/src/skia/PieChart/PieChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/PieChart/usePieChart.d.ts +13 -0
- package/lib/typescript/src/skia/PieChart/usePieChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/Popup.d.ts +26 -0
- package/lib/typescript/src/skia/Popup.d.ts.map +1 -0
- package/lib/typescript/src/skia/Progress/LinearProgress.d.ts +18 -0
- package/lib/typescript/src/skia/Progress/LinearProgress.d.ts.map +1 -0
- package/lib/typescript/src/skia/Progress/SemiCircleProgress.d.ts +18 -0
- package/lib/typescript/src/skia/Progress/SemiCircleProgress.d.ts.map +1 -0
- package/lib/typescript/src/skia/RadarChart/RadarChart.d.ts +27 -0
- package/lib/typescript/src/skia/RadarChart/RadarChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/RadarChart/useRadarChart.d.ts +41 -0
- package/lib/typescript/src/skia/RadarChart/useRadarChart.d.ts.map +1 -0
- package/lib/typescript/src/skia/common.d.ts +31 -0
- package/lib/typescript/src/skia/common.d.ts.map +1 -0
- package/lib/typescript/src/util/colors.d.ts +4 -0
- package/lib/typescript/src/util/colors.d.ts.map +1 -0
- package/lib/typescript/src/util/util.d.ts +33 -0
- package/lib/typescript/src/util/util.d.ts.map +1 -0
- package/package.json +172 -0
- package/src/index.tsx +12 -0
- package/src/skia/AreaChart/AreaChart.tsx +140 -0
- package/src/skia/AreaChart/useAreaChart.ts +180 -0
- package/src/skia/BarChart/BarChart.tsx +190 -0
- package/src/skia/BarChart/useBarChart.ts +210 -0
- package/src/skia/Common/VerticalLabel.tsx +91 -0
- package/src/skia/HeatMap/HeatMap.tsx +106 -0
- package/src/skia/HeatMap/useHeatMap.ts +175 -0
- package/src/skia/PieChart/PieChart.tsx +114 -0
- package/src/skia/PieChart/usePieChart.ts +156 -0
- package/src/skia/Popup.tsx +125 -0
- package/src/skia/Progress/LinearProgress.tsx +84 -0
- package/src/skia/Progress/SemiCircleProgress.tsx +82 -0
- package/src/skia/RadarChart/RadarChart.tsx +159 -0
- package/src/skia/RadarChart/useRadarChart.ts +208 -0
- package/src/skia/common.ts +82 -0
- package/src/util/colors.ts +186 -0
- package/src/util/util.ts +89 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommonStyle } from '../common';
|
|
2
|
+
export interface LinearProgressStyles extends CommonStyle {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
radius?: number;
|
|
6
|
+
tintColor?: string;
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
tintColors?: string[];
|
|
9
|
+
tineColorsPositions?: number[];
|
|
10
|
+
backgroundColors?: string[];
|
|
11
|
+
backgroundColorsPositions?: number[];
|
|
12
|
+
}
|
|
13
|
+
export interface LinearProgressProps {
|
|
14
|
+
style: LinearProgressStyles;
|
|
15
|
+
progress: number;
|
|
16
|
+
}
|
|
17
|
+
export default function LinearProgress({ progress, style, }: LinearProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=LinearProgress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.d.ts","sourceRoot":"","sources":["../../../../../src/skia/Progress/LinearProgress.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,KAAK,GACN,EAAE,mBAAmB,2CAqDrB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CommonStyle } from '../common';
|
|
2
|
+
export interface SemiCircleProgressStyles extends CommonStyle {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
radius?: number;
|
|
6
|
+
tintColor?: string;
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
tintColors?: string[];
|
|
9
|
+
tineColorsPositions?: number[];
|
|
10
|
+
backgroundColors?: string[];
|
|
11
|
+
backgroundColorsPositions?: number[];
|
|
12
|
+
}
|
|
13
|
+
export interface SemiCircleProgressProps {
|
|
14
|
+
style: SemiCircleProgressStyles;
|
|
15
|
+
progress: number;
|
|
16
|
+
}
|
|
17
|
+
export default function SemiCircleProgress({ progress, style, }: SemiCircleProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=SemiCircleProgress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SemiCircleProgress.d.ts","sourceRoot":"","sources":["../../../../../src/skia/Progress/SemiCircleProgress.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,QAAQ,EACR,KAAK,GACN,EAAE,uBAAuB,2CAqDzB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CommonStyle } from '../common';
|
|
3
|
+
export interface RadarDatum {
|
|
4
|
+
values: number[];
|
|
5
|
+
backgroundColor?: string;
|
|
6
|
+
strokeColor?: string;
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RadarChartStyle extends CommonStyle {
|
|
10
|
+
size?: number;
|
|
11
|
+
strokeWidth?: number;
|
|
12
|
+
strokeColor?: string;
|
|
13
|
+
centerDotRadius?: number;
|
|
14
|
+
centerDotColor?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RadarChartProps {
|
|
17
|
+
data: RadarDatum[];
|
|
18
|
+
labels?: string[];
|
|
19
|
+
levels?: number;
|
|
20
|
+
labelViews?: ReactNode[];
|
|
21
|
+
maxValue?: number;
|
|
22
|
+
minValue?: number;
|
|
23
|
+
style?: RadarChartStyle;
|
|
24
|
+
}
|
|
25
|
+
declare function RadarChart(props: RadarChartProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export default RadarChart;
|
|
27
|
+
//# sourceMappingURL=RadarChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadarChart.d.ts","sourceRoot":"","sources":["../../../../../src/skia/RadarChart/RadarChart.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAcrE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAkHzC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type SkPath } from "@shopify/react-native-skia";
|
|
2
|
+
import type { RadarChartProps } from "./RadarChart";
|
|
3
|
+
export interface RadarDatum {
|
|
4
|
+
values: number[];
|
|
5
|
+
backgroundColor?: string;
|
|
6
|
+
strokeColor?: string;
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
}
|
|
9
|
+
export default function useRadarChart({ data, labels, labelViews, levels, maxValue, minValue, style, }: RadarChartProps): {
|
|
10
|
+
size: number;
|
|
11
|
+
cx: number;
|
|
12
|
+
cy: number;
|
|
13
|
+
radius: number;
|
|
14
|
+
safeMax: number;
|
|
15
|
+
angles: number[];
|
|
16
|
+
gridPaths: SkPath[];
|
|
17
|
+
axisPaths: SkPath[];
|
|
18
|
+
dataPaths: {
|
|
19
|
+
backgroundColor?: string;
|
|
20
|
+
strokeColor?: string;
|
|
21
|
+
strokeWidth?: number;
|
|
22
|
+
path: SkPath;
|
|
23
|
+
}[];
|
|
24
|
+
formattedLabels: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
label: string;
|
|
28
|
+
align: "left" | "center" | "right";
|
|
29
|
+
}[] | undefined;
|
|
30
|
+
formattedLabelViews: {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
view: React.ReactNode;
|
|
34
|
+
align: "left" | "center" | "right";
|
|
35
|
+
}[] | undefined;
|
|
36
|
+
strokeWidth: number;
|
|
37
|
+
strokeColor: string;
|
|
38
|
+
centerDotRadius: number;
|
|
39
|
+
centerDotColor: string;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useRadarChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRadarChart.d.ts","sourceRoot":"","sources":["../../../../../src/skia/RadarChart/useRadarChart.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,IAAI,EACJ,MAAM,EACN,UAAU,EACV,MAAU,EACV,QAAQ,EACR,QAAY,EACZ,KAAK,GACN,EAAE,eAAe;;;;;;;;;;;;;;;;WA4FT,MAAM;WACN,MAAM;eACF,MAAM;eACN,MAAM,GAAG,QAAQ,GAAG,OAAO;;;WAkC/B,MAAM;WACN,MAAM;cACH,KAAK,CAAC,SAAS;eACd,MAAM,GAAG,QAAQ,GAAG,OAAO;;;;;;EA4CvC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type SkFont } from "@shopify/react-native-skia";
|
|
2
|
+
export interface CommonStyle {
|
|
3
|
+
padding?: number;
|
|
4
|
+
paddingTop?: number;
|
|
5
|
+
paddingBottom?: number;
|
|
6
|
+
paddingStart?: number;
|
|
7
|
+
paddingEnd?: number;
|
|
8
|
+
paddingLeft?: number;
|
|
9
|
+
paddingRight?: number;
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
disableRTL?: boolean;
|
|
12
|
+
font?: SkFont;
|
|
13
|
+
fontSize?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function getCommonStyleFont(style?: CommonStyle): {
|
|
16
|
+
font: SkFont;
|
|
17
|
+
fontSize: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function getPaddings(style?: CommonStyle): {
|
|
20
|
+
paddingTop: number;
|
|
21
|
+
paddingBottom: number;
|
|
22
|
+
paddingLeft: number;
|
|
23
|
+
paddingRight: number;
|
|
24
|
+
paddingHorizontal: number;
|
|
25
|
+
paddingVertical: number;
|
|
26
|
+
};
|
|
27
|
+
export declare function getRandomRGBColor(): string;
|
|
28
|
+
export declare const systemFontFamilies: string[];
|
|
29
|
+
export declare function getFont(size?: number): SkFont;
|
|
30
|
+
export declare const font: SkFont;
|
|
31
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/skia/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,KAAK,MAAM,EAAsC,MAAM,4BAA4B,CAAC;AAG3I,MAAM,WAAW,WAAW;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,WAAW;;;EAIrD;AAED,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,WAAW;;;;;;;EAgB9C;AAED,wBAAgB,iBAAiB,WAKhC;AAED,eAAO,MAAM,kBAAkB,UAI7B,CAAC;AAEH,wBAAgB,OAAO,CAAC,IAAI,GAAE,MAAW,GAAG,MAAM,CAWjD;AAED,eAAO,MAAM,IAAI,QAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../../src/util/colors.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAqJnE,CAAC;AAEF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAmB9D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAY7D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare function arrayFrom(maxValue: number, interval: number): number[];
|
|
3
|
+
export declare const stringToArray: (s: string, separator: string) => string[];
|
|
4
|
+
export declare const increment: (char: string, by: number) => string;
|
|
5
|
+
export declare const getRandomInteger: (min: number, max: number) => number;
|
|
6
|
+
export declare const parseQuery: (queryString: string) => Record<string, string>;
|
|
7
|
+
export declare const processNumber: (num: number, min: number, max: number) => number;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {number} value - The number.
|
|
11
|
+
* @param {Intl.NumberFormatOptions} options - The options.
|
|
12
|
+
* Default Value: { maximumFractionDigits: 2, minimumFractionDigits: 0 }
|
|
13
|
+
* @returns {string} Returns the number in as formatted string.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const result = getFormattedString(3.012)
|
|
17
|
+
* console.log(result); // 3.01
|
|
18
|
+
*/
|
|
19
|
+
export declare function getFormattedString(value: number, options?: Intl.NumberFormatOptions): string;
|
|
20
|
+
export declare function isNumber<T>(value: T | number): value is number;
|
|
21
|
+
export declare function isNonNANNumber<T>(value: T | number): value is number;
|
|
22
|
+
export declare function isStringNumber(value: string): boolean;
|
|
23
|
+
export declare function isDefined<T>(value: T | undefined | null): value is T;
|
|
24
|
+
export declare function isFunction(value: any): value is Function;
|
|
25
|
+
export declare function isString(node: ReactNode): node is string;
|
|
26
|
+
type ArrayLengthMutationKeys = 'splice' | 'push' | 'pop' | 'shift' | 'unshift';
|
|
27
|
+
export type FixedLengthArray<T, L extends number, TObj = [T, ...Array<T>]> = Pick<TObj, Exclude<keyof TObj, ArrayLengthMutationKeys>> & {
|
|
28
|
+
readonly length: L;
|
|
29
|
+
[I: number]: T;
|
|
30
|
+
[Symbol.iterator]: () => IterableIterator<T>;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/util/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtE;AAED,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,WAAW,MAAM,KAAG,MAAM,EAElE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,WAEjD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,WAExD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,aAAa,MAAM,2BAW7C,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,MAAM,KACV,MAKF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,mBAA4E,UAE3I;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,GAAG,KAAK,IAAI,MAAM,CAEpE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC,CAEpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAExD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,IAAI,MAAM,CAExD;AAED,KAAK,uBAAuB,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAI,SAAS,CAAA;AAC/E,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IACvE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,uBAAuB,CAAC,CAAC,GACtD;IACA,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAClB,CAAE,CAAC,EAAG,MAAM,GAAK,CAAC,CAAA;IAClB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,gBAAgB,CAAC,CAAC,CAAC,CAAA;CAC7C,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bashem/rn-charts",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Experimental Charts Library",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"ios",
|
|
8
|
+
"android"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/mbashem/rn-charts#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/mbashem/rn-charts/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/mbashem/rn-charts.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Bashem <example@github.com> (https://github.com/mbashem)",
|
|
20
|
+
"type": "commonjs",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"source": "./src/index.tsx",
|
|
24
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
25
|
+
"default": "./lib/module/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"main": "./lib/module/index.js",
|
|
30
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
31
|
+
"directories": {
|
|
32
|
+
"example": "example",
|
|
33
|
+
"lib": "lib"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"src",
|
|
37
|
+
"lib",
|
|
38
|
+
"android",
|
|
39
|
+
"ios",
|
|
40
|
+
"cpp",
|
|
41
|
+
"*.podspec",
|
|
42
|
+
"react-native.config.js",
|
|
43
|
+
"!ios/build",
|
|
44
|
+
"!android/build",
|
|
45
|
+
"!android/gradle",
|
|
46
|
+
"!android/gradlew",
|
|
47
|
+
"!android/gradlew.bat",
|
|
48
|
+
"!android/local.properties",
|
|
49
|
+
"!**/__tests__",
|
|
50
|
+
"!**/__fixtures__",
|
|
51
|
+
"!**/__mocks__",
|
|
52
|
+
"!**/.*"
|
|
53
|
+
],
|
|
54
|
+
"workspaces": [
|
|
55
|
+
"example"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"example": "yarn workspace rn-charts-example",
|
|
59
|
+
"test": "jest",
|
|
60
|
+
"typecheck": "tsc",
|
|
61
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
62
|
+
"clean": "del-cli lib",
|
|
63
|
+
"prepare": "bob build",
|
|
64
|
+
"release": "release-it --only-version"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@shopify/react-native-skia": "v2.0.0-next.4",
|
|
68
|
+
"react-native-gesture-handler": "^2.28.0",
|
|
69
|
+
"react-native-reanimated": "^3.19.5",
|
|
70
|
+
"react-native-worklets": "^0.4.2",
|
|
71
|
+
"react": "19.0.0",
|
|
72
|
+
"react-native": "0.79.6"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
76
|
+
"@eslint/compat": "^1.2.7",
|
|
77
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
78
|
+
"@eslint/js": "^9.22.0",
|
|
79
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
80
|
+
"@react-native/babel-preset": "0.78.2",
|
|
81
|
+
"@react-native/eslint-config": "^0.78.0",
|
|
82
|
+
"@release-it/conventional-changelog": "^10.0.4",
|
|
83
|
+
"@types/jest": "^29.5.5",
|
|
84
|
+
"@types/react": "^19.0.12",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
|
86
|
+
"commitlint": "^19.6.1",
|
|
87
|
+
"del-cli": "^5.1.0",
|
|
88
|
+
"eslint": "^9.22.0",
|
|
89
|
+
"eslint-config-prettier": "^10.1.1",
|
|
90
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
91
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
92
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
93
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
94
|
+
"eslint-plugin-react-native": "^5.0.0",
|
|
95
|
+
"jest": "^29.7.0",
|
|
96
|
+
"prettier": "^3.6.2",
|
|
97
|
+
"react-native-builder-bob": "^0.40.13",
|
|
98
|
+
"release-it": "^19.2.2",
|
|
99
|
+
"typescript": "^5.8.3"
|
|
100
|
+
},
|
|
101
|
+
"peerDependencies": {
|
|
102
|
+
"react": "^19.0.0",
|
|
103
|
+
"react-native": "^0.79.5"
|
|
104
|
+
},
|
|
105
|
+
"publishConfig": {
|
|
106
|
+
"registry": "https://registry.npmjs.org/",
|
|
107
|
+
"access": "public"
|
|
108
|
+
},
|
|
109
|
+
"packageManager": "yarn@3.6.1",
|
|
110
|
+
"jest": {
|
|
111
|
+
"preset": "react-native",
|
|
112
|
+
"modulePathIgnorePatterns": [
|
|
113
|
+
"<rootDir>/example/node_modules",
|
|
114
|
+
"<rootDir>/lib/"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"commitlint": {
|
|
118
|
+
"extends": [
|
|
119
|
+
"@commitlint/config-conventional"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"release-it": {
|
|
123
|
+
"git": {
|
|
124
|
+
"requireCleanWorkingDir": false,
|
|
125
|
+
"commitMessage": "chore: release ${version}",
|
|
126
|
+
"tagName": "v${version}"
|
|
127
|
+
},
|
|
128
|
+
"npm": {
|
|
129
|
+
"publish": true
|
|
130
|
+
},
|
|
131
|
+
"github": {
|
|
132
|
+
"release": true
|
|
133
|
+
},
|
|
134
|
+
"plugins": {
|
|
135
|
+
"@release-it/conventional-changelog": {
|
|
136
|
+
"preset": {
|
|
137
|
+
"name": "angular"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"prettier": {
|
|
143
|
+
"quoteProps": "consistent",
|
|
144
|
+
"singleQuote": true,
|
|
145
|
+
"tabWidth": 2,
|
|
146
|
+
"trailingComma": "es5",
|
|
147
|
+
"useTabs": false
|
|
148
|
+
},
|
|
149
|
+
"react-native-builder-bob": {
|
|
150
|
+
"source": "src",
|
|
151
|
+
"output": "lib",
|
|
152
|
+
"targets": [
|
|
153
|
+
[
|
|
154
|
+
"module",
|
|
155
|
+
{
|
|
156
|
+
"esm": true
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
"typescript",
|
|
161
|
+
{
|
|
162
|
+
"project": "tsconfig.build.json"
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
"create-react-native-library": {
|
|
168
|
+
"languages": "js",
|
|
169
|
+
"type": "library",
|
|
170
|
+
"version": "0.52.0"
|
|
171
|
+
}
|
|
172
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function multiply(a: number, b: number): number {
|
|
2
|
+
return a * b;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export { default as BarChart } from './skia/BarChart/BarChart';
|
|
6
|
+
export * from './skia/BarChart/BarChart';
|
|
7
|
+
export * from './skia/PieChart/PieChart';
|
|
8
|
+
export * from './skia/AreaChart/AreaChart';
|
|
9
|
+
export * from './skia/Progress/LinearProgress';
|
|
10
|
+
export * from './skia/RadarChart/RadarChart';
|
|
11
|
+
export { default as PieChart } from './skia/PieChart/PieChart';
|
|
12
|
+
export { default as AreaChart } from './skia/AreaChart/AreaChart';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// AreaChart.tsx
|
|
2
|
+
import { Canvas, Circle, Group, Path, Text } from '@shopify/react-native-skia';
|
|
3
|
+
import { type CommonStyle } from '../common';
|
|
4
|
+
import VerticalLabel from '../Common/VerticalLabel';
|
|
5
|
+
import { View } from 'react-native';
|
|
6
|
+
import useAreaChart, { type AreaData } from './useAreaChart';
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
import { lighten } from '../../util/colors';
|
|
9
|
+
import Popup, { type PopupStyle } from '../Popup';
|
|
10
|
+
|
|
11
|
+
export interface AreaChartStyle extends CommonStyle {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
showPoints?: boolean;
|
|
15
|
+
pointRadius?: number;
|
|
16
|
+
lightenPointsBy?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AreaChartProps {
|
|
20
|
+
data: AreaData[];
|
|
21
|
+
minValue?: number;
|
|
22
|
+
maxValue?: number;
|
|
23
|
+
xLabels?: string[];
|
|
24
|
+
style?: AreaChartStyle;
|
|
25
|
+
popupStyle: PopupStyle<{ rowIndex: number; colIndex: number; value: number }>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function AreaChart(props: AreaChartProps) {
|
|
29
|
+
const {
|
|
30
|
+
minValue,
|
|
31
|
+
maxValue,
|
|
32
|
+
canvasHeight,
|
|
33
|
+
areaCanvasHeight,
|
|
34
|
+
labelWidth,
|
|
35
|
+
chartWidth,
|
|
36
|
+
paths,
|
|
37
|
+
xLabelsData,
|
|
38
|
+
paddingLeft,
|
|
39
|
+
paddingTop,
|
|
40
|
+
paddingHorizontal,
|
|
41
|
+
font,
|
|
42
|
+
touchLine,
|
|
43
|
+
touchHandler,
|
|
44
|
+
} = useAreaChart(props);
|
|
45
|
+
const { style, popupStyle } = props;
|
|
46
|
+
|
|
47
|
+
const [viewOffset, setViewOffset] = useState({ x: 0, y: 0 });
|
|
48
|
+
console.log('AreaChart render', { touchLine });
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View
|
|
52
|
+
style={[style, { flexDirection: 'row' }]}
|
|
53
|
+
ref={(view) => {
|
|
54
|
+
view?.measureInWindow((fx, fy) => {
|
|
55
|
+
setViewOffset((prev) => {
|
|
56
|
+
if (prev.x === fx && prev.y === fy) {
|
|
57
|
+
return prev;
|
|
58
|
+
}
|
|
59
|
+
return { x: fx, y: fy };
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<VerticalLabel
|
|
65
|
+
minValue={minValue}
|
|
66
|
+
maxValue={maxValue}
|
|
67
|
+
styles={{
|
|
68
|
+
height: areaCanvasHeight,
|
|
69
|
+
width: labelWidth,
|
|
70
|
+
fontSize: style?.fontSize,
|
|
71
|
+
}}
|
|
72
|
+
labelCount={5}
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
<Canvas
|
|
76
|
+
style={{
|
|
77
|
+
width: chartWidth,
|
|
78
|
+
height: canvasHeight,
|
|
79
|
+
}}
|
|
80
|
+
onTouchStart={(event) =>
|
|
81
|
+
touchHandler(event.nativeEvent.locationX, event.nativeEvent.locationY)
|
|
82
|
+
}
|
|
83
|
+
>
|
|
84
|
+
{paths.map(({ path, points, color }, index) => {
|
|
85
|
+
return (
|
|
86
|
+
<Group key={index}>
|
|
87
|
+
<Path path={path} color={color} />
|
|
88
|
+
{style?.showPoints &&
|
|
89
|
+
color &&
|
|
90
|
+
points.map((points) => (
|
|
91
|
+
<Circle
|
|
92
|
+
key={`${points.x}-${points.y}`}
|
|
93
|
+
cx={points.x}
|
|
94
|
+
cy={points.y}
|
|
95
|
+
r={style?.pointRadius ?? 3}
|
|
96
|
+
color={lighten(color, style?.lightenPointsBy ?? 0.3)}
|
|
97
|
+
/>
|
|
98
|
+
))}
|
|
99
|
+
</Group>
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
{xLabelsData.map(({ label, xPosition }, index) => {
|
|
103
|
+
return (
|
|
104
|
+
<Text
|
|
105
|
+
key={index}
|
|
106
|
+
x={xPosition}
|
|
107
|
+
y={canvasHeight}
|
|
108
|
+
text={label}
|
|
109
|
+
font={font}
|
|
110
|
+
color={'white'}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
114
|
+
</Canvas>
|
|
115
|
+
{touchLine && (
|
|
116
|
+
<Popup
|
|
117
|
+
popupData={touchLine.y.map((y, index) => ({
|
|
118
|
+
x: touchLine.x,
|
|
119
|
+
y: y,
|
|
120
|
+
data: {
|
|
121
|
+
rowIndex: index,
|
|
122
|
+
colIndex: touchLine.col,
|
|
123
|
+
value: touchLine.values[index]!,
|
|
124
|
+
},
|
|
125
|
+
}))}
|
|
126
|
+
totalWidth={chartWidth + labelWidth + paddingHorizontal}
|
|
127
|
+
totalHeight={canvasHeight}
|
|
128
|
+
touchHandler={(x, y) => {
|
|
129
|
+
console.log('Popup touchHandler', x, y);
|
|
130
|
+
touchHandler(x - labelWidth - paddingLeft, y - paddingTop);
|
|
131
|
+
}}
|
|
132
|
+
viewOffset={viewOffset}
|
|
133
|
+
popupStyle={popupStyle}
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
136
|
+
</View>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default AreaChart;
|