/
ScatterChart.xaml
227 lines (197 loc) · 13.7 KB
/
ScatterChart.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<Page
x:Class="Syncfusion.ChartDemos.WinUI.Views.ScatterChart"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:chart="using:Syncfusion.UI.Xaml.Charts"
xmlns:common="using:Syncfusion.DemosCommon.WinUI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Syncfusion.ChartDemos.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="Transparent"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="TooltipFill" Color="{StaticResource SystemBaseHighColor}"/>
<SolidColorBrush x:Key="TooltipForeground" Color="{StaticResource SystemAltHighColor}"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="TooltipFill" Color="{StaticResource SystemBaseHighColor}"/>
<SolidColorBrush x:Key="TooltipForeground" Color="{StaticResource SystemAltHighColor}"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="TooltipFill" Color="{ThemeResource SystemColorWindowColor}"/>
<SolidColorBrush x:Key="TooltipForeground" Color="{ThemeResource SystemColorWindowTextColor}"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<DataTemplate x:Key="tooltipTemplate">
<Grid RowDefinitions="Auto,Auto,Auto,Auto">
<StackPanel Grid.Row="0" Background="{ThemeResource TooltipFill}" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Male" FontSize="12" FontWeight="Bold"
Foreground="{ThemeResource TooltipForeground}"
HorizontalTextAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</StackPanel>
<Rectangle Grid.Row="1" Height="1.5" Fill="{ThemeResource TooltipForeground}" Margin="1"/>
<StackPanel Grid.Row="2" Background="{ThemeResource TooltipFill}" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text=" Height" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalTextAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock Text=":" Margin="3,0,3,0" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center" HorizontalTextAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock HorizontalTextAlignment="Center"
Text="{Binding Item.Value}"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<TextBlock HorizontalTextAlignment="Center"
Text=" cm"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</StackPanel>
<StackPanel Grid.Row="3" Background="{ThemeResource TooltipFill}" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Weight" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalTextAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock Text=":" Margin="3,0,3,0" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center" HorizontalTextAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock HorizontalTextAlignment="Center"
Text="{Binding Item.Size}"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<TextBlock HorizontalTextAlignment="Center"
Text=" kg"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</StackPanel>
</Grid>
</DataTemplate>
<DataTemplate x:Key="tooltipTemplate1">
<Grid RowDefinitions="Auto,Auto,Auto,Auto">
<StackPanel Grid.Row="0" Background="{ThemeResource TooltipFill}" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Female" FontSize="12" FontWeight="Bold"
Foreground="{ThemeResource TooltipForeground}"
HorizontalTextAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</StackPanel>
<Rectangle Grid.Row="1" Height="1.5" Fill="{ThemeResource TooltipForeground}" Margin="1"/>
<StackPanel Grid.Row="2" Background="{ThemeResource TooltipFill}" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text=" Height" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalTextAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock Text=":" Margin="3,0,3,0" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center" HorizontalTextAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock HorizontalTextAlignment="Center"
Text="{Binding Item.Value}"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<TextBlock HorizontalTextAlignment="Center"
Text=" cm"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</StackPanel>
<StackPanel Grid.Row="3" Background="{ThemeResource TooltipFill}" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Weight" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalTextAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock Text=":" Margin="3,0,3,0" FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center" HorizontalTextAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock HorizontalTextAlignment="Center"
Text="{Binding Item.Size}"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<TextBlock HorizontalTextAlignment="Center"
Text=" kg"
FontSize="11"
Foreground="{ThemeResource TooltipForeground}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</StackPanel>
</Grid>
</DataTemplate>
<DataTemplate x:Key="headerTemplate">
<TextBlock Text="Weight in kilogram" Padding="0,0,0,10"/>
</DataTemplate>
</ResourceDictionary>
</Grid.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto" VerticalScrollMode="Auto">
<common:DemoLayout HeaderText="This scatter chart illustrates the correlation between height and weight for both males and females, with each data point depicted as a circle of equal size.">
<common:DemoLayout.DataContext>
<local:ScatterChartViewModel />
</common:DemoLayout.DataContext>
<common:DemoLayout.Example>
<chart:SfCartesianChart x:Name="Chart" Height="420">
<chart:SfCartesianChart.Header>
<TextBlock FontSize="18" Text="Height vs Weight" />
</chart:SfCartesianChart.Header>
<chart:SfCartesianChart.Legend>
<chart:ChartLegend Padding="0,0,60,0"/>
</chart:SfCartesianChart.Legend>
<chart:SfCartesianChart.XAxes>
<chart:NumericalAxis ShowMajorGridLines="False" EdgeLabelsDrawingMode="Shift" Minimum="100" Maximum="220" Interval="20" Header="Height in centimeter"/>
</chart:SfCartesianChart.XAxes>
<chart:SfCartesianChart.YAxes>
<chart:NumericalAxis ShowMajorGridLines="False" Minimum="50" Maximum="80" Interval="5" HeaderTemplate="{StaticResource headerTemplate}"/>
</chart:SfCartesianChart.YAxes>
<chart:ScatterSeries EnableAnimation="True" ItemsSource="{Binding MaleData}" PointHeight="8" PointWidth="8"
XBindingPath="Value" YBindingPath="Size" EnableTooltip="True" Label="Male" Fill="{ThemeResource SeriesBrush2}" LegendIcon="Circle" TooltipTemplate="{StaticResource tooltipTemplate}"/>
<chart:ScatterSeries EnableAnimation="True" ItemsSource="{Binding FemaleData}" PointHeight="8" PointWidth="8"
XBindingPath="Value" YBindingPath="Size" EnableTooltip="True" Label="Female" Fill="{ThemeResource SeriesBrush1}" LegendIcon="Circle" TooltipTemplate="{StaticResource tooltipTemplate1}"/>
</chart:SfCartesianChart>
</common:DemoLayout.Example>
<common:DemoLayout.Xaml>
<x:String xml:space="preserve">
<chart:SfCartesianChart x:Name="Chart" Header="Height vs Weight">
<chart:SfCartesianChart.Legend>
<chart:ChartLegend/>
</chart:SfCartesianChart.Legend>
<chart:SfCartesianChart.XAxes>
<chart:NumericalAxis ShowMajorGridLines="False" EdgeLabelsDrawingMode="Shift" Minimum="100"
Header="Height in centimeter" Interval="20" Maximum="220"/>
</chart:SfCartesianChart.XAxes>
<chart:SfCartesianChart.YAxes>
<chart:NumericalAxis Interval="5" ShowMajorGridLines="False" Maximum="80"
Minimum="50" HeaderTemplate="{StaticResource headerTemplate}"/>
</chart:SfCartesianChart.YAxes>
<chart:ScatterSeries ItemsSource="{Binding MaleData}" YBindingPath="Size"
XBindingPath="Value" PointHeight="8" Fill="{ThemeResource SeriesBrush2}"
PointWidth="8" EnableTooltip="True" Label="Male" EnableAnimation="True"
LegendIcon="Circle" TooltipTemplate="{StaticResource tooltipTemplate}"/>
<chart:ScatterSeries ItemsSource="{Binding FemaleData}" XBindingPath="Value"
YBindingPath="Size" PointHeight="8" Fill="{ThemeResource SeriesBrush1}"
PointWidth="8" EnableTooltip="True" Label="Female" EnableAnimation="True"
LegendIcon="Circle" TooltipTemplate="{StaticResource tooltipTemplate1}"/>
</chart:SfCartesianChart>
</x:String>
</common:DemoLayout.Xaml>
</common:DemoLayout>
</ScrollViewer>
</Grid>
</Page>