@impulse-ui-native/charts 2.2.0 → 2.3.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/README.md +61 -4
- package/dist/components/{bar-chart-body.d.mts → bar-chart/bar-chart-body.d.mts} +4 -4
- package/dist/components/{bar-chart-body.js → bar-chart/bar-chart-body.js} +5 -4
- package/dist/components/bar-chart/bar-chart-body.js.map +1 -0
- package/dist/components/{bar-chart.d.mts → bar-chart/bar-chart.d.mts} +4 -4
- package/dist/components/{bar-chart.js → bar-chart/bar-chart.js} +1 -1
- package/dist/components/bar-chart/bar-chart.js.map +1 -0
- package/dist/components/bar-chart/index.d.mts +8 -0
- package/dist/components/bar-chart/index.js +5 -0
- package/dist/components/bar-chart/index.js.map +1 -0
- package/dist/components/{chart-axes.d.mts → chart-axes/chart-axes.d.mts} +3 -3
- package/dist/components/{chart-axes.js → chart-axes/chart-axes.js} +1 -1
- package/dist/components/chart-axes/chart-axes.js.map +1 -0
- package/dist/components/chart-axes/index.d.mts +7 -0
- package/dist/components/chart-axes/index.js +5 -0
- package/dist/components/chart-axes/index.js.map +1 -0
- package/dist/components/index.d.mts +10 -4
- package/dist/components/index.js +5 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/line-chart/index.d.mts +7 -0
- package/dist/components/line-chart/index.js +5 -0
- package/dist/components/line-chart/index.js.map +1 -0
- package/dist/components/{line-chart-body.d.mts → line-chart/line-chart-body.d.mts} +3 -3
- package/dist/components/{line-chart-body.js → line-chart/line-chart-body.js} +5 -5
- package/dist/components/line-chart/line-chart-body.js.map +1 -0
- package/dist/components/{line-chart.d.mts → line-chart/line-chart.d.mts} +3 -3
- package/dist/components/{line-chart.js → line-chart/line-chart.js} +1 -1
- package/dist/components/line-chart/line-chart.js.map +1 -0
- package/dist/components/multi-bar-chart/index.d.mts +9 -0
- package/dist/components/multi-bar-chart/index.js +5 -0
- package/dist/components/multi-bar-chart/index.js.map +1 -0
- package/dist/components/{multi-bar-chart-body.d.mts → multi-bar-chart/multi-bar-chart-body.d.mts} +5 -5
- package/dist/components/{multi-bar-chart-body.js → multi-bar-chart/multi-bar-chart-body.js} +6 -5
- package/dist/components/multi-bar-chart/multi-bar-chart-body.js.map +1 -0
- package/dist/components/{multi-bar-chart.d.mts → multi-bar-chart/multi-bar-chart.d.mts} +5 -5
- package/dist/components/{multi-bar-chart.js → multi-bar-chart/multi-bar-chart.js} +1 -1
- package/dist/components/multi-bar-chart/multi-bar-chart.js.map +1 -0
- package/dist/components/multi-line-chart/index.d.mts +8 -0
- package/dist/components/multi-line-chart/index.js +5 -0
- package/dist/components/multi-line-chart/index.js.map +1 -0
- package/dist/components/{multi-line-chart-body.d.mts → multi-line-chart/multi-line-chart-body.d.mts} +4 -4
- package/dist/components/{multi-line-chart-body.js → multi-line-chart/multi-line-chart-body.js} +5 -4
- package/dist/components/multi-line-chart/multi-line-chart-body.js.map +1 -0
- package/dist/components/{multi-line-chart.d.mts → multi-line-chart/multi-line-chart.d.mts} +4 -4
- package/dist/components/{multi-line-chart.js → multi-line-chart/multi-line-chart.js} +1 -1
- package/dist/components/multi-line-chart/multi-line-chart.js.map +1 -0
- package/dist/components/multi-pie-chart/index.d.mts +7 -0
- package/dist/components/multi-pie-chart/index.js +5 -0
- package/dist/components/multi-pie-chart/index.js.map +1 -0
- package/dist/components/multi-pie-chart/multi-pie-chart-body.d.mts +13 -0
- package/dist/components/multi-pie-chart/multi-pie-chart-body.js +40 -0
- package/dist/components/multi-pie-chart/multi-pie-chart-body.js.map +1 -0
- package/dist/components/multi-pie-chart/multi-pie-chart.d.mts +10 -0
- package/dist/components/multi-pie-chart/multi-pie-chart.js +19 -0
- package/dist/components/multi-pie-chart/multi-pie-chart.js.map +1 -0
- package/dist/components/pie-chart/index.d.mts +6 -0
- package/dist/components/pie-chart/index.js +5 -0
- package/dist/components/pie-chart/index.js.map +1 -0
- package/dist/components/pie-chart/pie-chart-body.d.mts +12 -0
- package/dist/components/pie-chart/pie-chart-body.js +32 -0
- package/dist/components/pie-chart/pie-chart-body.js.map +1 -0
- package/dist/components/pie-chart/pie-chart.d.mts +9 -0
- package/dist/components/pie-chart/pie-chart.js +19 -0
- package/dist/components/pie-chart/pie-chart.js.map +1 -0
- package/dist/components/primitives/index.d.mts +3 -0
- package/dist/components/primitives/index.js +2 -0
- package/dist/components/primitives/index.js.map +1 -1
- package/dist/components/primitives/pie.d.mts +10 -0
- package/dist/components/primitives/pie.js +63 -0
- package/dist/components/primitives/pie.js.map +1 -0
- package/dist/constants/chart-layout.constants.d.mts +7 -0
- package/dist/constants/chart-layout.constants.js +10 -0
- package/dist/constants/chart-layout.constants.js.map +1 -0
- package/dist/constants/index.d.mts +4 -2
- package/dist/constants/index.js +2 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/pie.constants.d.mts +15 -0
- package/dist/constants/pie.constants.js +26 -0
- package/dist/constants/pie.constants.js.map +1 -0
- package/dist/hooks/index.d.mts +6 -0
- package/dist/hooks/index.js +5 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-chart-layout.hook.d.mts +1 -1
- package/dist/hooks/use-chart-layout.hook.js +5 -2
- package/dist/hooks/use-chart-layout.hook.js.map +1 -1
- package/dist/hooks/use-multi-pie-chart.hook.d.mts +10 -0
- package/dist/hooks/use-multi-pie-chart.hook.js +40 -0
- package/dist/hooks/use-multi-pie-chart.hook.js.map +1 -0
- package/dist/hooks/use-pie-chart.hook.d.mts +9 -0
- package/dist/hooks/use-pie-chart.hook.js +29 -0
- package/dist/hooks/use-pie-chart.hook.js.map +1 -0
- package/dist/index.d.mts +19 -4
- package/dist/types/index.d.mts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/multi-pie-chart.types.d.mts +20 -0
- package/dist/types/multi-pie-chart.types.js +1 -0
- package/dist/types/multi-pie-chart.types.js.map +1 -0
- package/dist/types/pie-chart.types.d.mts +46 -0
- package/dist/types/pie-chart.types.js +1 -0
- package/dist/types/pie-chart.types.js.map +1 -0
- package/dist/types/pie.types.d.mts +10 -0
- package/dist/types/pie.types.js +1 -0
- package/dist/types/pie.types.js.map +1 -0
- package/dist/types/use-multi-pie-chart.types.d.mts +14 -0
- package/dist/types/use-multi-pie-chart.types.js +1 -0
- package/dist/types/use-multi-pie-chart.types.js.map +1 -0
- package/dist/types/use-pie-chart.types.d.mts +12 -0
- package/dist/types/use-pie-chart.types.js +1 -0
- package/dist/types/use-pie-chart.types.js.map +1 -0
- package/dist/utils/chart-layout.util.d.mts +1 -1
- package/dist/utils/chart-layout.util.js +5 -5
- package/dist/utils/chart-layout.util.js.map +1 -1
- package/dist/utils/index.d.mts +7 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/multi-pie-chart.util.d.mts +10 -0
- package/dist/utils/multi-pie-chart.util.js +59 -0
- package/dist/utils/multi-pie-chart.util.js.map +1 -0
- package/dist/utils/pie-chart.util.d.mts +18 -0
- package/dist/utils/pie-chart.util.js +82 -0
- package/dist/utils/pie-chart.util.js.map +1 -0
- package/dist/utils/pie.util.d.mts +8 -0
- package/dist/utils/pie.util.js +19 -0
- package/dist/utils/pie.util.js.map +1 -0
- package/package.json +5 -5
- package/dist/components/bar-chart-body.js.map +0 -1
- package/dist/components/bar-chart.js.map +0 -1
- package/dist/components/chart-axes.js.map +0 -1
- package/dist/components/line-chart-body.js.map +0 -1
- package/dist/components/line-chart.js.map +0 -1
- package/dist/components/multi-bar-chart-body.js.map +0 -1
- package/dist/components/multi-bar-chart.js.map +0 -1
- package/dist/components/multi-line-chart-body.js.map +0 -1
- package/dist/components/multi-line-chart.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { createPieChartModel } from "../utils";
|
|
3
|
+
function usePieChart(props) {
|
|
4
|
+
const {
|
|
5
|
+
data,
|
|
6
|
+
endAngle,
|
|
7
|
+
innerRadius,
|
|
8
|
+
outerRadius,
|
|
9
|
+
padAngle,
|
|
10
|
+
plot,
|
|
11
|
+
startAngle
|
|
12
|
+
} = props;
|
|
13
|
+
return useMemo(
|
|
14
|
+
() => createPieChartModel({
|
|
15
|
+
data,
|
|
16
|
+
endAngle,
|
|
17
|
+
innerRadius,
|
|
18
|
+
outerRadius,
|
|
19
|
+
padAngle,
|
|
20
|
+
plot,
|
|
21
|
+
startAngle
|
|
22
|
+
}),
|
|
23
|
+
[data, endAngle, innerRadius, outerRadius, padAngle, plot, startAngle]
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
usePieChart
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=use-pie-chart.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-pie-chart.hook.ts"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { UsePieChartProps, UsePieChartResult } from \"../types\";\nimport { createPieChartModel } from \"../utils\";\n\nexport function usePieChart(props: UsePieChartProps): UsePieChartResult {\n const {\n data,\n endAngle,\n innerRadius,\n outerRadius,\n padAngle,\n plot,\n startAngle,\n } = props;\n\n return useMemo(\n () =>\n createPieChartModel({\n data,\n endAngle,\n innerRadius,\n outerRadius,\n padAngle,\n plot,\n startAngle,\n }),\n [data, endAngle, innerRadius, outerRadius, padAngle, plot, startAngle],\n );\n}\n"],"mappings":"AAAA,SAAS,eAAe;AAGxB,SAAS,2BAA2B;AAE7B,SAAS,YAAY,OAA4C;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,SAAO;AAAA,IACL,MACE,oBAAoB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,MAAM,UAAU,aAAa,aAAa,UAAU,MAAM,UAAU;AAAA,EACvE;AACF;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -2,25 +2,32 @@ export { Bar } from './components/primitives/bar.mjs';
|
|
|
2
2
|
export { Grid } from './components/primitives/grid.mjs';
|
|
3
3
|
export { Label } from './components/primitives/label.mjs';
|
|
4
4
|
export { Line } from './components/primitives/line.mjs';
|
|
5
|
+
export { Pie } from './components/primitives/pie.mjs';
|
|
5
6
|
export { XAxis } from './components/primitives/x-axis.mjs';
|
|
6
7
|
export { YAxis } from './components/primitives/y-axis.mjs';
|
|
7
|
-
export { BarChart } from './components/bar-chart.mjs';
|
|
8
|
-
export { LineChart } from './components/line-chart.mjs';
|
|
9
|
-
export { MultiBarChart } from './components/multi-bar-chart.mjs';
|
|
10
|
-
export { MultiLineChart } from './components/multi-line-chart.mjs';
|
|
8
|
+
export { BarChart } from './components/bar-chart/bar-chart.mjs';
|
|
9
|
+
export { LineChart } from './components/line-chart/line-chart.mjs';
|
|
10
|
+
export { MultiBarChart } from './components/multi-bar-chart/multi-bar-chart.mjs';
|
|
11
|
+
export { MultiLineChart } from './components/multi-line-chart/multi-line-chart.mjs';
|
|
12
|
+
export { MultiPieChart } from './components/multi-pie-chart/multi-pie-chart.mjs';
|
|
13
|
+
export { PieChart } from './components/pie-chart/pie-chart.mjs';
|
|
11
14
|
export { AxisDefaultLabelGap, AxisDefaultOpacity, AxisDefaultTickLength, AxisDefaultWidth } from './constants/axis.constants.mjs';
|
|
12
15
|
export { BarDefaultColor, BarDefaultColors, BarDefaultOpacity, BarDefaultRadius } from './constants/bar.constants.mjs';
|
|
13
16
|
export { BarChartDefaultCategoryPadding, MultiBarChartDefaultSeriesPadding } from './constants/bar-chart.constants.mjs';
|
|
17
|
+
export { CartesianChartDefaultInsets } from './constants/chart-layout.constants.mjs';
|
|
14
18
|
export { GridDefaultOpacity, GridDefaultWidth, GridDefaultXVisible, GridDefaultYVisible } from './constants/grid.constants.mjs';
|
|
15
19
|
export { LabelDefaultHorizontalAlignment, LabelDefaultVerticalAlignment, TabularNumsFeature } from './constants/label.constants.mjs';
|
|
16
20
|
export { LineDefaultCap, LineDefaultColor, LineDefaultColors, LineDefaultCurve, LineDefaultJoin, LineDefaultOpacity, LineDefaultWidth } from './constants/line.constants.mjs';
|
|
17
21
|
export { LineChartDefaultNumericDomain, LineChartDefaultTickCount } from './constants/line-chart.constants.mjs';
|
|
22
|
+
export { MultiPieDefaultRingPadding, PieDefaultColor, PieDefaultColors, PieDefaultCornerRadius, PieDefaultEndAngle, PieDefaultInnerRadius, PieDefaultOpacity, PieDefaultOuterRadius, PieDefaultPadAngle, PieDefaultStartAngle, PieDefaultStrokeWidth } from './constants/pie.constants.mjs';
|
|
18
23
|
export { useChartCanvas } from './hooks/use-chart-canvas.hook.mjs';
|
|
19
24
|
export { useChartLayout } from './hooks/use-chart-layout.hook.mjs';
|
|
20
25
|
export { useBarChart } from './hooks/use-bar-chart.hook.mjs';
|
|
21
26
|
export { useLineChart } from './hooks/use-line-chart.hook.mjs';
|
|
22
27
|
export { useMultiBarChart } from './hooks/use-multi-bar-chart.hook.mjs';
|
|
23
28
|
export { useMultiLineChart } from './hooks/use-multi-line-chart.hook.mjs';
|
|
29
|
+
export { useMultiPieChart } from './hooks/use-multi-pie-chart.hook.mjs';
|
|
30
|
+
export { usePieChart } from './hooks/use-pie-chart.hook.mjs';
|
|
24
31
|
export { AxisLayout, AxisLineLayout, AxisProps, AxisTick, AxisTickLayout, CreateAxisLayoutProps, CreateYAxisLayoutProps, XAxisProps, YAxisProps } from './types/axis.types.mjs';
|
|
25
32
|
export { BarProps } from './types/bar.types.mjs';
|
|
26
33
|
export { BarChartBarOptions, BarChartCommonProps, BarChartCoordinate, BarChartPoint, BarChartProps } from './types/bar-chart.types.mjs';
|
|
@@ -30,11 +37,16 @@ export { LabelHorizontalAlignment, LabelProps, LabelVerticalAlignment } from './
|
|
|
30
37
|
export { LineProps } from './types/line.types.mjs';
|
|
31
38
|
export { MultiBarChartProps, MultiBarChartSeries, MultiBarChartSeriesModel } from './types/multi-bar-chart.types.mjs';
|
|
32
39
|
export { MultiLineChartBodyProps, MultiLineChartProps, MultiLineChartSeries, MultiLineChartSeriesModel } from './types/multi-line-chart.types.mjs';
|
|
40
|
+
export { MultiPieChartProps, MultiPieChartSeries, MultiPieChartSeriesModel } from './types/multi-pie-chart.types.mjs';
|
|
41
|
+
export { PieProps } from './types/pie.types.mjs';
|
|
42
|
+
export { PieChartCommonProps, PieChartCoordinate, PieChartModel, PieChartPoint, PieChartProps, PieChartSliceOptions } from './types/pie-chart.types.mjs';
|
|
33
43
|
export { ChartLabelStyle, ChartStrokeCap, ChartStrokeJoin, ChartStrokeStyle } from './types/style.types.mjs';
|
|
34
44
|
export { UseBarChartProps, UseBarChartResult } from './types/use-bar-chart.types.mjs';
|
|
35
45
|
export { LineChartXScaleModel, UseLineChartProps, UseLineChartResult } from './types/use-line-chart.types.mjs';
|
|
36
46
|
export { UseMultiBarChartProps, UseMultiBarChartResult } from './types/use-multi-bar-chart.types.mjs';
|
|
37
47
|
export { UseMultiLineChartProps, UseMultiLineChartResult } from './types/use-multi-line-chart.types.mjs';
|
|
48
|
+
export { UseMultiPieChartProps, UseMultiPieChartResult } from './types/use-multi-pie-chart.types.mjs';
|
|
49
|
+
export { UsePieChartProps, UsePieChartResult } from './types/use-pie-chart.types.mjs';
|
|
38
50
|
export { createAxisTicks, createXAxisLabelRect, createXAxisLayout, createYAxisLabelRect, createYAxisLayout, formatAxisTick } from './utils/axis.util.mjs';
|
|
39
51
|
export { createBarChartCoordinates, createBarChartModel } from './utils/bar-chart.util.mjs';
|
|
40
52
|
export { createChartLayout, createInsetRect } from './utils/chart-layout.util.mjs';
|
|
@@ -45,6 +57,9 @@ export { createLineChartCoordinates, createLineChartModel } from './utils/line-c
|
|
|
45
57
|
export { createDrawableMultiLineChartSeries } from './utils/multi-line-chart.util.mjs';
|
|
46
58
|
export { createDrawableMultiBarChartSeries, createMultiBarChartModel } from './utils/multi-bar-chart.util.mjs';
|
|
47
59
|
export { createParagraphBuilder } from './utils/paragraph-builder.util.mjs';
|
|
60
|
+
export { createMultiPieChartModel } from './utils/multi-pie-chart.util.mjs';
|
|
61
|
+
export { createPieChartModel, createPieChartRadii, normalizeRadiusRatio } from './utils/pie-chart.util.mjs';
|
|
62
|
+
export { createPieSlicePath } from './utils/pie.util.mjs';
|
|
48
63
|
import 'react/jsx-runtime';
|
|
49
64
|
import '@impulse-ui-native/theme';
|
|
50
65
|
import '@shopify/react-native-skia';
|
package/dist/types/index.d.mts
CHANGED
|
@@ -7,10 +7,15 @@ export { LabelHorizontalAlignment, LabelProps, LabelVerticalAlignment } from './
|
|
|
7
7
|
export { LineProps } from './line.types.mjs';
|
|
8
8
|
export { MultiBarChartProps, MultiBarChartSeries, MultiBarChartSeriesModel } from './multi-bar-chart.types.mjs';
|
|
9
9
|
export { MultiLineChartBodyProps, MultiLineChartProps, MultiLineChartSeries, MultiLineChartSeriesModel } from './multi-line-chart.types.mjs';
|
|
10
|
+
export { MultiPieChartProps, MultiPieChartSeries, MultiPieChartSeriesModel } from './multi-pie-chart.types.mjs';
|
|
11
|
+
export { PieProps } from './pie.types.mjs';
|
|
12
|
+
export { PieChartCommonProps, PieChartCoordinate, PieChartModel, PieChartPoint, PieChartProps, PieChartSliceOptions } from './pie-chart.types.mjs';
|
|
10
13
|
export { ChartLabelStyle, ChartStrokeCap, ChartStrokeJoin, ChartStrokeStyle } from './style.types.mjs';
|
|
11
14
|
export { UseBarChartProps, UseBarChartResult } from './use-bar-chart.types.mjs';
|
|
12
15
|
export { LineChartXScaleModel, UseLineChartProps, UseLineChartResult } from './use-line-chart.types.mjs';
|
|
13
16
|
export { UseMultiBarChartProps, UseMultiBarChartResult } from './use-multi-bar-chart.types.mjs';
|
|
14
17
|
export { UseMultiLineChartProps, UseMultiLineChartResult } from './use-multi-line-chart.types.mjs';
|
|
18
|
+
export { UseMultiPieChartProps, UseMultiPieChartResult } from './use-multi-pie-chart.types.mjs';
|
|
19
|
+
export { UsePieChartProps, UsePieChartResult } from './use-pie-chart.types.mjs';
|
|
15
20
|
import '@shopify/react-native-skia';
|
|
16
21
|
import '@impulse-ui-native/theme';
|
package/dist/types/index.js
CHANGED
|
@@ -8,9 +8,14 @@ export * from "./line.types";
|
|
|
8
8
|
export * from "./line-chart.types";
|
|
9
9
|
export * from "./multi-bar-chart.types";
|
|
10
10
|
export * from "./multi-line-chart.types";
|
|
11
|
+
export * from "./multi-pie-chart.types";
|
|
12
|
+
export * from "./pie.types";
|
|
13
|
+
export * from "./pie-chart.types";
|
|
11
14
|
export * from "./style.types";
|
|
12
15
|
export * from "./use-bar-chart.types";
|
|
13
16
|
export * from "./use-line-chart.types";
|
|
14
17
|
export * from "./use-multi-bar-chart.types";
|
|
15
18
|
export * from "./use-multi-line-chart.types";
|
|
19
|
+
export * from "./use-multi-pie-chart.types";
|
|
20
|
+
export * from "./use-pie-chart.types";
|
|
16
21
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./axis.types\";\nexport * from \"./bar.types\";\nexport * from \"./bar-chart.types\";\nexport * from \"./common.types\";\nexport * from \"./grid.types\";\nexport * from \"./label.types\";\nexport * from \"./line.types\";\nexport * from \"./line-chart.types\";\nexport * from \"./multi-bar-chart.types\";\nexport * from \"./multi-line-chart.types\";\nexport * from \"./style.types\";\nexport * from \"./use-bar-chart.types\";\nexport * from \"./use-line-chart.types\";\nexport * from \"./use-multi-bar-chart.types\";\nexport * from \"./use-multi-line-chart.types\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./axis.types\";\nexport * from \"./bar.types\";\nexport * from \"./bar-chart.types\";\nexport * from \"./common.types\";\nexport * from \"./grid.types\";\nexport * from \"./label.types\";\nexport * from \"./line.types\";\nexport * from \"./line-chart.types\";\nexport * from \"./multi-bar-chart.types\";\nexport * from \"./multi-line-chart.types\";\nexport * from \"./multi-pie-chart.types\";\nexport * from \"./pie.types\";\nexport * from \"./pie-chart.types\";\nexport * from \"./style.types\";\nexport * from \"./use-bar-chart.types\";\nexport * from \"./use-line-chart.types\";\nexport * from \"./use-multi-bar-chart.types\";\nexport * from \"./use-multi-line-chart.types\";\nexport * from \"./use-multi-pie-chart.types\";\nexport * from \"./use-pie-chart.types\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PieChartCommonProps, PieChartPoint, PieChartSliceOptions, PieChartCoordinate } from './pie-chart.types.mjs';
|
|
2
|
+
import './common.types.mjs';
|
|
3
|
+
import './style.types.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
|
|
6
|
+
interface MultiPieChartSeries {
|
|
7
|
+
id: string;
|
|
8
|
+
data: readonly PieChartPoint[];
|
|
9
|
+
slice?: PieChartSliceOptions;
|
|
10
|
+
}
|
|
11
|
+
interface MultiPieChartSeriesModel extends MultiPieChartSeries {
|
|
12
|
+
coordinates: readonly PieChartCoordinate[];
|
|
13
|
+
total: number;
|
|
14
|
+
}
|
|
15
|
+
interface MultiPieChartProps extends PieChartCommonProps {
|
|
16
|
+
series: readonly MultiPieChartSeries[];
|
|
17
|
+
ringPadding?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type { MultiPieChartProps, MultiPieChartSeries, MultiPieChartSeriesModel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=multi-pie-chart.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ChartInsets, ChartPoint } from './common.types.mjs';
|
|
2
|
+
import './style.types.mjs';
|
|
3
|
+
import '@shopify/react-native-skia';
|
|
4
|
+
|
|
5
|
+
interface PieChartPoint {
|
|
6
|
+
id: string;
|
|
7
|
+
value: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
}
|
|
10
|
+
interface PieChartCoordinate {
|
|
11
|
+
datum: PieChartPoint;
|
|
12
|
+
index: number;
|
|
13
|
+
center: ChartPoint;
|
|
14
|
+
startAngle: number;
|
|
15
|
+
endAngle: number;
|
|
16
|
+
padAngle: number;
|
|
17
|
+
padRadius: number;
|
|
18
|
+
innerRadius: number;
|
|
19
|
+
outerRadius: number;
|
|
20
|
+
}
|
|
21
|
+
interface PieChartSliceOptions {
|
|
22
|
+
visible?: boolean;
|
|
23
|
+
colors?: readonly string[];
|
|
24
|
+
opacity?: number;
|
|
25
|
+
cornerRadius?: number;
|
|
26
|
+
strokeColor?: string;
|
|
27
|
+
strokeWidth?: number;
|
|
28
|
+
}
|
|
29
|
+
interface PieChartCommonProps {
|
|
30
|
+
insets?: Partial<ChartInsets>;
|
|
31
|
+
innerRadius?: number;
|
|
32
|
+
outerRadius?: number;
|
|
33
|
+
padAngle?: number;
|
|
34
|
+
startAngle?: number;
|
|
35
|
+
endAngle?: number;
|
|
36
|
+
}
|
|
37
|
+
interface PieChartProps extends PieChartCommonProps {
|
|
38
|
+
data: readonly PieChartPoint[];
|
|
39
|
+
slice?: PieChartSliceOptions;
|
|
40
|
+
}
|
|
41
|
+
interface PieChartModel {
|
|
42
|
+
coordinates: readonly PieChartCoordinate[];
|
|
43
|
+
total: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type { PieChartCommonProps, PieChartCoordinate, PieChartModel, PieChartPoint, PieChartProps, PieChartSliceOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=pie-chart.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PieChartSliceOptions, PieChartCoordinate } from './pie-chart.types.mjs';
|
|
2
|
+
import './common.types.mjs';
|
|
3
|
+
import './style.types.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
|
|
6
|
+
interface PieProps extends PieChartSliceOptions {
|
|
7
|
+
coordinates: readonly PieChartCoordinate[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type { PieProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=pie.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChartRect } from './common.types.mjs';
|
|
2
|
+
import { MultiPieChartProps, MultiPieChartSeriesModel } from './multi-pie-chart.types.mjs';
|
|
3
|
+
import { PieChartCommonProps } from './pie-chart.types.mjs';
|
|
4
|
+
import './style.types.mjs';
|
|
5
|
+
import '@shopify/react-native-skia';
|
|
6
|
+
|
|
7
|
+
interface UseMultiPieChartProps extends Pick<PieChartCommonProps, "endAngle" | "innerRadius" | "outerRadius" | "padAngle" | "startAngle">, Pick<MultiPieChartProps, "ringPadding" | "series"> {
|
|
8
|
+
plot: ChartRect;
|
|
9
|
+
}
|
|
10
|
+
interface UseMultiPieChartResult {
|
|
11
|
+
series: readonly MultiPieChartSeriesModel[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type { UseMultiPieChartProps, UseMultiPieChartResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=use-multi-pie-chart.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChartRect } from './common.types.mjs';
|
|
2
|
+
import { PieChartCommonProps, PieChartPoint, PieChartModel } from './pie-chart.types.mjs';
|
|
3
|
+
import './style.types.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
|
|
6
|
+
interface UsePieChartProps extends Pick<PieChartCommonProps, "endAngle" | "innerRadius" | "outerRadius" | "padAngle" | "startAngle"> {
|
|
7
|
+
data: readonly PieChartPoint[];
|
|
8
|
+
plot: ChartRect;
|
|
9
|
+
}
|
|
10
|
+
type UsePieChartResult = PieChartModel;
|
|
11
|
+
|
|
12
|
+
export type { UsePieChartProps, UsePieChartResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=use-pie-chart.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -2,7 +2,7 @@ import { ChartSize, ChartInsets, ChartLayout, ChartRect } from '../types/common.
|
|
|
2
2
|
import '../types/style.types.mjs';
|
|
3
3
|
import '@shopify/react-native-skia';
|
|
4
4
|
|
|
5
|
-
declare function createChartLayout(size: ChartSize, insets?: Partial<ChartInsets>): ChartLayout;
|
|
5
|
+
declare function createChartLayout(size: ChartSize, insets?: Partial<ChartInsets>, defaultInsets?: Partial<ChartInsets>): ChartLayout;
|
|
6
6
|
declare function createInsetRect(rect: ChartRect, amount: number): ChartRect;
|
|
7
7
|
|
|
8
8
|
export { createChartLayout, createInsetRect };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function createChartLayout(size, insets = {}) {
|
|
1
|
+
function createChartLayout(size, insets = {}, defaultInsets = {}) {
|
|
2
2
|
const resolvedInsets = {
|
|
3
|
-
top: insets.top ?? 0,
|
|
4
|
-
right: insets.right ?? 0,
|
|
5
|
-
bottom: insets.bottom ?? 0,
|
|
6
|
-
left: insets.left ?? 0
|
|
3
|
+
top: insets.top ?? defaultInsets.top ?? 0,
|
|
4
|
+
right: insets.right ?? defaultInsets.right ?? 0,
|
|
5
|
+
bottom: insets.bottom ?? defaultInsets.bottom ?? 0,
|
|
6
|
+
left: insets.left ?? defaultInsets.left ?? 0
|
|
7
7
|
};
|
|
8
8
|
const plotWidth = Math.max(
|
|
9
9
|
0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/chart-layout.util.ts"],"sourcesContent":["import { ChartInsets, ChartLayout, ChartRect, ChartSize } from \"../types\";\n\nexport function createChartLayout(\n size: ChartSize,\n insets: Partial<ChartInsets> = {},\n): ChartLayout {\n const resolvedInsets: ChartInsets = {\n top: insets.top ?? 0,\n right: insets.right ?? 0,\n bottom: insets.bottom ?? 0,\n left: insets.left ?? 0,\n };\n\n const plotWidth = Math.max(\n 0,\n size.width - resolvedInsets.left - resolvedInsets.right,\n );\n const plotHeight = Math.max(\n 0,\n size.height - resolvedInsets.top - resolvedInsets.bottom,\n );\n\n const plot = {\n x: resolvedInsets.left,\n y: resolvedInsets.top,\n width: plotWidth,\n height: plotHeight,\n };\n\n return {\n size,\n insets: resolvedInsets,\n plot,\n xAxis: {\n x: plot.x,\n y: plot.y + plot.height,\n width: plot.width,\n height: resolvedInsets.bottom,\n },\n yAxis: {\n x: 0,\n y: plot.y,\n width: resolvedInsets.left,\n height: plot.height,\n },\n };\n}\n\nexport function createInsetRect(rect: ChartRect, amount: number): ChartRect {\n const inset = Math.max(0, amount);\n const horizontalInset = Math.min(inset, rect.width / 2);\n const verticalInset = Math.min(inset, rect.height / 2);\n\n return {\n x: rect.x + horizontalInset,\n y: rect.y + verticalInset,\n width: Math.max(0, rect.width - horizontalInset * 2),\n height: Math.max(0, rect.height - verticalInset * 2),\n };\n}\n"],"mappings":"AAEO,SAAS,kBACd,MACA,SAA+B,CAAC,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/chart-layout.util.ts"],"sourcesContent":["import { ChartInsets, ChartLayout, ChartRect, ChartSize } from \"../types\";\n\nexport function createChartLayout(\n size: ChartSize,\n insets: Partial<ChartInsets> = {},\n defaultInsets: Partial<ChartInsets> = {},\n): ChartLayout {\n const resolvedInsets: ChartInsets = {\n top: insets.top ?? defaultInsets.top ?? 0,\n right: insets.right ?? defaultInsets.right ?? 0,\n bottom: insets.bottom ?? defaultInsets.bottom ?? 0,\n left: insets.left ?? defaultInsets.left ?? 0,\n };\n\n const plotWidth = Math.max(\n 0,\n size.width - resolvedInsets.left - resolvedInsets.right,\n );\n const plotHeight = Math.max(\n 0,\n size.height - resolvedInsets.top - resolvedInsets.bottom,\n );\n\n const plot = {\n x: resolvedInsets.left,\n y: resolvedInsets.top,\n width: plotWidth,\n height: plotHeight,\n };\n\n return {\n size,\n insets: resolvedInsets,\n plot,\n xAxis: {\n x: plot.x,\n y: plot.y + plot.height,\n width: plot.width,\n height: resolvedInsets.bottom,\n },\n yAxis: {\n x: 0,\n y: plot.y,\n width: resolvedInsets.left,\n height: plot.height,\n },\n };\n}\n\nexport function createInsetRect(rect: ChartRect, amount: number): ChartRect {\n const inset = Math.max(0, amount);\n const horizontalInset = Math.min(inset, rect.width / 2);\n const verticalInset = Math.min(inset, rect.height / 2);\n\n return {\n x: rect.x + horizontalInset,\n y: rect.y + verticalInset,\n width: Math.max(0, rect.width - horizontalInset * 2),\n height: Math.max(0, rect.height - verticalInset * 2),\n };\n}\n"],"mappings":"AAEO,SAAS,kBACd,MACA,SAA+B,CAAC,GAChC,gBAAsC,CAAC,GAC1B;AACb,QAAM,iBAA8B;AAAA,IAClC,KAAK,OAAO,OAAO,cAAc,OAAO;AAAA,IACxC,OAAO,OAAO,SAAS,cAAc,SAAS;AAAA,IAC9C,QAAQ,OAAO,UAAU,cAAc,UAAU;AAAA,IACjD,MAAM,OAAO,QAAQ,cAAc,QAAQ;AAAA,EAC7C;AAEA,QAAM,YAAY,KAAK;AAAA,IACrB;AAAA,IACA,KAAK,QAAQ,eAAe,OAAO,eAAe;AAAA,EACpD;AACA,QAAM,aAAa,KAAK;AAAA,IACtB;AAAA,IACA,KAAK,SAAS,eAAe,MAAM,eAAe;AAAA,EACpD;AAEA,QAAM,OAAO;AAAA,IACX,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAEA,SAAO;AAAA,IACL;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,OAAO;AAAA,MACL,GAAG,KAAK;AAAA,MACR,GAAG,KAAK,IAAI,KAAK;AAAA,MACjB,OAAO,KAAK;AAAA,MACZ,QAAQ,eAAe;AAAA,IACzB;AAAA,IACA,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG,KAAK;AAAA,MACR,OAAO,eAAe;AAAA,MACtB,QAAQ,KAAK;AAAA,IACf;AAAA,EACF;AACF;AAEO,SAAS,gBAAgB,MAAiB,QAA2B;AAC1E,QAAM,QAAQ,KAAK,IAAI,GAAG,MAAM;AAChC,QAAM,kBAAkB,KAAK,IAAI,OAAO,KAAK,QAAQ,CAAC;AACtD,QAAM,gBAAgB,KAAK,IAAI,OAAO,KAAK,SAAS,CAAC;AAErD,SAAO;AAAA,IACL,GAAG,KAAK,IAAI;AAAA,IACZ,GAAG,KAAK,IAAI;AAAA,IACZ,OAAO,KAAK,IAAI,GAAG,KAAK,QAAQ,kBAAkB,CAAC;AAAA,IACnD,QAAQ,KAAK,IAAI,GAAG,KAAK,SAAS,gBAAgB,CAAC;AAAA,EACrD;AACF;","names":[]}
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -8,6 +8,9 @@ export { createLineChartCoordinates, createLineChartModel } from './line-chart.u
|
|
|
8
8
|
export { createDrawableMultiLineChartSeries } from './multi-line-chart.util.mjs';
|
|
9
9
|
export { createDrawableMultiBarChartSeries, createMultiBarChartModel } from './multi-bar-chart.util.mjs';
|
|
10
10
|
export { createParagraphBuilder } from './paragraph-builder.util.mjs';
|
|
11
|
+
export { createMultiPieChartModel } from './multi-pie-chart.util.mjs';
|
|
12
|
+
export { createPieChartModel, createPieChartRadii, normalizeRadiusRatio } from './pie-chart.util.mjs';
|
|
13
|
+
export { createPieSlicePath } from './pie.util.mjs';
|
|
11
14
|
import '../types/axis.types.mjs';
|
|
12
15
|
import '@shopify/react-native-skia';
|
|
13
16
|
import '@impulse-ui-native/theme';
|
|
@@ -21,3 +24,7 @@ import '../types/use-line-chart.types.mjs';
|
|
|
21
24
|
import '../types/multi-line-chart.types.mjs';
|
|
22
25
|
import '../types/multi-bar-chart.types.mjs';
|
|
23
26
|
import '../types/use-multi-bar-chart.types.mjs';
|
|
27
|
+
import '../types/use-multi-pie-chart.types.mjs';
|
|
28
|
+
import '../types/multi-pie-chart.types.mjs';
|
|
29
|
+
import '../types/pie-chart.types.mjs';
|
|
30
|
+
import '../types/use-pie-chart.types.mjs';
|
package/dist/utils/index.js
CHANGED
|
@@ -28,6 +28,13 @@ import {
|
|
|
28
28
|
createMultiBarChartModel
|
|
29
29
|
} from "./multi-bar-chart.util";
|
|
30
30
|
import { createParagraphBuilder } from "./paragraph-builder.util";
|
|
31
|
+
import { createMultiPieChartModel } from "./multi-pie-chart.util";
|
|
32
|
+
import {
|
|
33
|
+
createPieChartModel,
|
|
34
|
+
createPieChartRadii,
|
|
35
|
+
normalizeRadiusRatio
|
|
36
|
+
} from "./pie-chart.util";
|
|
37
|
+
import { createPieSlicePath } from "./pie.util";
|
|
31
38
|
export {
|
|
32
39
|
createAxisTicks,
|
|
33
40
|
createBarChartCoordinates,
|
|
@@ -41,7 +48,11 @@ export {
|
|
|
41
48
|
createLineChartModel,
|
|
42
49
|
createLinePath,
|
|
43
50
|
createMultiBarChartModel,
|
|
51
|
+
createMultiPieChartModel,
|
|
44
52
|
createParagraphBuilder,
|
|
53
|
+
createPieChartModel,
|
|
54
|
+
createPieChartRadii,
|
|
55
|
+
createPieSlicePath,
|
|
45
56
|
createVerticalGridPath,
|
|
46
57
|
createXAxisLabelRect,
|
|
47
58
|
createXAxisLayout,
|
|
@@ -51,6 +62,7 @@ export {
|
|
|
51
62
|
formatAxisTick,
|
|
52
63
|
getLabelTextAlign,
|
|
53
64
|
getLabelY,
|
|
65
|
+
normalizeRadiusRatio,
|
|
54
66
|
resolveGridLineOptions
|
|
55
67
|
};
|
|
56
68
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export {\n createAxisTicks,\n createXAxisLayout,\n createXAxisLabelRect,\n createYAxisLayout,\n createYAxisLabelRect,\n formatAxisTick,\n} from \"./axis.util\";\nexport {\n createBarChartCoordinates,\n createBarChartModel,\n} from \"./bar-chart.util\";\nexport { createChartLayout, createInsetRect } from \"./chart-layout.util\";\nexport {\n createHorizontalGridPath,\n createVerticalGridPath,\n resolveGridLineOptions,\n} from \"./grid.util\";\nexport { getLabelTextAlign, getLabelY } from \"./label.util\";\nexport { createLinePath, fitLineCoordinatesToRect } from \"./line.util\";\nexport {\n createLineChartCoordinates,\n createLineChartModel,\n} from \"./line-chart.util\";\nexport { createDrawableMultiLineChartSeries } from \"./multi-line-chart.util\";\nexport {\n createDrawableMultiBarChartSeries,\n createMultiBarChartModel,\n} from \"./multi-bar-chart.util\";\nexport { createParagraphBuilder } from \"./paragraph-builder.util\";\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB,uBAAuB;AACnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB,iBAAiB;AAC7C,SAAS,gBAAgB,gCAAgC;AACzD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,0CAA0C;AACnD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export {\n createAxisTicks,\n createXAxisLayout,\n createXAxisLabelRect,\n createYAxisLayout,\n createYAxisLabelRect,\n formatAxisTick,\n} from \"./axis.util\";\nexport {\n createBarChartCoordinates,\n createBarChartModel,\n} from \"./bar-chart.util\";\nexport { createChartLayout, createInsetRect } from \"./chart-layout.util\";\nexport {\n createHorizontalGridPath,\n createVerticalGridPath,\n resolveGridLineOptions,\n} from \"./grid.util\";\nexport { getLabelTextAlign, getLabelY } from \"./label.util\";\nexport { createLinePath, fitLineCoordinatesToRect } from \"./line.util\";\nexport {\n createLineChartCoordinates,\n createLineChartModel,\n} from \"./line-chart.util\";\nexport { createDrawableMultiLineChartSeries } from \"./multi-line-chart.util\";\nexport {\n createDrawableMultiBarChartSeries,\n createMultiBarChartModel,\n} from \"./multi-bar-chart.util\";\nexport { createParagraphBuilder } from \"./paragraph-builder.util\";\nexport { createMultiPieChartModel } from \"./multi-pie-chart.util\";\nexport {\n createPieChartModel,\n createPieChartRadii,\n normalizeRadiusRatio,\n} from \"./pie-chart.util\";\nexport { createPieSlicePath } from \"./pie.util\";\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB,uBAAuB;AACnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB,iBAAiB;AAC7C,SAAS,gBAAgB,gCAAgC;AACzD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,0CAA0C;AACnD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseMultiPieChartProps, UseMultiPieChartResult } from '../types/use-multi-pie-chart.types.mjs';
|
|
2
|
+
import '../types/common.types.mjs';
|
|
3
|
+
import '../types/style.types.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
import '../types/multi-pie-chart.types.mjs';
|
|
6
|
+
import '../types/pie-chart.types.mjs';
|
|
7
|
+
|
|
8
|
+
declare function createMultiPieChartModel(props: UseMultiPieChartProps): UseMultiPieChartResult;
|
|
9
|
+
|
|
10
|
+
export { createMultiPieChartModel };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { MultiPieDefaultRingPadding } from "../constants";
|
|
2
|
+
import { createPieChartModel, createPieChartRadii } from "./pie-chart.util";
|
|
3
|
+
function createMultiPieChartModel(props) {
|
|
4
|
+
const { innerRadius, outerRadius } = createPieChartRadii(
|
|
5
|
+
props.plot,
|
|
6
|
+
props.innerRadius,
|
|
7
|
+
props.outerRadius
|
|
8
|
+
);
|
|
9
|
+
const ringCount = props.series.length;
|
|
10
|
+
const radialSpan = outerRadius - innerRadius;
|
|
11
|
+
const ringPadding = ringCount <= 1 ? 0 : Math.min(
|
|
12
|
+
normalizeRingPadding(props.ringPadding),
|
|
13
|
+
radialSpan / (ringCount - 1)
|
|
14
|
+
);
|
|
15
|
+
const availableWidth = Math.max(
|
|
16
|
+
0,
|
|
17
|
+
radialSpan - ringPadding * Math.max(0, ringCount - 1)
|
|
18
|
+
);
|
|
19
|
+
const ringWidth = ringCount === 0 ? 0 : availableWidth / ringCount;
|
|
20
|
+
const maximumRadius = Math.max(
|
|
21
|
+
0,
|
|
22
|
+
Math.min(props.plot.width, props.plot.height) / 2
|
|
23
|
+
);
|
|
24
|
+
const series = props.series.map(
|
|
25
|
+
(currentSeries, index) => {
|
|
26
|
+
const seriesOuterRadius = outerRadius - index * (ringWidth + ringPadding);
|
|
27
|
+
const seriesInnerRadius = Math.max(
|
|
28
|
+
innerRadius,
|
|
29
|
+
seriesOuterRadius - ringWidth
|
|
30
|
+
);
|
|
31
|
+
const model = createPieChartModel({
|
|
32
|
+
data: currentSeries.data,
|
|
33
|
+
plot: props.plot,
|
|
34
|
+
startAngle: props.startAngle,
|
|
35
|
+
endAngle: props.endAngle,
|
|
36
|
+
padAngle: props.padAngle,
|
|
37
|
+
innerRadius: maximumRadius === 0 ? 0 : seriesInnerRadius / maximumRadius,
|
|
38
|
+
outerRadius: maximumRadius === 0 ? 0 : seriesOuterRadius / maximumRadius
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
...currentSeries,
|
|
42
|
+
...model,
|
|
43
|
+
coordinates: model.coordinates.map((coordinate) => ({
|
|
44
|
+
...coordinate,
|
|
45
|
+
padRadius: outerRadius
|
|
46
|
+
}))
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
return { series };
|
|
51
|
+
}
|
|
52
|
+
function normalizeRingPadding(value) {
|
|
53
|
+
const padding = value === void 0 || !Number.isFinite(value) ? MultiPieDefaultRingPadding : value;
|
|
54
|
+
return Math.max(0, padding);
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
createMultiPieChartModel
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=multi-pie-chart.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/multi-pie-chart.util.ts"],"sourcesContent":["import { MultiPieDefaultRingPadding } from \"../constants\";\nimport {\n MultiPieChartSeriesModel,\n UseMultiPieChartProps,\n UseMultiPieChartResult,\n} from \"../types\";\nimport { createPieChartModel, createPieChartRadii } from \"./pie-chart.util\";\n\nexport function createMultiPieChartModel(\n props: UseMultiPieChartProps,\n): UseMultiPieChartResult {\n const { innerRadius, outerRadius } = createPieChartRadii(\n props.plot,\n props.innerRadius,\n props.outerRadius,\n );\n const ringCount = props.series.length;\n const radialSpan = outerRadius - innerRadius;\n const ringPadding =\n ringCount <= 1\n ? 0\n : Math.min(\n normalizeRingPadding(props.ringPadding),\n radialSpan / (ringCount - 1),\n );\n const availableWidth = Math.max(\n 0,\n radialSpan - ringPadding * Math.max(0, ringCount - 1),\n );\n const ringWidth = ringCount === 0 ? 0 : availableWidth / ringCount;\n const maximumRadius = Math.max(\n 0,\n Math.min(props.plot.width, props.plot.height) / 2,\n );\n\n const series: MultiPieChartSeriesModel[] = props.series.map(\n (currentSeries, index) => {\n const seriesOuterRadius = outerRadius - index * (ringWidth + ringPadding);\n const seriesInnerRadius = Math.max(\n innerRadius,\n seriesOuterRadius - ringWidth,\n );\n const model = createPieChartModel({\n data: currentSeries.data,\n plot: props.plot,\n startAngle: props.startAngle,\n endAngle: props.endAngle,\n padAngle: props.padAngle,\n innerRadius:\n maximumRadius === 0 ? 0 : seriesInnerRadius / maximumRadius,\n outerRadius:\n maximumRadius === 0 ? 0 : seriesOuterRadius / maximumRadius,\n });\n\n return {\n ...currentSeries,\n ...model,\n coordinates: model.coordinates.map((coordinate) => ({\n ...coordinate,\n padRadius: outerRadius,\n })),\n };\n },\n );\n\n return { series };\n}\n\nfunction normalizeRingPadding(value: number | undefined): number {\n const padding =\n value === undefined || !Number.isFinite(value)\n ? MultiPieDefaultRingPadding\n : value;\n\n return Math.max(0, padding);\n}\n"],"mappings":"AAAA,SAAS,kCAAkC;AAM3C,SAAS,qBAAqB,2BAA2B;AAElD,SAAS,yBACd,OACwB;AACxB,QAAM,EAAE,aAAa,YAAY,IAAI;AAAA,IACnC,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACA,QAAM,YAAY,MAAM,OAAO;AAC/B,QAAM,aAAa,cAAc;AACjC,QAAM,cACJ,aAAa,IACT,IACA,KAAK;AAAA,IACH,qBAAqB,MAAM,WAAW;AAAA,IACtC,cAAc,YAAY;AAAA,EAC5B;AACN,QAAM,iBAAiB,KAAK;AAAA,IAC1B;AAAA,IACA,aAAa,cAAc,KAAK,IAAI,GAAG,YAAY,CAAC;AAAA,EACtD;AACA,QAAM,YAAY,cAAc,IAAI,IAAI,iBAAiB;AACzD,QAAM,gBAAgB,KAAK;AAAA,IACzB;AAAA,IACA,KAAK,IAAI,MAAM,KAAK,OAAO,MAAM,KAAK,MAAM,IAAI;AAAA,EAClD;AAEA,QAAM,SAAqC,MAAM,OAAO;AAAA,IACtD,CAAC,eAAe,UAAU;AACxB,YAAM,oBAAoB,cAAc,SAAS,YAAY;AAC7D,YAAM,oBAAoB,KAAK;AAAA,QAC7B;AAAA,QACA,oBAAoB;AAAA,MACtB;AACA,YAAM,QAAQ,oBAAoB;AAAA,QAChC,MAAM,cAAc;AAAA,QACpB,MAAM,MAAM;AAAA,QACZ,YAAY,MAAM;AAAA,QAClB,UAAU,MAAM;AAAA,QAChB,UAAU,MAAM;AAAA,QAChB,aACE,kBAAkB,IAAI,IAAI,oBAAoB;AAAA,QAChD,aACE,kBAAkB,IAAI,IAAI,oBAAoB;AAAA,MAClD,CAAC;AAED,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG;AAAA,QACH,aAAa,MAAM,YAAY,IAAI,CAAC,gBAAgB;AAAA,UAClD,GAAG;AAAA,UACH,WAAW;AAAA,QACb,EAAE;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,OAAO;AAClB;AAEA,SAAS,qBAAqB,OAAmC;AAC/D,QAAM,UACJ,UAAU,UAAa,CAAC,OAAO,SAAS,KAAK,IACzC,6BACA;AAEN,SAAO,KAAK,IAAI,GAAG,OAAO;AAC5B;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChartRect } from '../types/common.types.mjs';
|
|
2
|
+
import { PieChartModel } from '../types/pie-chart.types.mjs';
|
|
3
|
+
import { UsePieChartProps } from '../types/use-pie-chart.types.mjs';
|
|
4
|
+
import '../types/style.types.mjs';
|
|
5
|
+
import '@shopify/react-native-skia';
|
|
6
|
+
|
|
7
|
+
declare function createPieChartModel(props: UsePieChartProps): PieChartModel;
|
|
8
|
+
declare function createPieChartRadii(plot: ChartRect, innerRadiusRatio?: number, outerRadiusRatio?: number): {
|
|
9
|
+
center: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
innerRadius: number;
|
|
14
|
+
outerRadius: number;
|
|
15
|
+
};
|
|
16
|
+
declare function normalizeRadiusRatio(value: number): number;
|
|
17
|
+
|
|
18
|
+
export { createPieChartModel, createPieChartRadii, normalizeRadiusRatio };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { pie } from "d3-shape";
|
|
2
|
+
import {
|
|
3
|
+
PieDefaultEndAngle,
|
|
4
|
+
PieDefaultInnerRadius,
|
|
5
|
+
PieDefaultOuterRadius,
|
|
6
|
+
PieDefaultPadAngle,
|
|
7
|
+
PieDefaultStartAngle
|
|
8
|
+
} from "../constants/pie.constants";
|
|
9
|
+
const DegreesToRadians = Math.PI / 180;
|
|
10
|
+
function createPieChartModel(props) {
|
|
11
|
+
const data = props.data.filter(isValidPieChartPoint);
|
|
12
|
+
const total = data.reduce((sum, datum) => sum + datum.value, 0);
|
|
13
|
+
const { center, innerRadius, outerRadius } = createPieChartRadii(
|
|
14
|
+
props.plot,
|
|
15
|
+
props.innerRadius,
|
|
16
|
+
props.outerRadius
|
|
17
|
+
);
|
|
18
|
+
if (data.length === 0 || outerRadius <= 0) {
|
|
19
|
+
return { coordinates: [], total: 0 };
|
|
20
|
+
}
|
|
21
|
+
const startAngle = degreesToRadians(
|
|
22
|
+
normalizeAngle(props.startAngle, PieDefaultStartAngle)
|
|
23
|
+
);
|
|
24
|
+
const endAngle = degreesToRadians(
|
|
25
|
+
normalizeAngle(props.endAngle, PieDefaultEndAngle)
|
|
26
|
+
);
|
|
27
|
+
const padAngle = Math.max(
|
|
28
|
+
0,
|
|
29
|
+
degreesToRadians(normalizeAngle(props.padAngle, PieDefaultPadAngle))
|
|
30
|
+
);
|
|
31
|
+
const arcs = pie().value((datum) => datum.value).sort(null).startAngle(startAngle).endAngle(endAngle).padAngle(padAngle)(data);
|
|
32
|
+
const coordinates = arcs.map((currentArc) => ({
|
|
33
|
+
datum: currentArc.data,
|
|
34
|
+
index: currentArc.index,
|
|
35
|
+
center,
|
|
36
|
+
startAngle: currentArc.startAngle,
|
|
37
|
+
endAngle: currentArc.endAngle,
|
|
38
|
+
padAngle: currentArc.padAngle,
|
|
39
|
+
padRadius: outerRadius,
|
|
40
|
+
innerRadius,
|
|
41
|
+
outerRadius
|
|
42
|
+
}));
|
|
43
|
+
return { coordinates, total };
|
|
44
|
+
}
|
|
45
|
+
function createPieChartRadii(plot, innerRadiusRatio = PieDefaultInnerRadius, outerRadiusRatio = PieDefaultOuterRadius) {
|
|
46
|
+
const maximumRadius = Math.max(0, Math.min(plot.width, plot.height) / 2);
|
|
47
|
+
const resolvedOuterRatio = normalizeRadiusRatio(
|
|
48
|
+
Number.isFinite(outerRadiusRatio) ? outerRadiusRatio : PieDefaultOuterRadius
|
|
49
|
+
);
|
|
50
|
+
const resolvedInnerRatio = Math.min(
|
|
51
|
+
normalizeRadiusRatio(
|
|
52
|
+
Number.isFinite(innerRadiusRatio) ? innerRadiusRatio : PieDefaultInnerRadius
|
|
53
|
+
),
|
|
54
|
+
resolvedOuterRatio
|
|
55
|
+
);
|
|
56
|
+
return {
|
|
57
|
+
center: {
|
|
58
|
+
x: plot.x + plot.width / 2,
|
|
59
|
+
y: plot.y + plot.height / 2
|
|
60
|
+
},
|
|
61
|
+
innerRadius: maximumRadius * resolvedInnerRatio,
|
|
62
|
+
outerRadius: maximumRadius * resolvedOuterRatio
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function normalizeRadiusRatio(value) {
|
|
66
|
+
return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
67
|
+
}
|
|
68
|
+
function degreesToRadians(value) {
|
|
69
|
+
return value * DegreesToRadians;
|
|
70
|
+
}
|
|
71
|
+
function normalizeAngle(value, fallback) {
|
|
72
|
+
return value === void 0 || !Number.isFinite(value) ? fallback : value;
|
|
73
|
+
}
|
|
74
|
+
function isValidPieChartPoint(datum) {
|
|
75
|
+
return Number.isFinite(datum.value) && datum.value > 0;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
createPieChartModel,
|
|
79
|
+
createPieChartRadii,
|
|
80
|
+
normalizeRadiusRatio
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=pie-chart.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/pie-chart.util.ts"],"sourcesContent":["import { pie } from \"d3-shape\";\n\nimport {\n PieDefaultEndAngle,\n PieDefaultInnerRadius,\n PieDefaultOuterRadius,\n PieDefaultPadAngle,\n PieDefaultStartAngle,\n} from \"../constants/pie.constants\";\nimport {\n ChartRect,\n PieChartCoordinate,\n PieChartModel,\n PieChartPoint,\n UsePieChartProps,\n} from \"../types\";\n\nconst DegreesToRadians = Math.PI / 180;\n\nexport function createPieChartModel(props: UsePieChartProps): PieChartModel {\n const data = props.data.filter(isValidPieChartPoint);\n const total = data.reduce((sum, datum) => sum + datum.value, 0);\n const { center, innerRadius, outerRadius } = createPieChartRadii(\n props.plot,\n props.innerRadius,\n props.outerRadius,\n );\n\n if (data.length === 0 || outerRadius <= 0) {\n return { coordinates: [], total: 0 };\n }\n\n const startAngle = degreesToRadians(\n normalizeAngle(props.startAngle, PieDefaultStartAngle),\n );\n const endAngle = degreesToRadians(\n normalizeAngle(props.endAngle, PieDefaultEndAngle),\n );\n const padAngle = Math.max(\n 0,\n degreesToRadians(normalizeAngle(props.padAngle, PieDefaultPadAngle)),\n );\n const arcs = pie<PieChartPoint>()\n .value((datum) => datum.value)\n .sort(null)\n .startAngle(startAngle)\n .endAngle(endAngle)\n .padAngle(padAngle)(data);\n const coordinates: PieChartCoordinate[] = arcs.map((currentArc) => ({\n datum: currentArc.data,\n index: currentArc.index,\n center,\n startAngle: currentArc.startAngle,\n endAngle: currentArc.endAngle,\n padAngle: currentArc.padAngle,\n padRadius: outerRadius,\n innerRadius,\n outerRadius,\n }));\n\n return { coordinates, total };\n}\n\nexport function createPieChartRadii(\n plot: ChartRect,\n innerRadiusRatio = PieDefaultInnerRadius,\n outerRadiusRatio = PieDefaultOuterRadius,\n) {\n const maximumRadius = Math.max(0, Math.min(plot.width, plot.height) / 2);\n const resolvedOuterRatio = normalizeRadiusRatio(\n Number.isFinite(outerRadiusRatio)\n ? outerRadiusRatio\n : PieDefaultOuterRadius,\n );\n const resolvedInnerRatio = Math.min(\n normalizeRadiusRatio(\n Number.isFinite(innerRadiusRatio)\n ? innerRadiusRatio\n : PieDefaultInnerRadius,\n ),\n resolvedOuterRatio,\n );\n\n return {\n center: {\n x: plot.x + plot.width / 2,\n y: plot.y + plot.height / 2,\n },\n innerRadius: maximumRadius * resolvedInnerRatio,\n outerRadius: maximumRadius * resolvedOuterRatio,\n };\n}\n\nexport function normalizeRadiusRatio(value: number): number {\n return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;\n}\n\nfunction degreesToRadians(value: number): number {\n return value * DegreesToRadians;\n}\n\nfunction normalizeAngle(value: number | undefined, fallback: number): number {\n return value === undefined || !Number.isFinite(value) ? fallback : value;\n}\n\nfunction isValidPieChartPoint(datum: PieChartPoint): boolean {\n return Number.isFinite(datum.value) && datum.value > 0;\n}\n"],"mappings":"AAAA,SAAS,WAAW;AAEpB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,MAAM,mBAAmB,KAAK,KAAK;AAE5B,SAAS,oBAAoB,OAAwC;AAC1E,QAAM,OAAO,MAAM,KAAK,OAAO,oBAAoB;AACnD,QAAM,QAAQ,KAAK,OAAO,CAAC,KAAK,UAAU,MAAM,MAAM,OAAO,CAAC;AAC9D,QAAM,EAAE,QAAQ,aAAa,YAAY,IAAI;AAAA,IAC3C,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAEA,MAAI,KAAK,WAAW,KAAK,eAAe,GAAG;AACzC,WAAO,EAAE,aAAa,CAAC,GAAG,OAAO,EAAE;AAAA,EACrC;AAEA,QAAM,aAAa;AAAA,IACjB,eAAe,MAAM,YAAY,oBAAoB;AAAA,EACvD;AACA,QAAM,WAAW;AAAA,IACf,eAAe,MAAM,UAAU,kBAAkB;AAAA,EACnD;AACA,QAAM,WAAW,KAAK;AAAA,IACpB;AAAA,IACA,iBAAiB,eAAe,MAAM,UAAU,kBAAkB,CAAC;AAAA,EACrE;AACA,QAAM,OAAO,IAAmB,EAC7B,MAAM,CAAC,UAAU,MAAM,KAAK,EAC5B,KAAK,IAAI,EACT,WAAW,UAAU,EACrB,SAAS,QAAQ,EACjB,SAAS,QAAQ,EAAE,IAAI;AAC1B,QAAM,cAAoC,KAAK,IAAI,CAAC,gBAAgB;AAAA,IAClE,OAAO,WAAW;AAAA,IAClB,OAAO,WAAW;AAAA,IAClB;AAAA,IACA,YAAY,WAAW;AAAA,IACvB,UAAU,WAAW;AAAA,IACrB,UAAU,WAAW;AAAA,IACrB,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACF,EAAE;AAEF,SAAO,EAAE,aAAa,MAAM;AAC9B;AAEO,SAAS,oBACd,MACA,mBAAmB,uBACnB,mBAAmB,uBACnB;AACA,QAAM,gBAAgB,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,OAAO,KAAK,MAAM,IAAI,CAAC;AACvE,QAAM,qBAAqB;AAAA,IACzB,OAAO,SAAS,gBAAgB,IAC5B,mBACA;AAAA,EACN;AACA,QAAM,qBAAqB,KAAK;AAAA,IAC9B;AAAA,MACE,OAAO,SAAS,gBAAgB,IAC5B,mBACA;AAAA,IACN;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,MACN,GAAG,KAAK,IAAI,KAAK,QAAQ;AAAA,MACzB,GAAG,KAAK,IAAI,KAAK,SAAS;AAAA,IAC5B;AAAA,IACA,aAAa,gBAAgB;AAAA,IAC7B,aAAa,gBAAgB;AAAA,EAC/B;AACF;AAEO,SAAS,qBAAqB,OAAuB;AAC1D,SAAO,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI;AACpE;AAEA,SAAS,iBAAiB,OAAuB;AAC/C,SAAO,QAAQ;AACjB;AAEA,SAAS,eAAe,OAA2B,UAA0B;AAC3E,SAAO,UAAU,UAAa,CAAC,OAAO,SAAS,KAAK,IAAI,WAAW;AACrE;AAEA,SAAS,qBAAqB,OAA+B;AAC3D,SAAO,OAAO,SAAS,MAAM,KAAK,KAAK,MAAM,QAAQ;AACvD;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SkPath } from '@shopify/react-native-skia';
|
|
2
|
+
import { PieChartCoordinate } from '../types/pie-chart.types.mjs';
|
|
3
|
+
import '../types/common.types.mjs';
|
|
4
|
+
import '../types/style.types.mjs';
|
|
5
|
+
|
|
6
|
+
declare function createPieSlicePath(coordinate: PieChartCoordinate, cornerRadius?: number): SkPath | null;
|
|
7
|
+
|
|
8
|
+
export { createPieSlicePath };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Skia } from "@shopify/react-native-skia";
|
|
2
|
+
import { arc } from "d3-shape";
|
|
3
|
+
function createPieSlicePath(coordinate, cornerRadius = 0) {
|
|
4
|
+
const pathData = arc().cornerRadius(Math.max(0, cornerRadius)).padRadius(coordinate.padRadius)({
|
|
5
|
+
innerRadius: coordinate.innerRadius,
|
|
6
|
+
outerRadius: coordinate.outerRadius,
|
|
7
|
+
startAngle: coordinate.startAngle,
|
|
8
|
+
endAngle: coordinate.endAngle,
|
|
9
|
+
padAngle: coordinate.padAngle
|
|
10
|
+
});
|
|
11
|
+
if (!pathData) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return Skia.Path.MakeFromSVGString(pathData);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
createPieSlicePath
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=pie.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/pie.util.ts"],"sourcesContent":["import { Skia, SkPath } from \"@shopify/react-native-skia\";\nimport { arc } from \"d3-shape\";\n\nimport { PieChartCoordinate } from \"../types\";\n\nexport function createPieSlicePath(\n coordinate: PieChartCoordinate,\n cornerRadius = 0,\n): SkPath | null {\n const pathData = arc()\n .cornerRadius(Math.max(0, cornerRadius))\n .padRadius(coordinate.padRadius)({\n innerRadius: coordinate.innerRadius,\n outerRadius: coordinate.outerRadius,\n startAngle: coordinate.startAngle,\n endAngle: coordinate.endAngle,\n padAngle: coordinate.padAngle,\n });\n\n if (!pathData) {\n return null;\n }\n\n return Skia.Path.MakeFromSVGString(pathData);\n}\n"],"mappings":"AAAA,SAAS,YAAoB;AAC7B,SAAS,WAAW;AAIb,SAAS,mBACd,YACA,eAAe,GACA;AACf,QAAM,WAAW,IAAI,EAClB,aAAa,KAAK,IAAI,GAAG,YAAY,CAAC,EACtC,UAAU,WAAW,SAAS,EAAE;AAAA,IACjC,aAAa,WAAW;AAAA,IACxB,aAAa,WAAW;AAAA,IACxB,YAAY,WAAW;AAAA,IACvB,UAAU,WAAW;AAAA,IACrB,UAAU,WAAW;AAAA,EACvB,CAAC;AAED,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,SAAO,KAAK,KAAK,kBAAkB,QAAQ;AAC7C;","names":[]}
|