热力图(HeatMapChart)

1import { Chart, HeatMapChart, Navigation, NavigationStack, Script, VStack } from "scripting"
2
3const data = [
4  { positive: "+", negative: "+", num: 125 },
5  { positive: "+", negative: "-", num: 10 },
6  { positive: "-", negative: "-", num: 80 },
7  { positive: "-", negative: "+", num: 1 },
8]
9
10function Example() {
11
12  return <NavigationStack>
13    <VStack
14      navigationTitle={"HeatMapChart"}
15      navigationBarTitleDisplayMode={"inline"}
16    >
17      <Chart
18        aspectRatio={{
19          value: 1,
20          contentMode: 'fit'
21        }}
22      >
23        <HeatMapChart
24          marks={
25            data.map(item => ({
26              x: item.positive,
27              y: item.negative,
28              value: item.num,
29            }))
30          }
31        />
32      </Chart>
33    </VStack>
34  </NavigationStack>
35}
36
37async function run() {
38  await Navigation.present({
39    element: <Example />
40  })
41
42  Script.exit()
43}
44
45run()