@impulse-ui-native/charts 2.1.1 → 2.3.0
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 +97 -6
- package/dist/components/bar-chart/bar-chart-body.d.mts +15 -0
- package/dist/components/bar-chart/bar-chart-body.js +50 -0
- package/dist/components/bar-chart/bar-chart-body.js.map +1 -0
- package/dist/components/bar-chart/bar-chart.d.mts +11 -0
- package/dist/components/bar-chart/bar-chart.js +21 -0
- 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/chart-axes.d.mts +22 -0
- package/dist/components/chart-axes/chart-axes.js +64 -0
- 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 +14 -2
- package/dist/components/index.js +9 -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 -9
- 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/multi-bar-chart-body.d.mts +16 -0
- package/dist/components/multi-bar-chart/multi-bar-chart-body.js +72 -0
- package/dist/components/multi-bar-chart/multi-bar-chart-body.js.map +1 -0
- package/dist/components/multi-bar-chart/multi-bar-chart.d.mts +12 -0
- package/dist/components/multi-bar-chart/multi-bar-chart.js +21 -0
- 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} +4 -7
- 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/bar.d.mts +12 -0
- package/dist/components/primitives/bar.js +44 -0
- package/dist/components/primitives/bar.js.map +1 -0
- package/dist/components/primitives/index.d.mts +6 -0
- package/dist/components/primitives/index.js +4 -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/bar-chart.constants.d.mts +4 -0
- package/dist/constants/bar-chart.constants.js +7 -0
- package/dist/constants/bar-chart.constants.js.map +1 -0
- package/dist/constants/bar.constants.d.mts +8 -0
- package/dist/constants/bar.constants.js +12 -0
- package/dist/constants/bar.constants.js.map +1 -0
- package/dist/constants/index.d.mts +4 -1
- package/dist/constants/index.js +3 -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 +14 -1
- package/dist/hooks/index.js +11 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-bar-chart.hook.d.mts +11 -0
- package/dist/hooks/use-bar-chart.hook.js +13 -0
- package/dist/hooks/use-bar-chart.hook.js.map +1 -0
- package/dist/hooks/use-chart-layout.hook.d.mts +7 -0
- package/dist/hooks/use-chart-layout.hook.js +9 -0
- package/dist/hooks/use-chart-layout.hook.js.map +1 -0
- package/dist/hooks/use-multi-bar-chart.hook.d.mts +13 -0
- package/dist/hooks/use-multi-bar-chart.hook.js +20 -0
- package/dist/hooks/use-multi-bar-chart.hook.js.map +1 -0
- 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 +32 -3
- package/dist/types/bar-chart.types.d.mts +38 -0
- package/dist/types/bar-chart.types.js +1 -0
- package/dist/types/bar-chart.types.js.map +1 -0
- package/dist/types/bar.types.d.mts +12 -0
- package/dist/types/bar.types.js +1 -0
- package/dist/types/bar.types.js.map +1 -0
- package/dist/types/index.d.mts +10 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/multi-bar-chart.types.d.mts +21 -0
- package/dist/types/multi-bar-chart.types.js +1 -0
- package/dist/types/multi-bar-chart.types.js.map +1 -0
- 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-bar-chart.types.d.mts +26 -0
- package/dist/types/use-bar-chart.types.js +1 -0
- package/dist/types/use-bar-chart.types.js.map +1 -0
- package/dist/types/use-multi-bar-chart.types.d.mts +17 -0
- package/dist/types/use-multi-bar-chart.types.js +1 -0
- package/dist/types/use-multi-bar-chart.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/bar-chart.util.d.mts +25 -0
- package/dist/utils/bar-chart.util.js +145 -0
- package/dist/utils/bar-chart.util.js.map +1 -0
- package/dist/utils/grid.util.js +4 -4
- package/dist/utils/grid.util.js.map +1 -1
- package/dist/utils/index.d.mts +13 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/multi-bar-chart.util.d.mts +14 -0
- package/dist/utils/multi-bar-chart.util.js +62 -0
- package/dist/utils/multi-bar-chart.util.js.map +1 -0
- 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/line-chart-body.js.map +0 -1
- package/dist/components/line-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
package/README.md
CHANGED
|
@@ -1,14 +1,105 @@
|
|
|
1
1
|
# @impulse-ui-native/charts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Skia-rendered chart components and primitives for Impulse UI Native.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Components
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The package provides Skia-rendered `LineChart`, `MultiLineChart`, `BarChart`, `MultiBarChart`, `PieChart`, and `MultiPieChart` components. Charts fill their parent, so give the surrounding view an explicit height.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```tsx
|
|
10
|
+
import { BarChart } from "@impulse-ui-native/charts";
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
<BarChart
|
|
13
|
+
data={[
|
|
14
|
+
{ x: "Jan", y: 18 },
|
|
15
|
+
{ x: "Feb", y: 24 },
|
|
16
|
+
{ x: "Mar", y: 16 },
|
|
17
|
+
]}
|
|
18
|
+
insets={{ left: 40, bottom: 28 }}
|
|
19
|
+
bar={{ color: "#6366f1", radius: 4 }}
|
|
20
|
+
/>;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Use `MultiBarChart` for grouped series. Categories are shared across the series, and each series can supply its own bar style.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { MultiBarChart } from "@impulse-ui-native/charts";
|
|
27
|
+
|
|
28
|
+
<MultiBarChart
|
|
29
|
+
series={[
|
|
30
|
+
{
|
|
31
|
+
id: "revenue",
|
|
32
|
+
data: [
|
|
33
|
+
{ x: "Jan", y: 18 },
|
|
34
|
+
{ x: "Feb", y: 24 },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "cost",
|
|
39
|
+
data: [
|
|
40
|
+
{ x: "Jan", y: 12 },
|
|
41
|
+
{ x: "Feb", y: 15 },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
]}
|
|
45
|
+
categoryPadding={0.2}
|
|
46
|
+
seriesPadding={0.1}
|
|
47
|
+
insets={{ left: 40, bottom: 28 }}
|
|
48
|
+
/>;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Bar charts support string, number, and `Date` categories, nullable values, positive and negative values, custom Y domains, axes, and grid styling. Inferred Y domains include zero.
|
|
52
|
+
|
|
53
|
+
`categoryPadding` and `seriesPadding` are ratios clamped between `0` and `1`. Multi-series bars use the theme's chart palette unless a series supplies `bar.color`.
|
|
54
|
+
|
|
55
|
+
Use `PieChart` for pies and donuts. Slice values must be positive finite numbers; invalid, zero, and negative values are ignored. Colors follow the chart palette unless a datum supplies `color`.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { PieChart } from "@impulse-ui-native/charts";
|
|
59
|
+
|
|
60
|
+
<PieChart
|
|
61
|
+
data={[
|
|
62
|
+
{ id: "mobile", value: 46 },
|
|
63
|
+
{ id: "desktop", value: 34 },
|
|
64
|
+
{ id: "tablet", value: 20 },
|
|
65
|
+
]}
|
|
66
|
+
innerRadius={0.5}
|
|
67
|
+
outerRadius={0.9}
|
|
68
|
+
padAngle={2}
|
|
69
|
+
slice={{ cornerRadius: 4, strokeColor: "#fff", strokeWidth: 2 }}
|
|
70
|
+
/>;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`innerRadius` and `outerRadius` are ratios of the available radius and are clamped between `0` and `1`. Angles use degrees, measured clockwise from 12 o'clock. The defaults render a complete circle from `0` through `360` degrees.
|
|
74
|
+
|
|
75
|
+
Use `MultiPieChart` for independently normalized concentric series. The first series is the outermost ring, and angular padding keeps a consistent visual width across all rings.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { MultiPieChart } from "@impulse-ui-native/charts";
|
|
79
|
+
|
|
80
|
+
<MultiPieChart
|
|
81
|
+
series={[
|
|
82
|
+
{
|
|
83
|
+
id: "current",
|
|
84
|
+
data: [
|
|
85
|
+
{ id: "organic", value: 42 },
|
|
86
|
+
{ id: "paid", value: 33 },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "previous",
|
|
91
|
+
data: [
|
|
92
|
+
{ id: "organic", value: 36 },
|
|
93
|
+
{ id: "paid", value: 29 },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
]}
|
|
97
|
+
innerRadius={0.25}
|
|
98
|
+
ringPadding={4}
|
|
99
|
+
/>;
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Scope
|
|
12
103
|
|
|
13
104
|
- Token-aware chart primitives for React Native.
|
|
14
105
|
- Skia-based rendering.
|
|
@@ -17,4 +108,4 @@ Do not depend on `@impulse-ui-native/charts` for application code until its firs
|
|
|
17
108
|
|
|
18
109
|
## Native prerequisite
|
|
19
110
|
|
|
20
|
-
|
|
111
|
+
Chart APIs require `@shopify/react-native-skia` version 2 or newer. Follow Skia's platform setup instructions before using them.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { AppTheme } from '@impulse-ui-native/theme';
|
|
3
|
+
import { ChartSize } from '../../types/common.types.mjs';
|
|
4
|
+
import { b as ChartXValue } from '../../line-chart.types-yxru5uWc.mjs';
|
|
5
|
+
import { BarChartProps } from '../../types/bar-chart.types.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
import '@shopify/react-native-skia';
|
|
8
|
+
|
|
9
|
+
interface BarChartBodyProps<X extends ChartXValue> extends BarChartProps<X> {
|
|
10
|
+
size: ChartSize;
|
|
11
|
+
theme: AppTheme;
|
|
12
|
+
}
|
|
13
|
+
declare const BarChartBody: <X extends ChartXValue = string>(props: BarChartBodyProps<X>) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
|
|
15
|
+
export { BarChartBody };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Group } from "@shopify/react-native-skia";
|
|
3
|
+
import { memo } from "@impulse-ui-native/core";
|
|
4
|
+
import { useBarChart, useChartLayout } from "../../hooks";
|
|
5
|
+
import { ChartAxes } from "../chart-axes";
|
|
6
|
+
import { Bar } from "../primitives";
|
|
7
|
+
const BarChartBody = memo(function BarChartBodyComponent(props) {
|
|
8
|
+
const {
|
|
9
|
+
bar,
|
|
10
|
+
categoryPadding,
|
|
11
|
+
data,
|
|
12
|
+
fontManager,
|
|
13
|
+
grid,
|
|
14
|
+
insets,
|
|
15
|
+
size,
|
|
16
|
+
theme,
|
|
17
|
+
xAxis,
|
|
18
|
+
yAxis
|
|
19
|
+
} = props;
|
|
20
|
+
const layout = useChartLayout(size, insets);
|
|
21
|
+
const { coordinates, xScale, xTicks, yScale, yTicks } = useBarChart({
|
|
22
|
+
categoryPadding,
|
|
23
|
+
data,
|
|
24
|
+
plot: layout.plot,
|
|
25
|
+
xAxis,
|
|
26
|
+
yAxis
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
ChartAxes,
|
|
31
|
+
{
|
|
32
|
+
fontManager,
|
|
33
|
+
grid,
|
|
34
|
+
layout,
|
|
35
|
+
theme,
|
|
36
|
+
xAxis,
|
|
37
|
+
xScale,
|
|
38
|
+
xTicks,
|
|
39
|
+
yAxis,
|
|
40
|
+
yScale,
|
|
41
|
+
yTicks
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsx(Group, { clip: layout.plot, children: /* @__PURE__ */ jsx(Bar, { coordinates, ...bar }) })
|
|
45
|
+
] });
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
BarChartBody
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=bar-chart-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/bar-chart/bar-chart-body.tsx"],"sourcesContent":["import { Group } from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\nimport { AppTheme } from \"@impulse-ui-native/theme\";\n\nimport { useBarChart, useChartLayout } from \"../../hooks\";\nimport { BarChartProps, ChartSize, ChartXValue } from \"../../types\";\nimport { ChartAxes } from \"../chart-axes\";\nimport { Bar } from \"../primitives\";\n\ninterface BarChartBodyProps<X extends ChartXValue> extends BarChartProps<X> {\n size: ChartSize;\n theme: AppTheme;\n}\n\nexport const BarChartBody = memo(function BarChartBodyComponent<\n X extends ChartXValue = string,\n>(props: BarChartBodyProps<X>) {\n const {\n bar,\n categoryPadding,\n data,\n fontManager,\n grid,\n insets,\n size,\n theme,\n xAxis,\n yAxis,\n } = props;\n const layout = useChartLayout(size, insets);\n const { coordinates, xScale, xTicks, yScale, yTicks } = useBarChart({\n categoryPadding,\n data,\n plot: layout.plot,\n xAxis,\n yAxis,\n });\n\n return (\n <>\n <ChartAxes\n fontManager={fontManager}\n grid={grid}\n layout={layout}\n theme={theme}\n xAxis={xAxis}\n xScale={xScale}\n xTicks={xTicks}\n yAxis={yAxis}\n yScale={yScale}\n yTicks={yTicks}\n />\n\n <Group clip={layout.plot}>\n <Bar coordinates={coordinates} {...bar} />\n </Group>\n </>\n );\n});\n"],"mappings":"AAwCI,mBACE,KADF;AAxCJ,SAAS,aAAa;AAEtB,SAAS,YAAY;AAGrB,SAAS,aAAa,sBAAsB;AAE5C,SAAS,iBAAiB;AAC1B,SAAS,WAAW;AAOb,MAAM,eAAe,KAAK,SAAS,sBAExC,OAA6B;AAC7B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,SAAS,eAAe,MAAM,MAAM;AAC1C,QAAM,EAAE,aAAa,QAAQ,QAAQ,QAAQ,OAAO,IAAI,YAAY;AAAA,IAClE;AAAA,IACA;AAAA,IACA,MAAM,OAAO;AAAA,IACb;AAAA,IACA;AAAA,EACF,CAAC;AAED,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,IAEA,oBAAC,SAAM,MAAM,OAAO,MAClB,8BAAC,OAAI,aAA2B,GAAG,KAAK,GAC1C;AAAA,KACF;AAEJ,CAAC;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { b as ChartXValue } from '../../line-chart.types-yxru5uWc.mjs';
|
|
3
|
+
import { BarChartProps } from '../../types/bar-chart.types.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
import '../../types/common.types.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
import '@impulse-ui-native/theme';
|
|
8
|
+
|
|
9
|
+
declare const BarChart: <X extends ChartXValue = string>(props: BarChartProps<X>) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { BarChart };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { Canvas } from "@shopify/react-native-skia";
|
|
4
|
+
import { memo } from "@impulse-ui-native/core";
|
|
5
|
+
import { useTheme } from "@impulse-ui-native/theme";
|
|
6
|
+
import { useChartCanvas } from "../../hooks";
|
|
7
|
+
import { BarChartBody } from "./bar-chart-body";
|
|
8
|
+
const BarChart = memo(function BarChart2(props) {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const { ref, size } = useChartCanvas();
|
|
11
|
+
return /* @__PURE__ */ jsx(Canvas, { ref, style: styles.container, children: /* @__PURE__ */ jsx(BarChartBody, { ...props, size, theme }) });
|
|
12
|
+
});
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
container: {
|
|
15
|
+
flex: 1
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
BarChart
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=bar-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/bar-chart/bar-chart.tsx"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport { Canvas } from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\nimport { useTheme } from \"@impulse-ui-native/theme\";\n\nimport { useChartCanvas } from \"../../hooks\";\nimport { BarChartProps, ChartXValue } from \"../../types\";\nimport { BarChartBody } from \"./bar-chart-body\";\n\nexport const BarChart = memo(function BarChart<X extends ChartXValue = string>(\n props: BarChartProps<X>,\n) {\n const theme = useTheme();\n const { ref, size } = useChartCanvas();\n\n return (\n <Canvas ref={ref} style={styles.container}>\n <BarChartBody {...props} size={size} theme={theme} />\n </Canvas>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"],"mappings":"AAkBM;AAlBN,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEvB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB;AAE/B,SAAS,oBAAoB;AAEtB,MAAM,WAAW,KAAK,SAASA,UACpC,OACA;AACA,QAAM,QAAQ,SAAS;AACvB,QAAM,EAAE,KAAK,KAAK,IAAI,eAAe;AAErC,SACE,oBAAC,UAAO,KAAU,OAAO,OAAO,WAC9B,8BAAC,gBAAc,GAAG,OAAO,MAAY,OAAc,GACrD;AAEJ,CAAC;AAED,MAAM,SAAS,WAAW,OAAO;AAAA,EAC/B,WAAW;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":["BarChart"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BarChart } from './bar-chart.mjs';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import '../../line-chart.types-yxru5uWc.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
import '../../types/common.types.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
import '@impulse-ui-native/theme';
|
|
8
|
+
import '../../types/bar-chart.types.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/bar-chart/index.ts"],"sourcesContent":["export { BarChart } from \"./bar-chart\";\n"],"mappings":"AAAA,SAAS,gBAAgB;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SkTypefaceFontProvider } from '@shopify/react-native-skia';
|
|
3
|
+
import { AppTheme } from '@impulse-ui-native/theme';
|
|
4
|
+
import { ChartLayout, ChartXAxisOptions, ChartYAxisOptions } from '../../types/common.types.mjs';
|
|
5
|
+
import { b as ChartXValue, a as ChartGridOptions, h as LineChartScale } from '../../line-chart.types-yxru5uWc.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
|
|
8
|
+
interface ChartAxesProps<X extends ChartXValue> {
|
|
9
|
+
fontManager?: SkTypefaceFontProvider;
|
|
10
|
+
grid?: ChartGridOptions;
|
|
11
|
+
layout: ChartLayout;
|
|
12
|
+
theme: AppTheme;
|
|
13
|
+
xAxis?: ChartXAxisOptions<X>;
|
|
14
|
+
xScale: LineChartScale<X>;
|
|
15
|
+
xTicks: readonly X[];
|
|
16
|
+
yAxis?: ChartYAxisOptions;
|
|
17
|
+
yScale: LineChartScale<number>;
|
|
18
|
+
yTicks: readonly number[];
|
|
19
|
+
}
|
|
20
|
+
declare const ChartAxes: <X extends ChartXValue = number>(props: ChartAxesProps<X>) => react_jsx_runtime.JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { ChartAxes };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "@impulse-ui-native/core";
|
|
3
|
+
import { Grid, XAxis, YAxis } from "../primitives";
|
|
4
|
+
const ChartAxes = memo(function ChartAxes2(props) {
|
|
5
|
+
const {
|
|
6
|
+
fontManager,
|
|
7
|
+
grid,
|
|
8
|
+
layout,
|
|
9
|
+
theme,
|
|
10
|
+
xAxis,
|
|
11
|
+
xScale,
|
|
12
|
+
xTicks,
|
|
13
|
+
yAxis,
|
|
14
|
+
yScale,
|
|
15
|
+
yTicks
|
|
16
|
+
} = props;
|
|
17
|
+
const isGridStyle = grid !== void 0;
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
isGridStyle ? /* @__PURE__ */ jsx(
|
|
20
|
+
Grid,
|
|
21
|
+
{
|
|
22
|
+
options: grid,
|
|
23
|
+
plot: layout.plot,
|
|
24
|
+
theme,
|
|
25
|
+
xTicks,
|
|
26
|
+
xScale,
|
|
27
|
+
yTicks,
|
|
28
|
+
yScale
|
|
29
|
+
}
|
|
30
|
+
) : null,
|
|
31
|
+
xAxis?.visible !== false ? /* @__PURE__ */ jsx(
|
|
32
|
+
XAxis,
|
|
33
|
+
{
|
|
34
|
+
ticks: xTicks,
|
|
35
|
+
scale: xScale,
|
|
36
|
+
plot: layout.plot,
|
|
37
|
+
region: layout.xAxis,
|
|
38
|
+
theme,
|
|
39
|
+
options: xAxis,
|
|
40
|
+
fontManager,
|
|
41
|
+
lineVisible: !isGridStyle,
|
|
42
|
+
tickVisible: !isGridStyle
|
|
43
|
+
}
|
|
44
|
+
) : null,
|
|
45
|
+
yAxis?.visible !== false ? /* @__PURE__ */ jsx(
|
|
46
|
+
YAxis,
|
|
47
|
+
{
|
|
48
|
+
ticks: yTicks,
|
|
49
|
+
scale: yScale,
|
|
50
|
+
plot: layout.plot,
|
|
51
|
+
region: layout.yAxis,
|
|
52
|
+
theme,
|
|
53
|
+
options: yAxis,
|
|
54
|
+
fontManager,
|
|
55
|
+
lineVisible: !isGridStyle,
|
|
56
|
+
tickVisible: !isGridStyle
|
|
57
|
+
}
|
|
58
|
+
) : null
|
|
59
|
+
] });
|
|
60
|
+
});
|
|
61
|
+
export {
|
|
62
|
+
ChartAxes
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=chart-axes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chart-axes/chart-axes.tsx"],"sourcesContent":["import { SkTypefaceFontProvider } from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\nimport { AppTheme } from \"@impulse-ui-native/theme\";\n\nimport {\n ChartGridOptions,\n ChartLayout,\n ChartXAxisOptions,\n ChartXValue,\n ChartYAxisOptions,\n LineChartScale,\n} from \"../../types\";\nimport { Grid, XAxis, YAxis } from \"../primitives\";\n\ninterface ChartAxesProps<X extends ChartXValue> {\n fontManager?: SkTypefaceFontProvider;\n grid?: ChartGridOptions;\n layout: ChartLayout;\n theme: AppTheme;\n xAxis?: ChartXAxisOptions<X>;\n xScale: LineChartScale<X>;\n xTicks: readonly X[];\n yAxis?: ChartYAxisOptions;\n yScale: LineChartScale<number>;\n yTicks: readonly number[];\n}\n\nexport const ChartAxes = memo(function ChartAxes<\n X extends ChartXValue = number,\n>(props: ChartAxesProps<X>) {\n const {\n fontManager,\n grid,\n layout,\n theme,\n xAxis,\n xScale,\n xTicks,\n yAxis,\n yScale,\n yTicks,\n } = props;\n const isGridStyle = grid !== undefined;\n\n return (\n <>\n {isGridStyle ? (\n <Grid\n options={grid}\n plot={layout.plot}\n theme={theme}\n xTicks={xTicks}\n xScale={xScale}\n yTicks={yTicks}\n yScale={yScale}\n />\n ) : null}\n\n {xAxis?.visible !== false ? (\n <XAxis\n ticks={xTicks}\n scale={xScale}\n plot={layout.plot}\n region={layout.xAxis}\n theme={theme}\n options={xAxis}\n fontManager={fontManager}\n lineVisible={!isGridStyle}\n tickVisible={!isGridStyle}\n />\n ) : null}\n\n {yAxis?.visible !== false ? (\n <YAxis\n ticks={yTicks}\n scale={yScale}\n plot={layout.plot}\n region={layout.yAxis}\n theme={theme}\n options={yAxis}\n fontManager={fontManager}\n lineVisible={!isGridStyle}\n tickVisible={!isGridStyle}\n />\n ) : null}\n </>\n );\n});\n"],"mappings":"AA8CI,mBAEI,KAFJ;AA5CJ,SAAS,YAAY;AAWrB,SAAS,MAAM,OAAO,aAAa;AAe5B,MAAM,YAAY,KAAK,SAASA,WAErC,OAA0B;AAC1B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,cAAc,SAAS;AAE7B,SACE,iCACG;AAAA,kBACC;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,MAAM,OAAO;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,IACE;AAAA,IAEH,OAAO,YAAY,QAClB;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,OAAO;AAAA,QACP,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA,aAAa,CAAC;AAAA,QACd,aAAa,CAAC;AAAA;AAAA,IAChB,IACE;AAAA,IAEH,OAAO,YAAY,QAClB;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,OAAO;AAAA,QACP,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA,aAAa,CAAC;AAAA,QACd,aAAa,CAAC;AAAA;AAAA,IAChB,IACE;AAAA,KACN;AAEJ,CAAC;","names":["ChartAxes"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ChartAxes } from './chart-axes.mjs';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import '@shopify/react-native-skia';
|
|
4
|
+
import '@impulse-ui-native/theme';
|
|
5
|
+
import '../../types/common.types.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
import '../../line-chart.types-yxru5uWc.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chart-axes/index.ts"],"sourcesContent":["export { ChartAxes } from \"./chart-axes\";\n"],"mappings":"AAAA,SAAS,iBAAiB;","names":[]}
|
|
@@ -1,17 +1,29 @@
|
|
|
1
|
+
export { Bar } from './primitives/bar.mjs';
|
|
1
2
|
export { Grid } from './primitives/grid.mjs';
|
|
2
3
|
export { Label } from './primitives/label.mjs';
|
|
3
4
|
export { Line } from './primitives/line.mjs';
|
|
5
|
+
export { Pie } from './primitives/pie.mjs';
|
|
4
6
|
export { XAxis } from './primitives/x-axis.mjs';
|
|
5
7
|
export { YAxis } from './primitives/y-axis.mjs';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
+
export { BarChart } from './bar-chart/bar-chart.mjs';
|
|
9
|
+
export { LineChart } from './line-chart/line-chart.mjs';
|
|
10
|
+
export { MultiBarChart } from './multi-bar-chart/multi-bar-chart.mjs';
|
|
11
|
+
export { MultiLineChart } from './multi-line-chart/multi-line-chart.mjs';
|
|
12
|
+
export { MultiPieChart } from './multi-pie-chart/multi-pie-chart.mjs';
|
|
13
|
+
export { PieChart } from './pie-chart/pie-chart.mjs';
|
|
8
14
|
import 'react/jsx-runtime';
|
|
9
15
|
import '../line-chart.types-yxru5uWc.mjs';
|
|
10
16
|
import '@shopify/react-native-skia';
|
|
11
17
|
import '../types/common.types.mjs';
|
|
12
18
|
import '../types/style.types.mjs';
|
|
13
19
|
import '@impulse-ui-native/theme';
|
|
20
|
+
import '../types/bar.types.mjs';
|
|
21
|
+
import '../types/bar-chart.types.mjs';
|
|
14
22
|
import '../types/label.types.mjs';
|
|
15
23
|
import '../types/line.types.mjs';
|
|
24
|
+
import '../types/pie.types.mjs';
|
|
25
|
+
import '../types/pie-chart.types.mjs';
|
|
16
26
|
import '../types/axis.types.mjs';
|
|
27
|
+
import '../types/multi-bar-chart.types.mjs';
|
|
17
28
|
import '../types/multi-line-chart.types.mjs';
|
|
29
|
+
import '../types/multi-pie-chart.types.mjs';
|
package/dist/components/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
export * from "./primitives";
|
|
2
|
+
import { BarChart } from "./bar-chart";
|
|
2
3
|
import { LineChart } from "./line-chart";
|
|
4
|
+
import { MultiBarChart } from "./multi-bar-chart";
|
|
3
5
|
import { MultiLineChart } from "./multi-line-chart";
|
|
6
|
+
import { MultiPieChart } from "./multi-pie-chart";
|
|
7
|
+
import { PieChart } from "./pie-chart";
|
|
4
8
|
export {
|
|
9
|
+
BarChart,
|
|
5
10
|
LineChart,
|
|
6
|
-
|
|
11
|
+
MultiBarChart,
|
|
12
|
+
MultiLineChart,
|
|
13
|
+
MultiPieChart,
|
|
14
|
+
PieChart
|
|
7
15
|
};
|
|
8
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["export * from \"./primitives\";\nexport { LineChart } from \"./line-chart\";\nexport { MultiLineChart } from \"./multi-line-chart\";\n"],"mappings":"AAAA,cAAc;AACd,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["export * from \"./primitives\";\nexport { BarChart } from \"./bar-chart\";\nexport { LineChart } from \"./line-chart\";\nexport { MultiBarChart } from \"./multi-bar-chart\";\nexport { MultiLineChart } from \"./multi-line-chart\";\nexport { MultiPieChart } from \"./multi-pie-chart\";\nexport { PieChart } from \"./pie-chart\";\n"],"mappings":"AAAA,cAAc;AACd,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { LineChart } from './line-chart.mjs';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import '../../line-chart.types-yxru5uWc.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
import '../../types/common.types.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
import '@impulse-ui-native/theme';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/line-chart/index.ts"],"sourcesContent":["export { LineChart } from \"./line-chart\";\n"],"mappings":"AAAA,SAAS,iBAAiB;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { AppTheme } from '@impulse-ui-native/theme';
|
|
3
|
-
import { ChartSize } from '
|
|
4
|
-
import { b as ChartXValue, g as LineChartProps } from '
|
|
5
|
-
import '
|
|
3
|
+
import { ChartSize } from '../../types/common.types.mjs';
|
|
4
|
+
import { b as ChartXValue, g as LineChartProps } from '../../line-chart.types-yxru5uWc.mjs';
|
|
5
|
+
import '../../types/style.types.mjs';
|
|
6
6
|
import '@shopify/react-native-skia';
|
|
7
7
|
|
|
8
8
|
interface LineChartBodyProps<X extends ChartXValue> extends LineChartProps<X> {
|
|
@@ -2,14 +2,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { Group } from "@shopify/react-native-skia";
|
|
4
4
|
import { memo } from "@impulse-ui-native/core";
|
|
5
|
-
import { LineDefaultWidth } from "
|
|
6
|
-
import { useLineChart } from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
createInsetRect,
|
|
10
|
-
fitLineCoordinatesToRect
|
|
11
|
-
} from "../utils";
|
|
12
|
-
import { Grid, Line, XAxis, YAxis } from "./primitives";
|
|
5
|
+
import { LineDefaultWidth } from "../../constants";
|
|
6
|
+
import { useChartLayout, useLineChart } from "../../hooks";
|
|
7
|
+
import { createInsetRect, fitLineCoordinatesToRect } from "../../utils";
|
|
8
|
+
import { Grid, Line, XAxis, YAxis } from "../primitives";
|
|
13
9
|
const LineChartBody = memo(function LineChartBodyComponent(props) {
|
|
14
10
|
const {
|
|
15
11
|
data,
|
|
@@ -23,7 +19,7 @@ const LineChartBody = memo(function LineChartBodyComponent(props) {
|
|
|
23
19
|
xScaleType,
|
|
24
20
|
yAxis
|
|
25
21
|
} = props;
|
|
26
|
-
const layout =
|
|
22
|
+
const layout = useChartLayout(size, insets);
|
|
27
23
|
const { coordinates, xScale, xTicks, yScale, yTicks } = useLineChart({
|
|
28
24
|
data,
|
|
29
25
|
plot: layout.plot,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/line-chart/line-chart-body.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Group } from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\nimport { AppTheme } from \"@impulse-ui-native/theme\";\n\nimport { LineDefaultWidth } from \"../../constants\";\nimport { useChartLayout, useLineChart } from \"../../hooks\";\nimport { ChartSize, ChartXValue, LineChartProps } from \"../../types\";\nimport { createInsetRect, fitLineCoordinatesToRect } from \"../../utils\";\nimport { Grid, Line, XAxis, YAxis } from \"../primitives\";\n\ninterface LineChartBodyProps<X extends ChartXValue> extends LineChartProps<X> {\n size: ChartSize;\n theme: AppTheme;\n}\n\nexport const LineChartBody = memo(function LineChartBodyComponent<\n X extends ChartXValue = number,\n>(props: LineChartBodyProps<X>) {\n const {\n data,\n fontManager,\n grid,\n insets,\n line,\n size,\n theme,\n xAxis,\n xScaleType,\n yAxis,\n } = props;\n\n const layout = useChartLayout(size, insets);\n\n const { coordinates, xScale, xTicks, yScale, yTicks } = useLineChart({\n data,\n plot: layout.plot,\n xAxis,\n xScaleType,\n yAxis,\n });\n\n const linePlot = useMemo(\n () => createInsetRect(layout.plot, (line?.width ?? LineDefaultWidth) / 2),\n [layout.plot, line?.width],\n );\n\n const lineCoordinates = useMemo(\n () => fitLineCoordinatesToRect(coordinates, layout.plot, linePlot),\n [coordinates, layout.plot, linePlot],\n );\n\n const isGridStyle = grid !== undefined;\n\n return (\n <>\n {isGridStyle ? (\n <Grid\n options={grid}\n plot={layout.plot}\n theme={theme}\n xTicks={xTicks}\n xScale={xScale}\n yTicks={yTicks}\n yScale={yScale}\n />\n ) : null}\n\n {xAxis?.visible !== false ? (\n <XAxis\n ticks={xTicks}\n scale={xScale}\n plot={layout.plot}\n region={layout.xAxis}\n theme={theme}\n options={xAxis}\n fontManager={fontManager}\n lineVisible={!isGridStyle}\n tickVisible={!isGridStyle}\n />\n ) : null}\n\n {yAxis?.visible !== false ? (\n <YAxis\n ticks={yTicks}\n scale={yScale}\n plot={layout.plot}\n region={layout.yAxis}\n theme={theme}\n options={yAxis}\n fontManager={fontManager}\n lineVisible={!isGridStyle}\n tickVisible={!isGridStyle}\n />\n ) : null}\n\n <Group clip={layout.plot}>\n <Line coordinates={lineCoordinates} {...line} />\n </Group>\n </>\n );\n});\n"],"mappings":"AAwDI,mBAEI,KAFJ;AAxDJ,SAAS,eAAe;AACxB,SAAS,aAAa;AAEtB,SAAS,YAAY;AAGrB,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,oBAAoB;AAE7C,SAAS,iBAAiB,gCAAgC;AAC1D,SAAS,MAAM,MAAM,OAAO,aAAa;AAOlC,MAAM,gBAAgB,KAAK,SAAS,uBAEzC,OAA8B;AAC9B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,SAAS,eAAe,MAAM,MAAM;AAE1C,QAAM,EAAE,aAAa,QAAQ,QAAQ,QAAQ,OAAO,IAAI,aAAa;AAAA,IACnE;AAAA,IACA,MAAM,OAAO;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,WAAW;AAAA,IACf,MAAM,gBAAgB,OAAO,OAAO,MAAM,SAAS,oBAAoB,CAAC;AAAA,IACxE,CAAC,OAAO,MAAM,MAAM,KAAK;AAAA,EAC3B;AAEA,QAAM,kBAAkB;AAAA,IACtB,MAAM,yBAAyB,aAAa,OAAO,MAAM,QAAQ;AAAA,IACjE,CAAC,aAAa,OAAO,MAAM,QAAQ;AAAA,EACrC;AAEA,QAAM,cAAc,SAAS;AAE7B,SACE,iCACG;AAAA,kBACC;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,MAAM,OAAO;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,IACE;AAAA,IAEH,OAAO,YAAY,QAClB;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,OAAO;AAAA,QACP,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA,aAAa,CAAC;AAAA,QACd,aAAa,CAAC;AAAA;AAAA,IAChB,IACE;AAAA,IAEH,OAAO,YAAY,QAClB;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,OAAO;AAAA,QACP,MAAM,OAAO;AAAA,QACb,QAAQ,OAAO;AAAA,QACf;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA,aAAa,CAAC;AAAA,QACd,aAAa,CAAC;AAAA;AAAA,IAChB,IACE;AAAA,IAEJ,oBAAC,SAAM,MAAM,OAAO,MAClB,8BAAC,QAAK,aAAa,iBAAkB,GAAG,MAAM,GAChD;AAAA,KACF;AAEJ,CAAC;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { b as ChartXValue, g as LineChartProps } from '
|
|
2
|
+
import { b as ChartXValue, g as LineChartProps } from '../../line-chart.types-yxru5uWc.mjs';
|
|
3
3
|
import '@shopify/react-native-skia';
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
4
|
+
import '../../types/common.types.mjs';
|
|
5
|
+
import '../../types/style.types.mjs';
|
|
6
6
|
import '@impulse-ui-native/theme';
|
|
7
7
|
|
|
8
8
|
declare const LineChart: <X extends ChartXValue = number>(props: LineChartProps<X>) => react_jsx_runtime.JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { StyleSheet } from "react-native";
|
|
|
3
3
|
import { Canvas } from "@shopify/react-native-skia";
|
|
4
4
|
import { memo } from "@impulse-ui-native/core";
|
|
5
5
|
import { useTheme } from "@impulse-ui-native/theme";
|
|
6
|
-
import { useChartCanvas } from "
|
|
6
|
+
import { useChartCanvas } from "../../hooks";
|
|
7
7
|
import { LineChartBody } from "./line-chart-body";
|
|
8
8
|
const LineChart = memo(function LineChart2(props) {
|
|
9
9
|
const theme = useTheme();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/line-chart/line-chart.tsx"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport { Canvas } from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\nimport { useTheme } from \"@impulse-ui-native/theme\";\n\nimport { useChartCanvas } from \"../../hooks\";\nimport { ChartXValue, LineChartProps } from \"../../types\";\nimport { LineChartBody } from \"./line-chart-body\";\n\nexport const LineChart = memo(function LineChart<\n X extends ChartXValue = number,\n>(props: LineChartProps<X>) {\n const theme = useTheme();\n\n const { ref, size } = useChartCanvas();\n\n return (\n <Canvas ref={ref} style={styles.container}>\n <LineChartBody {...props} size={size} theme={theme} />\n </Canvas>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"],"mappings":"AAmBM;AAnBN,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEvB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB;AAE/B,SAAS,qBAAqB;AAEvB,MAAM,YAAY,KAAK,SAASA,WAErC,OAA0B;AAC1B,QAAM,QAAQ,SAAS;AAEvB,QAAM,EAAE,KAAK,KAAK,IAAI,eAAe;AAErC,SACE,oBAAC,UAAO,KAAU,OAAO,OAAO,WAC9B,8BAAC,iBAAe,GAAG,OAAO,MAAY,OAAc,GACtD;AAEJ,CAAC;AAED,MAAM,SAAS,WAAW,OAAO;AAAA,EAC/B,WAAW;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":["LineChart"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { MultiBarChart } from './multi-bar-chart.mjs';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import '../../line-chart.types-yxru5uWc.mjs';
|
|
4
|
+
import '@shopify/react-native-skia';
|
|
5
|
+
import '../../types/common.types.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
import '@impulse-ui-native/theme';
|
|
8
|
+
import '../../types/multi-bar-chart.types.mjs';
|
|
9
|
+
import '../../types/bar-chart.types.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/multi-bar-chart/index.ts"],"sourcesContent":["export { MultiBarChart } from \"./multi-bar-chart\";\n"],"mappings":"AAAA,SAAS,qBAAqB;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { AppTheme } from '@impulse-ui-native/theme';
|
|
3
|
+
import { ChartSize } from '../../types/common.types.mjs';
|
|
4
|
+
import { b as ChartXValue } from '../../line-chart.types-yxru5uWc.mjs';
|
|
5
|
+
import { MultiBarChartProps } from '../../types/multi-bar-chart.types.mjs';
|
|
6
|
+
import '../../types/style.types.mjs';
|
|
7
|
+
import '@shopify/react-native-skia';
|
|
8
|
+
import '../../types/bar-chart.types.mjs';
|
|
9
|
+
|
|
10
|
+
interface MultiBarChartBodyProps<X extends ChartXValue> extends MultiBarChartProps<X> {
|
|
11
|
+
size: ChartSize;
|
|
12
|
+
theme: AppTheme;
|
|
13
|
+
}
|
|
14
|
+
declare const MultiBarChartBody: <X extends ChartXValue = string>(props: MultiBarChartBodyProps<X>) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { MultiBarChartBody };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { Group } from "@shopify/react-native-skia";
|
|
4
|
+
import { memo } from "@impulse-ui-native/core";
|
|
5
|
+
import { useChartLayout, useMultiBarChart } from "../../hooks";
|
|
6
|
+
import { createDrawableMultiBarChartSeries } from "../../utils";
|
|
7
|
+
import { ChartAxes } from "../chart-axes";
|
|
8
|
+
import { Bar } from "../primitives";
|
|
9
|
+
const MultiBarChartBody = memo(function MultiBarChartBodyComponent(props) {
|
|
10
|
+
const {
|
|
11
|
+
categoryPadding,
|
|
12
|
+
fontManager,
|
|
13
|
+
grid,
|
|
14
|
+
insets,
|
|
15
|
+
series,
|
|
16
|
+
seriesPadding,
|
|
17
|
+
size,
|
|
18
|
+
theme,
|
|
19
|
+
xAxis,
|
|
20
|
+
yAxis
|
|
21
|
+
} = props;
|
|
22
|
+
const layout = useChartLayout(size, insets);
|
|
23
|
+
const {
|
|
24
|
+
series: seriesModels,
|
|
25
|
+
xScale,
|
|
26
|
+
xTicks,
|
|
27
|
+
yScale,
|
|
28
|
+
yTicks
|
|
29
|
+
} = useMultiBarChart({
|
|
30
|
+
categoryPadding,
|
|
31
|
+
plot: layout.plot,
|
|
32
|
+
series,
|
|
33
|
+
seriesPadding,
|
|
34
|
+
xAxis,
|
|
35
|
+
yAxis
|
|
36
|
+
});
|
|
37
|
+
const drawableSeries = useMemo(
|
|
38
|
+
() => seriesModels.map(
|
|
39
|
+
(currentSeries, index) => createDrawableMultiBarChartSeries(currentSeries, index)
|
|
40
|
+
),
|
|
41
|
+
[seriesModels]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
ChartAxes,
|
|
46
|
+
{
|
|
47
|
+
fontManager,
|
|
48
|
+
grid,
|
|
49
|
+
layout,
|
|
50
|
+
theme,
|
|
51
|
+
xAxis,
|
|
52
|
+
xScale,
|
|
53
|
+
xTicks,
|
|
54
|
+
yAxis,
|
|
55
|
+
yScale,
|
|
56
|
+
yTicks
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx(Group, { clip: layout.plot, children: drawableSeries.map((currentSeries) => /* @__PURE__ */ jsx(
|
|
60
|
+
Bar,
|
|
61
|
+
{
|
|
62
|
+
coordinates: currentSeries.coordinates,
|
|
63
|
+
...currentSeries.bar
|
|
64
|
+
},
|
|
65
|
+
currentSeries.id
|
|
66
|
+
)) })
|
|
67
|
+
] });
|
|
68
|
+
});
|
|
69
|
+
export {
|
|
70
|
+
MultiBarChartBody
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=multi-bar-chart-body.js.map
|