@impulse-ui-native/charts 2.1.0 → 2.1.1
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/dist/components/index.d.mts +17 -0
- package/dist/components/index.js +8 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/line-chart-body.d.mts +14 -0
- package/dist/components/line-chart-body.js +90 -0
- package/dist/components/line-chart-body.js.map +1 -0
- package/dist/components/line-chart.d.mts +10 -0
- package/dist/components/line-chart.js +21 -0
- package/dist/components/line-chart.js.map +1 -0
- package/dist/components/multi-line-chart-body.d.mts +11 -0
- package/dist/components/multi-line-chart-body.js +98 -0
- package/dist/components/multi-line-chart-body.js.map +1 -0
- package/dist/components/multi-line-chart.d.mts +11 -0
- package/dist/components/multi-line-chart.js +21 -0
- package/dist/components/multi-line-chart.js.map +1 -0
- package/dist/components/primitives/grid.d.mts +10 -0
- package/dist/components/primitives/grid.js +65 -0
- package/dist/components/primitives/grid.js.map +1 -0
- package/dist/components/primitives/index.d.mts +14 -0
- package/dist/components/primitives/index.js +13 -0
- package/dist/components/primitives/index.js.map +1 -0
- package/dist/components/primitives/label.d.mts +10 -0
- package/dist/components/primitives/label.js +94 -0
- package/dist/components/primitives/label.js.map +1 -0
- package/dist/components/primitives/line.d.mts +11 -0
- package/dist/components/primitives/line.js +50 -0
- package/dist/components/primitives/line.js.map +1 -0
- package/dist/components/primitives/x-axis.d.mts +11 -0
- package/dist/components/primitives/x-axis.js +93 -0
- package/dist/components/primitives/x-axis.js.map +1 -0
- package/dist/components/primitives/y-axis.d.mts +11 -0
- package/dist/components/primitives/y-axis.js +95 -0
- package/dist/components/primitives/y-axis.js.map +1 -0
- package/dist/constants/axis.constants.d.mts +6 -0
- package/dist/constants/axis.constants.js +11 -0
- package/dist/constants/axis.constants.js.map +1 -0
- package/dist/constants/grid.constants.d.mts +6 -0
- package/dist/constants/grid.constants.js +11 -0
- package/dist/constants/grid.constants.js.map +1 -0
- package/dist/constants/index.d.mts +11 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/label.constants.d.mts +11 -0
- package/dist/constants/label.constants.js +12 -0
- package/dist/constants/label.constants.js.map +1 -0
- package/dist/constants/line-chart.constants.d.mts +8 -0
- package/dist/constants/line-chart.constants.js +7 -0
- package/dist/constants/line-chart.constants.js.map +1 -0
- package/dist/constants/line.constants.d.mts +15 -0
- package/dist/constants/line.constants.js +18 -0
- package/dist/constants/line.constants.js.map +1 -0
- package/dist/contexts/index.d.mts +2 -0
- package/dist/contexts/index.js +1 -0
- package/dist/contexts/index.js.map +1 -0
- package/dist/hooks/index.d.mts +12 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-chart-canvas.hook.d.mts +9 -0
- package/dist/hooks/use-chart-canvas.hook.js +10 -0
- package/dist/hooks/use-chart-canvas.hook.js.map +1 -0
- package/dist/hooks/use-line-chart.hook.d.mts +10 -0
- package/dist/hooks/use-line-chart.hook.js +13 -0
- package/dist/hooks/use-line-chart.hook.js.map +1 -0
- package/dist/hooks/use-multi-line-chart.hook.d.mts +12 -0
- package/dist/hooks/use-multi-line-chart.hook.js +44 -0
- package/dist/hooks/use-multi-line-chart.hook.js.map +1 -0
- package/dist/index.d.mts +36 -321
- package/dist/index.js +6 -1083
- package/dist/index.js.map +1 -1
- package/dist/line-chart.types-yxru5uWc.d.mts +62 -0
- package/dist/types/axis.types.d.mts +49 -0
- package/dist/types/axis.types.js +1 -0
- package/dist/types/axis.types.js.map +1 -0
- package/dist/types/common.types.d.mts +57 -0
- package/dist/types/common.types.js +1 -0
- package/dist/types/common.types.js.map +1 -0
- package/dist/types/grid.types.d.mts +5 -0
- package/dist/types/grid.types.js +1 -0
- package/dist/types/grid.types.js.map +1 -0
- package/dist/types/index.d.mts +11 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/label.types.d.mts +24 -0
- package/dist/types/label.types.js +1 -0
- package/dist/types/label.types.js.map +1 -0
- package/dist/types/line-chart.types.d.mts +5 -0
- package/dist/types/line-chart.types.js +1 -0
- package/dist/types/line-chart.types.js.map +1 -0
- package/dist/types/line.types.d.mts +11 -0
- package/dist/types/line.types.js +1 -0
- package/dist/types/line.types.js.map +1 -0
- package/dist/types/multi-line-chart.types.d.mts +23 -0
- package/dist/types/multi-line-chart.types.js +1 -0
- package/dist/types/multi-line-chart.types.js.map +1 -0
- package/dist/types/style.types.d.mts +19 -0
- package/dist/types/style.types.js +1 -0
- package/dist/types/style.types.js.map +1 -0
- package/dist/types/use-line-chart.types.d.mts +29 -0
- package/dist/types/use-line-chart.types.js +1 -0
- package/dist/types/use-line-chart.types.js.map +1 -0
- package/dist/types/use-multi-line-chart.types.d.mts +16 -0
- package/dist/types/use-multi-line-chart.types.js +1 -0
- package/dist/types/use-multi-line-chart.types.js.map +1 -0
- package/dist/utils/axis.util.d.mts +15 -0
- package/dist/utils/axis.util.js +82 -0
- package/dist/utils/axis.util.js.map +1 -0
- package/dist/utils/chart-layout.util.d.mts +8 -0
- package/dist/utils/chart-layout.util.js +55 -0
- package/dist/utils/chart-layout.util.js.map +1 -0
- package/dist/utils/grid.util.d.mts +11 -0
- package/dist/utils/grid.util.js +56 -0
- package/dist/utils/grid.util.js.map +1 -0
- package/dist/utils/index.d.mts +17 -0
- package/dist/utils/index.js +44 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/label.util.d.mts +10 -0
- package/dist/utils/label.util.js +24 -0
- package/dist/utils/label.util.js.map +1 -0
- package/dist/utils/line-chart.util.d.mts +11 -0
- package/dist/utils/line-chart.util.js +133 -0
- package/dist/utils/line-chart.util.js.map +1 -0
- package/dist/utils/line.util.d.mts +10 -0
- package/dist/utils/line.util.js +36 -0
- package/dist/utils/line.util.js.map +1 -0
- package/dist/utils/multi-line-chart.util.d.mts +10 -0
- package/dist/utils/multi-line-chart.util.js +23 -0
- package/dist/utils/multi-line-chart.util.js.map +1 -0
- package/dist/utils/paragraph-builder.util.d.mts +10 -0
- package/dist/utils/paragraph-builder.util.js +16 -0
- package/dist/utils/paragraph-builder.util.js.map +1 -0
- package/package.json +7 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { Grid } from './primitives/grid.mjs';
|
|
2
|
+
export { Label } from './primitives/label.mjs';
|
|
3
|
+
export { Line } from './primitives/line.mjs';
|
|
4
|
+
export { XAxis } from './primitives/x-axis.mjs';
|
|
5
|
+
export { YAxis } from './primitives/y-axis.mjs';
|
|
6
|
+
export { LineChart } from './line-chart.mjs';
|
|
7
|
+
export { MultiLineChart } from './multi-line-chart.mjs';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '../line-chart.types-yxru5uWc.mjs';
|
|
10
|
+
import '@shopify/react-native-skia';
|
|
11
|
+
import '../types/common.types.mjs';
|
|
12
|
+
import '../types/style.types.mjs';
|
|
13
|
+
import '@impulse-ui-native/theme';
|
|
14
|
+
import '../types/label.types.mjs';
|
|
15
|
+
import '../types/line.types.mjs';
|
|
16
|
+
import '../types/axis.types.mjs';
|
|
17
|
+
import '../types/multi-line-chart.types.mjs';
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
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, g as LineChartProps } from '../line-chart.types-yxru5uWc.mjs';
|
|
5
|
+
import '../types/style.types.mjs';
|
|
6
|
+
import '@shopify/react-native-skia';
|
|
7
|
+
|
|
8
|
+
interface LineChartBodyProps<X extends ChartXValue> extends LineChartProps<X> {
|
|
9
|
+
size: ChartSize;
|
|
10
|
+
theme: AppTheme;
|
|
11
|
+
}
|
|
12
|
+
declare const LineChartBody: <X extends ChartXValue = number>(props: LineChartBodyProps<X>) => react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
export { LineChartBody };
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { LineDefaultWidth } from "../constants";
|
|
6
|
+
import { useLineChart } from "../hooks";
|
|
7
|
+
import {
|
|
8
|
+
createChartLayout,
|
|
9
|
+
createInsetRect,
|
|
10
|
+
fitLineCoordinatesToRect
|
|
11
|
+
} from "../utils";
|
|
12
|
+
import { Grid, Line, XAxis, YAxis } from "./primitives";
|
|
13
|
+
const LineChartBody = memo(function LineChartBodyComponent(props) {
|
|
14
|
+
const {
|
|
15
|
+
data,
|
|
16
|
+
fontManager,
|
|
17
|
+
grid,
|
|
18
|
+
insets,
|
|
19
|
+
line,
|
|
20
|
+
size,
|
|
21
|
+
theme,
|
|
22
|
+
xAxis,
|
|
23
|
+
xScaleType,
|
|
24
|
+
yAxis
|
|
25
|
+
} = props;
|
|
26
|
+
const layout = useMemo(() => createChartLayout(size, insets), [insets, size]);
|
|
27
|
+
const { coordinates, xScale, xTicks, yScale, yTicks } = useLineChart({
|
|
28
|
+
data,
|
|
29
|
+
plot: layout.plot,
|
|
30
|
+
xAxis,
|
|
31
|
+
xScaleType,
|
|
32
|
+
yAxis
|
|
33
|
+
});
|
|
34
|
+
const linePlot = useMemo(
|
|
35
|
+
() => createInsetRect(layout.plot, (line?.width ?? LineDefaultWidth) / 2),
|
|
36
|
+
[layout.plot, line?.width]
|
|
37
|
+
);
|
|
38
|
+
const lineCoordinates = useMemo(
|
|
39
|
+
() => fitLineCoordinatesToRect(coordinates, layout.plot, linePlot),
|
|
40
|
+
[coordinates, layout.plot, linePlot]
|
|
41
|
+
);
|
|
42
|
+
const isGridStyle = grid !== void 0;
|
|
43
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
isGridStyle ? /* @__PURE__ */ jsx(
|
|
45
|
+
Grid,
|
|
46
|
+
{
|
|
47
|
+
options: grid,
|
|
48
|
+
plot: layout.plot,
|
|
49
|
+
theme,
|
|
50
|
+
xTicks,
|
|
51
|
+
xScale,
|
|
52
|
+
yTicks,
|
|
53
|
+
yScale
|
|
54
|
+
}
|
|
55
|
+
) : null,
|
|
56
|
+
xAxis?.visible !== false ? /* @__PURE__ */ jsx(
|
|
57
|
+
XAxis,
|
|
58
|
+
{
|
|
59
|
+
ticks: xTicks,
|
|
60
|
+
scale: xScale,
|
|
61
|
+
plot: layout.plot,
|
|
62
|
+
region: layout.xAxis,
|
|
63
|
+
theme,
|
|
64
|
+
options: xAxis,
|
|
65
|
+
fontManager,
|
|
66
|
+
lineVisible: !isGridStyle,
|
|
67
|
+
tickVisible: !isGridStyle
|
|
68
|
+
}
|
|
69
|
+
) : null,
|
|
70
|
+
yAxis?.visible !== false ? /* @__PURE__ */ jsx(
|
|
71
|
+
YAxis,
|
|
72
|
+
{
|
|
73
|
+
ticks: yTicks,
|
|
74
|
+
scale: yScale,
|
|
75
|
+
plot: layout.plot,
|
|
76
|
+
region: layout.yAxis,
|
|
77
|
+
theme,
|
|
78
|
+
options: yAxis,
|
|
79
|
+
fontManager,
|
|
80
|
+
lineVisible: !isGridStyle,
|
|
81
|
+
tickVisible: !isGridStyle
|
|
82
|
+
}
|
|
83
|
+
) : null,
|
|
84
|
+
/* @__PURE__ */ jsx(Group, { clip: layout.plot, children: /* @__PURE__ */ jsx(Line, { coordinates: lineCoordinates, ...line }) })
|
|
85
|
+
] });
|
|
86
|
+
});
|
|
87
|
+
export {
|
|
88
|
+
LineChartBody
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=line-chart-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/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 { useLineChart } from \"../hooks\";\nimport { ChartSize, ChartXValue, LineChartProps } from \"../types\";\nimport {\n createChartLayout,\n createInsetRect,\n fitLineCoordinatesToRect,\n} 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 = useMemo(() => createChartLayout(size, insets), [insets, size]);\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":"AA4DI,mBAEI,KAFJ;AA5DJ,SAAS,eAAe;AACxB,SAAS,aAAa;AAEtB,SAAS,YAAY;AAGrB,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,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,QAAQ,MAAM,kBAAkB,MAAM,MAAM,GAAG,CAAC,QAAQ,IAAI,CAAC;AAE5E,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":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { b as ChartXValue, g as LineChartProps } from '../line-chart.types-yxru5uWc.mjs';
|
|
3
|
+
import '@shopify/react-native-skia';
|
|
4
|
+
import '../types/common.types.mjs';
|
|
5
|
+
import '../types/style.types.mjs';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const LineChart: <X extends ChartXValue = number>(props: LineChartProps<X>) => react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { LineChart };
|
|
@@ -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 { LineChartBody } from "./line-chart-body";
|
|
8
|
+
const LineChart = memo(function LineChart2(props) {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const { ref, size } = useChartCanvas();
|
|
11
|
+
return /* @__PURE__ */ jsx(Canvas, { ref, style: styles.container, children: /* @__PURE__ */ jsx(LineChartBody, { ...props, size, theme }) });
|
|
12
|
+
});
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
container: {
|
|
15
|
+
flex: 1
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
LineChart
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=line-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/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,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { b as ChartXValue } from '../line-chart.types-yxru5uWc.mjs';
|
|
3
|
+
import { MultiLineChartBodyProps } from '../types/multi-line-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 MultiLineChartBody: <X extends ChartXValue = number>(props: MultiLineChartBodyProps<X>) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { MultiLineChartBody };
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { useMultiLineChart } from "../hooks";
|
|
6
|
+
import {
|
|
7
|
+
createChartLayout,
|
|
8
|
+
createDrawableMultiLineChartSeries
|
|
9
|
+
} from "../utils";
|
|
10
|
+
import { Grid, Line, XAxis, YAxis } from "./primitives";
|
|
11
|
+
const MultiLineChartBody = memo(function MultiLineChartBodyComponent(props) {
|
|
12
|
+
const {
|
|
13
|
+
fontManager,
|
|
14
|
+
grid,
|
|
15
|
+
insets,
|
|
16
|
+
series,
|
|
17
|
+
size,
|
|
18
|
+
theme,
|
|
19
|
+
xAxis,
|
|
20
|
+
xScaleType,
|
|
21
|
+
yAxis
|
|
22
|
+
} = props;
|
|
23
|
+
const layout = useMemo(() => createChartLayout(size, insets), [insets, size]);
|
|
24
|
+
const {
|
|
25
|
+
series: seriesModels,
|
|
26
|
+
xScale,
|
|
27
|
+
xTicks,
|
|
28
|
+
yScale,
|
|
29
|
+
yTicks
|
|
30
|
+
} = useMultiLineChart({
|
|
31
|
+
plot: layout.plot,
|
|
32
|
+
series,
|
|
33
|
+
xAxis,
|
|
34
|
+
xScaleType,
|
|
35
|
+
yAxis
|
|
36
|
+
});
|
|
37
|
+
const drawableSeries = useMemo(
|
|
38
|
+
() => seriesModels.map(
|
|
39
|
+
(currentSeries, index) => createDrawableMultiLineChartSeries(currentSeries, index, layout.plot)
|
|
40
|
+
),
|
|
41
|
+
[layout.plot, seriesModels]
|
|
42
|
+
);
|
|
43
|
+
const isGridStyle = grid !== void 0;
|
|
44
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
+
isGridStyle ? /* @__PURE__ */ jsx(
|
|
46
|
+
Grid,
|
|
47
|
+
{
|
|
48
|
+
options: grid,
|
|
49
|
+
plot: layout.plot,
|
|
50
|
+
theme,
|
|
51
|
+
xTicks,
|
|
52
|
+
xScale,
|
|
53
|
+
yTicks,
|
|
54
|
+
yScale
|
|
55
|
+
}
|
|
56
|
+
) : null,
|
|
57
|
+
xAxis?.visible !== false ? /* @__PURE__ */ jsx(
|
|
58
|
+
XAxis,
|
|
59
|
+
{
|
|
60
|
+
ticks: xTicks,
|
|
61
|
+
scale: xScale,
|
|
62
|
+
plot: layout.plot,
|
|
63
|
+
region: layout.xAxis,
|
|
64
|
+
theme,
|
|
65
|
+
options: xAxis,
|
|
66
|
+
fontManager,
|
|
67
|
+
lineVisible: !isGridStyle,
|
|
68
|
+
tickVisible: !isGridStyle
|
|
69
|
+
}
|
|
70
|
+
) : null,
|
|
71
|
+
yAxis?.visible !== false ? /* @__PURE__ */ jsx(
|
|
72
|
+
YAxis,
|
|
73
|
+
{
|
|
74
|
+
ticks: yTicks,
|
|
75
|
+
scale: yScale,
|
|
76
|
+
plot: layout.plot,
|
|
77
|
+
region: layout.yAxis,
|
|
78
|
+
theme,
|
|
79
|
+
options: yAxis,
|
|
80
|
+
fontManager,
|
|
81
|
+
lineVisible: !isGridStyle,
|
|
82
|
+
tickVisible: !isGridStyle
|
|
83
|
+
}
|
|
84
|
+
) : null,
|
|
85
|
+
/* @__PURE__ */ jsx(Group, { clip: layout.plot, children: drawableSeries.map((currentSeries) => /* @__PURE__ */ jsx(
|
|
86
|
+
Line,
|
|
87
|
+
{
|
|
88
|
+
coordinates: currentSeries.coordinates,
|
|
89
|
+
...currentSeries.line
|
|
90
|
+
},
|
|
91
|
+
currentSeries.id
|
|
92
|
+
)) })
|
|
93
|
+
] });
|
|
94
|
+
});
|
|
95
|
+
export {
|
|
96
|
+
MultiLineChartBody
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=multi-line-chart-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/multi-line-chart-body.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Group } from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\n\nimport { useMultiLineChart } from \"../hooks\";\nimport { ChartXValue, MultiLineChartBodyProps } from \"../types\";\nimport {\n createChartLayout,\n createDrawableMultiLineChartSeries,\n} from \"../utils\";\nimport { Grid, Line, XAxis, YAxis } from \"./primitives\";\n\nexport const MultiLineChartBody = memo(function MultiLineChartBodyComponent<\n X extends ChartXValue = number,\n>(props: MultiLineChartBodyProps<X>) {\n const {\n fontManager,\n grid,\n insets,\n series,\n size,\n theme,\n xAxis,\n xScaleType,\n yAxis,\n } = props;\n\n const layout = useMemo(() => createChartLayout(size, insets), [insets, size]);\n\n const {\n series: seriesModels,\n xScale,\n xTicks,\n yScale,\n yTicks,\n } = useMultiLineChart({\n plot: layout.plot,\n series,\n xAxis,\n xScaleType,\n yAxis,\n });\n\n const drawableSeries = useMemo(\n () =>\n seriesModels.map((currentSeries, index) =>\n createDrawableMultiLineChartSeries(currentSeries, index, layout.plot),\n ),\n [layout.plot, seriesModels],\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 {drawableSeries.map((currentSeries) => (\n <Line\n key={currentSeries.id}\n coordinates={currentSeries.coordinates}\n {...currentSeries.line}\n />\n ))}\n </Group>\n </>\n );\n});\n"],"mappings":"AAuDI,mBAEI,KAFJ;AAvDJ,SAAS,eAAe;AACxB,SAAS,aAAa;AAEtB,SAAS,YAAY;AAErB,SAAS,yBAAyB;AAElC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,MAAM,OAAO,aAAa;AAElC,MAAM,qBAAqB,KAAK,SAAS,4BAE9C,OAAmC;AACnC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,SAAS,QAAQ,MAAM,kBAAkB,MAAM,MAAM,GAAG,CAAC,QAAQ,IAAI,CAAC;AAE5E,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,kBAAkB;AAAA,IACpB,MAAM,OAAO;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,iBAAiB;AAAA,IACrB,MACE,aAAa;AAAA,MAAI,CAAC,eAAe,UAC/B,mCAAmC,eAAe,OAAO,OAAO,IAAI;AAAA,IACtE;AAAA,IACF,CAAC,OAAO,MAAM,YAAY;AAAA,EAC5B;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,MACjB,yBAAe,IAAI,CAAC,kBACnB;AAAA,MAAC;AAAA;AAAA,QAEC,aAAa,cAAc;AAAA,QAC1B,GAAG,cAAc;AAAA;AAAA,MAFb,cAAc;AAAA,IAGrB,CACD,GACH;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 { MultiLineChartProps } from '../types/multi-line-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 MultiLineChart: <X extends ChartXValue = number>(props: MultiLineChartProps<X>) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { MultiLineChart };
|
|
@@ -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 { MultiLineChartBody } from "./multi-line-chart-body";
|
|
8
|
+
const MultiLineChart = memo(function MultiLineChart2(props) {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const { ref, size } = useChartCanvas();
|
|
11
|
+
return /* @__PURE__ */ jsx(Canvas, { ref, style: styles.container, children: /* @__PURE__ */ jsx(MultiLineChartBody, { ...props, size, theme }) });
|
|
12
|
+
});
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
container: {
|
|
15
|
+
flex: 1
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
MultiLineChart
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=multi-line-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/multi-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, MultiLineChartProps } from \"../types\";\nimport { MultiLineChartBody } from \"./multi-line-chart-body\";\n\nexport const MultiLineChart = memo(function MultiLineChart<\n X extends ChartXValue = number,\n>(props: MultiLineChartProps<X>) {\n const theme = useTheme();\n\n const { ref, size } = useChartCanvas();\n\n return (\n <Canvas ref={ref} style={styles.container}>\n <MultiLineChartBody {...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,0BAA0B;AAE5B,MAAM,iBAAiB,KAAK,SAASA,gBAE1C,OAA+B;AAC/B,QAAM,QAAQ,SAAS;AAEvB,QAAM,EAAE,KAAK,KAAK,IAAI,eAAe;AAErC,SACE,oBAAC,UAAO,KAAU,OAAO,OAAO,WAC9B,8BAAC,sBAAoB,GAAG,OAAO,MAAY,OAAc,GAC3D;AAEJ,CAAC;AAED,MAAM,SAAS,WAAW,OAAO;AAAA,EAC/B,WAAW;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":["MultiLineChart"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { b as ChartXValue, G as GridProps } from '../../line-chart.types-yxru5uWc.mjs';
|
|
3
|
+
import '@shopify/react-native-skia';
|
|
4
|
+
import '../../types/common.types.mjs';
|
|
5
|
+
import '../../types/style.types.mjs';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const Grid: <X extends ChartXValue = number>(props: GridProps<X>) => react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { Grid };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { DashPathEffect, Group, Path } from "@shopify/react-native-skia";
|
|
4
|
+
import { memo } from "@impulse-ui-native/core";
|
|
5
|
+
import { GridDefaultXVisible, GridDefaultYVisible } from "../../constants";
|
|
6
|
+
import {
|
|
7
|
+
createHorizontalGridPath,
|
|
8
|
+
createVerticalGridPath,
|
|
9
|
+
resolveGridLineOptions
|
|
10
|
+
} from "../../utils";
|
|
11
|
+
const Grid = memo(function Grid2(props) {
|
|
12
|
+
const { options, plot, theme, xScale, xTicks, yScale, yTicks } = props;
|
|
13
|
+
const xStyle = useMemo(
|
|
14
|
+
() => resolveGridLineOptions(
|
|
15
|
+
options?.x,
|
|
16
|
+
GridDefaultXVisible,
|
|
17
|
+
theme.colors.border.subtle.value
|
|
18
|
+
),
|
|
19
|
+
[options?.x, theme.colors.border.subtle.value]
|
|
20
|
+
);
|
|
21
|
+
const yStyle = useMemo(
|
|
22
|
+
() => resolveGridLineOptions(
|
|
23
|
+
options?.y,
|
|
24
|
+
GridDefaultYVisible,
|
|
25
|
+
theme.colors.border.subtle.value
|
|
26
|
+
),
|
|
27
|
+
[options?.y, theme.colors.border.subtle.value]
|
|
28
|
+
);
|
|
29
|
+
const xPath = useMemo(
|
|
30
|
+
() => createVerticalGridPath(xTicks, xScale, plot),
|
|
31
|
+
[plot, xScale, xTicks]
|
|
32
|
+
);
|
|
33
|
+
const yPath = useMemo(
|
|
34
|
+
() => createHorizontalGridPath(yTicks, yScale, plot),
|
|
35
|
+
[plot, yScale, yTicks]
|
|
36
|
+
);
|
|
37
|
+
return /* @__PURE__ */ jsxs(Group, { children: [
|
|
38
|
+
xStyle.visible && xPath ? /* @__PURE__ */ jsx(
|
|
39
|
+
Path,
|
|
40
|
+
{
|
|
41
|
+
path: xPath,
|
|
42
|
+
color: xStyle.color,
|
|
43
|
+
opacity: xStyle.opacity,
|
|
44
|
+
strokeWidth: xStyle.width,
|
|
45
|
+
style: "stroke",
|
|
46
|
+
children: xStyle.dash?.length ? /* @__PURE__ */ jsx(DashPathEffect, { intervals: [...xStyle.dash] }) : null
|
|
47
|
+
}
|
|
48
|
+
) : null,
|
|
49
|
+
yStyle.visible && yPath ? /* @__PURE__ */ jsx(
|
|
50
|
+
Path,
|
|
51
|
+
{
|
|
52
|
+
path: yPath,
|
|
53
|
+
color: yStyle.color,
|
|
54
|
+
opacity: yStyle.opacity,
|
|
55
|
+
strokeWidth: yStyle.width,
|
|
56
|
+
style: "stroke",
|
|
57
|
+
children: yStyle.dash?.length ? /* @__PURE__ */ jsx(DashPathEffect, { intervals: [...yStyle.dash] }) : null
|
|
58
|
+
}
|
|
59
|
+
) : null
|
|
60
|
+
] });
|
|
61
|
+
});
|
|
62
|
+
export {
|
|
63
|
+
Grid
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/primitives/grid.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { DashPathEffect, Group, Path } from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\n\nimport { GridDefaultXVisible, GridDefaultYVisible } from \"../../constants\";\nimport { ChartXValue, GridProps } from \"../../types\";\nimport {\n createHorizontalGridPath,\n createVerticalGridPath,\n resolveGridLineOptions,\n} from \"../../utils\";\n\nexport const Grid = memo(function Grid<X extends ChartXValue = number>(\n props: GridProps<X>,\n) {\n const { options, plot, theme, xScale, xTicks, yScale, yTicks } = props;\n\n const xStyle = useMemo(\n () =>\n resolveGridLineOptions(\n options?.x,\n GridDefaultXVisible,\n theme.colors.border.subtle.value,\n ),\n [options?.x, theme.colors.border.subtle.value],\n );\n\n const yStyle = useMemo(\n () =>\n resolveGridLineOptions(\n options?.y,\n GridDefaultYVisible,\n theme.colors.border.subtle.value,\n ),\n [options?.y, theme.colors.border.subtle.value],\n );\n\n const xPath = useMemo(\n () => createVerticalGridPath(xTicks, xScale, plot),\n [plot, xScale, xTicks],\n );\n\n const yPath = useMemo(\n () => createHorizontalGridPath(yTicks, yScale, plot),\n [plot, yScale, yTicks],\n );\n\n return (\n <Group>\n {xStyle.visible && xPath ? (\n <Path\n path={xPath}\n color={xStyle.color}\n opacity={xStyle.opacity}\n strokeWidth={xStyle.width}\n style=\"stroke\"\n >\n {xStyle.dash?.length ? (\n <DashPathEffect intervals={[...xStyle.dash]} />\n ) : null}\n </Path>\n ) : null}\n\n {yStyle.visible && yPath ? (\n <Path\n path={yPath}\n color={yStyle.color}\n opacity={yStyle.opacity}\n strokeWidth={yStyle.width}\n style=\"stroke\"\n >\n {yStyle.dash?.length ? (\n <DashPathEffect intervals={[...yStyle.dash]} />\n ) : null}\n </Path>\n ) : null}\n </Group>\n );\n});\n"],"mappings":"AAiDI,SAUQ,KAVR;AAjDJ,SAAS,eAAe;AACxB,SAAS,gBAAgB,OAAO,YAAY;AAE5C,SAAS,YAAY;AAErB,SAAS,qBAAqB,2BAA2B;AAEzD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,OAAO,KAAK,SAASA,MAChC,OACA;AACA,QAAM,EAAE,SAAS,MAAM,OAAO,QAAQ,QAAQ,QAAQ,OAAO,IAAI;AAEjE,QAAM,SAAS;AAAA,IACb,MACE;AAAA,MACE,SAAS;AAAA,MACT;AAAA,MACA,MAAM,OAAO,OAAO,OAAO;AAAA,IAC7B;AAAA,IACF,CAAC,SAAS,GAAG,MAAM,OAAO,OAAO,OAAO,KAAK;AAAA,EAC/C;AAEA,QAAM,SAAS;AAAA,IACb,MACE;AAAA,MACE,SAAS;AAAA,MACT;AAAA,MACA,MAAM,OAAO,OAAO,OAAO;AAAA,IAC7B;AAAA,IACF,CAAC,SAAS,GAAG,MAAM,OAAO,OAAO,OAAO,KAAK;AAAA,EAC/C;AAEA,QAAM,QAAQ;AAAA,IACZ,MAAM,uBAAuB,QAAQ,QAAQ,IAAI;AAAA,IACjD,CAAC,MAAM,QAAQ,MAAM;AAAA,EACvB;AAEA,QAAM,QAAQ;AAAA,IACZ,MAAM,yBAAyB,QAAQ,QAAQ,IAAI;AAAA,IACnD,CAAC,MAAM,QAAQ,MAAM;AAAA,EACvB;AAEA,SACE,qBAAC,SACE;AAAA,WAAO,WAAW,QACjB;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,QACpB,OAAM;AAAA,QAEL,iBAAO,MAAM,SACZ,oBAAC,kBAAe,WAAW,CAAC,GAAG,OAAO,IAAI,GAAG,IAC3C;AAAA;AAAA,IACN,IACE;AAAA,IAEH,OAAO,WAAW,QACjB;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,QACpB,OAAM;AAAA,QAEL,iBAAO,MAAM,SACZ,oBAAC,kBAAe,WAAW,CAAC,GAAG,OAAO,IAAI,GAAG,IAC3C;AAAA;AAAA,IACN,IACE;AAAA,KACN;AAEJ,CAAC;","names":["Grid"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Grid } from './grid.mjs';
|
|
2
|
+
export { Label } from './label.mjs';
|
|
3
|
+
export { Line } from './line.mjs';
|
|
4
|
+
export { XAxis } from './x-axis.mjs';
|
|
5
|
+
export { YAxis } from './y-axis.mjs';
|
|
6
|
+
import 'react/jsx-runtime';
|
|
7
|
+
import '../../line-chart.types-yxru5uWc.mjs';
|
|
8
|
+
import '@shopify/react-native-skia';
|
|
9
|
+
import '../../types/common.types.mjs';
|
|
10
|
+
import '../../types/style.types.mjs';
|
|
11
|
+
import '@impulse-ui-native/theme';
|
|
12
|
+
import '../../types/label.types.mjs';
|
|
13
|
+
import '../../types/line.types.mjs';
|
|
14
|
+
import '../../types/axis.types.mjs';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Grid } from "./grid";
|
|
2
|
+
import { Label } from "./label";
|
|
3
|
+
import { Line } from "./line";
|
|
4
|
+
import { XAxis } from "./x-axis";
|
|
5
|
+
import { YAxis } from "./y-axis";
|
|
6
|
+
export {
|
|
7
|
+
Grid,
|
|
8
|
+
Label,
|
|
9
|
+
Line,
|
|
10
|
+
XAxis,
|
|
11
|
+
YAxis
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/primitives/index.ts"],"sourcesContent":["export { Grid } from \"./grid\";\nexport { Label } from \"./label\";\nexport { Line } from \"./line\";\nexport { XAxis } from \"./x-axis\";\nexport { YAxis } from \"./y-axis\";\n"],"mappings":"AAAA,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,aAAa;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { LabelProps } from '../../types/label.types.mjs';
|
|
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
|
+
|
|
8
|
+
declare const Label: (props: LabelProps) => react_jsx_runtime.JSX.Element | null;
|
|
9
|
+
|
|
10
|
+
export { Label };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import {
|
|
4
|
+
Group,
|
|
5
|
+
Paragraph,
|
|
6
|
+
Skia
|
|
7
|
+
} from "@shopify/react-native-skia";
|
|
8
|
+
import { memo } from "@impulse-ui-native/core";
|
|
9
|
+
import {
|
|
10
|
+
LabelDefaultHorizontalAlignment,
|
|
11
|
+
LabelDefaultVerticalAlignment,
|
|
12
|
+
TabularNumsFeature
|
|
13
|
+
} from "../../constants";
|
|
14
|
+
import {
|
|
15
|
+
createParagraphBuilder,
|
|
16
|
+
getLabelTextAlign,
|
|
17
|
+
getLabelY
|
|
18
|
+
} from "../../utils";
|
|
19
|
+
const Label = memo(function Label2(props) {
|
|
20
|
+
const {
|
|
21
|
+
color,
|
|
22
|
+
fontManager,
|
|
23
|
+
fontSize,
|
|
24
|
+
fontFamily,
|
|
25
|
+
fontWeight,
|
|
26
|
+
horizontalAlign = LabelDefaultHorizontalAlignment,
|
|
27
|
+
rect,
|
|
28
|
+
rotation = 0,
|
|
29
|
+
text,
|
|
30
|
+
theme,
|
|
31
|
+
tnum,
|
|
32
|
+
maxLines = 1,
|
|
33
|
+
verticalAlign = LabelDefaultVerticalAlignment
|
|
34
|
+
} = props;
|
|
35
|
+
const paragraph = useMemo(() => {
|
|
36
|
+
const fontFeatures = [];
|
|
37
|
+
if (tnum) {
|
|
38
|
+
fontFeatures.push(TabularNumsFeature);
|
|
39
|
+
}
|
|
40
|
+
const textStyle = {
|
|
41
|
+
color: Skia.Color(color ?? theme.colors.text.secondary),
|
|
42
|
+
fontSize: fontSize ?? theme.fontSize.xs,
|
|
43
|
+
fontFeatures
|
|
44
|
+
};
|
|
45
|
+
if (fontFamily) {
|
|
46
|
+
textStyle.fontFamilies = [fontFamily];
|
|
47
|
+
}
|
|
48
|
+
if (fontWeight !== void 0) {
|
|
49
|
+
textStyle.fontStyle = { weight: fontWeight };
|
|
50
|
+
}
|
|
51
|
+
const result = createParagraphBuilder({
|
|
52
|
+
paragraphStyle: {
|
|
53
|
+
ellipsis: "\u2026",
|
|
54
|
+
maxLines: Math.max(1, Math.floor(maxLines)),
|
|
55
|
+
textAlign: getLabelTextAlign(horizontalAlign)
|
|
56
|
+
},
|
|
57
|
+
typefaceProvider: fontManager
|
|
58
|
+
}).pushStyle(textStyle).addText(text).pop().build();
|
|
59
|
+
result.layout(rect.width);
|
|
60
|
+
return result;
|
|
61
|
+
}, [
|
|
62
|
+
color,
|
|
63
|
+
fontManager,
|
|
64
|
+
fontFamily,
|
|
65
|
+
fontSize,
|
|
66
|
+
fontWeight,
|
|
67
|
+
horizontalAlign,
|
|
68
|
+
rect.width,
|
|
69
|
+
text,
|
|
70
|
+
theme.colors.text.secondary,
|
|
71
|
+
theme.fontSize.xs,
|
|
72
|
+
tnum,
|
|
73
|
+
maxLines
|
|
74
|
+
]);
|
|
75
|
+
const rotationProps = useMemo(
|
|
76
|
+
() => ({
|
|
77
|
+
origin: {
|
|
78
|
+
x: rect.x + rect.width / 2,
|
|
79
|
+
y: rect.y + rect.height / 2
|
|
80
|
+
},
|
|
81
|
+
transform: [{ rotate: rotation * Math.PI / 180 }]
|
|
82
|
+
}),
|
|
83
|
+
[rect.height, rect.width, rect.x, rect.y, rotation]
|
|
84
|
+
);
|
|
85
|
+
if (!paragraph) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const y = getLabelY(rect, paragraph.getHeight(), verticalAlign);
|
|
89
|
+
return /* @__PURE__ */ jsx(Group, { origin: rotationProps.origin, transform: rotationProps.transform, children: /* @__PURE__ */ jsx(Paragraph, { paragraph, x: rect.x, y, width: rect.width }) });
|
|
90
|
+
});
|
|
91
|
+
export {
|
|
92
|
+
Label
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/primitives/label.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n Group,\n Paragraph,\n Skia,\n SkTextFontFeatures,\n SkTextStyle,\n} from \"@shopify/react-native-skia\";\n\nimport { memo } from \"@impulse-ui-native/core\";\n\nimport {\n LabelDefaultHorizontalAlignment,\n LabelDefaultVerticalAlignment,\n TabularNumsFeature,\n} from \"../../constants\";\nimport { LabelProps } from \"../../types\";\nimport {\n createParagraphBuilder,\n getLabelTextAlign,\n getLabelY,\n} from \"../../utils\";\n\nexport const Label = memo(function Label(props: LabelProps) {\n const {\n color,\n fontManager,\n fontSize,\n fontFamily,\n fontWeight,\n horizontalAlign = LabelDefaultHorizontalAlignment,\n rect,\n rotation = 0,\n text,\n theme,\n tnum,\n maxLines = 1,\n verticalAlign = LabelDefaultVerticalAlignment,\n } = props;\n\n const paragraph = useMemo(() => {\n const fontFeatures: SkTextFontFeatures[] = [];\n\n if (tnum) {\n fontFeatures.push(TabularNumsFeature);\n }\n\n const textStyle: SkTextStyle = {\n color: Skia.Color(color ?? theme.colors.text.secondary),\n fontSize: fontSize ?? theme.fontSize.xs,\n fontFeatures,\n };\n\n if (fontFamily) {\n textStyle.fontFamilies = [fontFamily];\n }\n\n if (fontWeight !== undefined) {\n textStyle.fontStyle = { weight: fontWeight };\n }\n\n const result = createParagraphBuilder({\n paragraphStyle: {\n ellipsis: \"\\u2026\",\n maxLines: Math.max(1, Math.floor(maxLines)),\n textAlign: getLabelTextAlign(horizontalAlign),\n },\n typefaceProvider: fontManager,\n })\n .pushStyle(textStyle)\n .addText(text)\n .pop()\n .build();\n\n result.layout(rect.width);\n\n return result;\n }, [\n color,\n fontManager,\n fontFamily,\n fontSize,\n fontWeight,\n horizontalAlign,\n rect.width,\n text,\n theme.colors.text.secondary,\n theme.fontSize.xs,\n tnum,\n maxLines,\n ]);\n\n const rotationProps = useMemo(\n () => ({\n origin: {\n x: rect.x + rect.width / 2,\n y: rect.y + rect.height / 2,\n },\n transform: [{ rotate: (rotation * Math.PI) / 180 }],\n }),\n [rect.height, rect.width, rect.x, rect.y, rotation],\n );\n\n if (!paragraph) {\n return null;\n }\n\n const y = getLabelY(rect, paragraph.getHeight(), verticalAlign);\n\n return (\n <Group origin={rotationProps.origin} transform={rotationProps.transform}>\n <Paragraph paragraph={paragraph} x={rect.x} y={y} width={rect.width} />\n </Group>\n );\n});\n"],"mappings":"AA+GM;AA/GN,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,YAAY;AAErB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,QAAQ,KAAK,SAASA,OAAM,OAAmB;AAC1D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,gBAAgB;AAAA,EAClB,IAAI;AAEJ,QAAM,YAAY,QAAQ,MAAM;AAC9B,UAAM,eAAqC,CAAC;AAE5C,QAAI,MAAM;AACR,mBAAa,KAAK,kBAAkB;AAAA,IACtC;AAEA,UAAM,YAAyB;AAAA,MAC7B,OAAO,KAAK,MAAM,SAAS,MAAM,OAAO,KAAK,SAAS;AAAA,MACtD,UAAU,YAAY,MAAM,SAAS;AAAA,MACrC;AAAA,IACF;AAEA,QAAI,YAAY;AACd,gBAAU,eAAe,CAAC,UAAU;AAAA,IACtC;AAEA,QAAI,eAAe,QAAW;AAC5B,gBAAU,YAAY,EAAE,QAAQ,WAAW;AAAA,IAC7C;AAEA,UAAM,SAAS,uBAAuB;AAAA,MACpC,gBAAgB;AAAA,QACd,UAAU;AAAA,QACV,UAAU,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,CAAC;AAAA,QAC1C,WAAW,kBAAkB,eAAe;AAAA,MAC9C;AAAA,MACA,kBAAkB;AAAA,IACpB,CAAC,EACE,UAAU,SAAS,EACnB,QAAQ,IAAI,EACZ,IAAI,EACJ,MAAM;AAET,WAAO,OAAO,KAAK,KAAK;AAExB,WAAO;AAAA,EACT,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA,MAAM,OAAO,KAAK;AAAA,IAClB,MAAM,SAAS;AAAA,IACf;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,gBAAgB;AAAA,IACpB,OAAO;AAAA,MACL,QAAQ;AAAA,QACN,GAAG,KAAK,IAAI,KAAK,QAAQ;AAAA,QACzB,GAAG,KAAK,IAAI,KAAK,SAAS;AAAA,MAC5B;AAAA,MACA,WAAW,CAAC,EAAE,QAAS,WAAW,KAAK,KAAM,IAAI,CAAC;AAAA,IACpD;AAAA,IACA,CAAC,KAAK,QAAQ,KAAK,OAAO,KAAK,GAAG,KAAK,GAAG,QAAQ;AAAA,EACpD;AAEA,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,QAAM,IAAI,UAAU,MAAM,UAAU,UAAU,GAAG,aAAa;AAE9D,SACE,oBAAC,SAAM,QAAQ,cAAc,QAAQ,WAAW,cAAc,WAC5D,8BAAC,aAAU,WAAsB,GAAG,KAAK,GAAG,GAAM,OAAO,KAAK,OAAO,GACvE;AAEJ,CAAC;","names":["Label"]}
|
|
@@ -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 { LineProps } from '../../types/line.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 Line: <X extends ChartXValue = number>(props: LineProps<X>) => react_jsx_runtime.JSX.Element | null;
|
|
10
|
+
|
|
11
|
+
export { Line };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { DashPathEffect, Path } from "@shopify/react-native-skia";
|
|
4
|
+
import { memo } from "@impulse-ui-native/core";
|
|
5
|
+
import {
|
|
6
|
+
LineDefaultCap,
|
|
7
|
+
LineDefaultColor,
|
|
8
|
+
LineDefaultCurve,
|
|
9
|
+
LineDefaultJoin,
|
|
10
|
+
LineDefaultOpacity,
|
|
11
|
+
LineDefaultWidth
|
|
12
|
+
} from "../../constants";
|
|
13
|
+
import { createLinePath } from "../../utils";
|
|
14
|
+
const Line = memo(function Line2(props) {
|
|
15
|
+
const {
|
|
16
|
+
cap = LineDefaultCap,
|
|
17
|
+
color = LineDefaultColor,
|
|
18
|
+
coordinates,
|
|
19
|
+
curve = LineDefaultCurve,
|
|
20
|
+
dash,
|
|
21
|
+
join = LineDefaultJoin,
|
|
22
|
+
opacity = LineDefaultOpacity,
|
|
23
|
+
visible = true,
|
|
24
|
+
width = LineDefaultWidth
|
|
25
|
+
} = props;
|
|
26
|
+
const path = useMemo(
|
|
27
|
+
() => createLinePath(coordinates, curve),
|
|
28
|
+
[coordinates, curve]
|
|
29
|
+
);
|
|
30
|
+
if (!visible || !path) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
Path,
|
|
35
|
+
{
|
|
36
|
+
path,
|
|
37
|
+
color,
|
|
38
|
+
opacity,
|
|
39
|
+
strokeWidth: width,
|
|
40
|
+
style: "stroke",
|
|
41
|
+
strokeCap: cap,
|
|
42
|
+
strokeJoin: join,
|
|
43
|
+
children: dash?.length ? /* @__PURE__ */ jsx(DashPathEffect, { intervals: [...dash] }) : null
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
Line
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=line.js.map
|