1import {
2 Chart,
3 RuleLineForLabelChart,
4 BarChart,
5 Navigation,
6 NavigationStack,
7 Script,
8 VStack
9} from "scripting"
10
11const data = [
12 { label: "Q1", value: 1500 },
13 { label: "Q2", value: 2300 },
14 { label: "Q3", value: 1800 },
15 { label: "Q4", value: 2700 },
16]
17
18const referenceLines = [
19 { label: "Q2", foregroundStyle: "blue", lineStyle: { dash: [3, 2] } },
20 { label: "Q4", foregroundStyle: "red", opacity: 0.5 },
21]
22
23function Example() {
24 return (
25 <NavigationStack>
26 <VStack
27 navigationTitle="带参考线的柱状图"
28 navigationBarTitleDisplayMode="inline"
29 >
30 <Chart frame={{ height: 300 }}>
31 <BarChart marks={data} />
32 <RuleLineForLabelChart marks={referenceLines} />
33 </Chart>
34 </VStack>
35 </NavigationStack>
36 )
37}
38
39async function run() {
40 await Navigation.present({ element: <Example /> })
41 Script.exit()
42}
43
44run()