LineDataChart.xaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <UserControl x:Class="Aitex.Core.UI.Control.LineDataChart"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:sciChart="http://schemas.abtsoftware.co.uk/scichart"
  7. xmlns:cv="clr-namespace:Aitex.Core.UI.Converters"
  8. mc:Ignorable="d"
  9. d:DesignHeight="600" d:DesignWidth="1000">
  10. <UserControl.Resources>
  11. <Style TargetType="ToggleButton">
  12. <Setter Property="Focusable" Value="False" />
  13. <Setter Property="Height" Value="22" />
  14. <Setter Property="Width" Value="80" />
  15. <Setter Property="FontSize" Value="11" />
  16. <Setter Property="Background" Value="Transparent" />
  17. <Setter Property="BorderThickness" Value="0.5" />
  18. </Style>
  19. <cv:LineColorConverter x:Key="colorConverter"/>
  20. <cv:bool2VisibilityConverter x:Key="bool2VisibilityConverter"/>
  21. <cv:Visibility2boolConverter x:Key="vis2bool" />
  22. <cv:RolloverDataTimeConverter x:Key="rolloverDataTimeConverter"/>
  23. <cv:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
  24. <cv:RolloverDataPointerInfoConverter x:Key="rolloverDataPointerInfoConverter"/>
  25. <!-- Template for the RolloverModifier tooltip to display AxisInfo collection (result of hit test) -->
  26. <ControlTemplate x:Key="RolloverLabelTemplate" TargetType="sciChart:TemplatableControl">
  27. <Border Background="#AAFFFFFF" BorderBrush="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" BorderThickness="2" CornerRadius="5">
  28. <StackPanel Margin="5">
  29. <TextBlock FontSize="12" FontWeight="Bold" Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" Text="{Binding SeriesName}"/>
  30. <TextBlock FontSize="11" Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}">
  31. <TextBlock.Text>
  32. <MultiBinding Converter="{StaticResource rolloverDataPointerInfoConverter}">
  33. <Binding Path="XValue"/>
  34. <Binding Path="Value"/>
  35. <Binding Path="RenderableSeries"/>
  36. </MultiBinding>
  37. </TextBlock.Text>
  38. </TextBlock>
  39. </StackPanel>
  40. </Border>
  41. </ControlTemplate>
  42. </UserControl.Resources>
  43. <Grid>
  44. <Grid.ColumnDefinitions>
  45. <ColumnDefinition x:Name="dataConfigPanelColumn" MinWidth="0" Width="0"/>
  46. <ColumnDefinition Width="0" />
  47. <ColumnDefinition Width="400*" />
  48. </Grid.ColumnDefinitions>
  49. <Grid Grid.Column="2">
  50. <!-- Create the chart surface -->
  51. <sciChart:SciChartSurface Name="sciChart" RenderableSeries="{Binding RenderableSeries}"
  52. sciChart:ThemeManager.Theme="ExpressionLight"
  53. Padding="0,0,0,0"
  54. MouseDoubleClick="sciChart_MouseDoubleClick"
  55. DebugWhyDoesntSciChartRender="False" BorderBrush="Gray" Focusable="False" IsTabStop="False">
  56. <!-- Create an X Axis -->
  57. <sciChart:SciChartSurface.XAxis>
  58. <sciChart:DateTimeAxis DrawMinorTicks="False"
  59. DrawMinorGridLines="False"
  60. DrawMajorBands="False"
  61. DrawMajorGridLines="False"
  62. Margin="0,0,0,0"
  63. SubDayTextFormatting="HH:mm:ss"
  64. TitleFontSize="15"
  65. FontSize="20"
  66. TextFormatting="HH:mm:ss"
  67. Id="DefaultAxisId" TitleFontWeight="Normal" />
  68. </sciChart:SciChartSurface.XAxis>
  69. <!-- Create a Y Axis -->
  70. <sciChart:SciChartSurface.YAxis>
  71. <sciChart:NumericAxis DrawMinorTicks="False" Visibility="Visible"
  72. DrawMinorGridLines="False"
  73. AxisAlignment="Right"
  74. Id="DefaultAxisId"
  75. MajorDelta="0.1"
  76. MinorDelta="0.1"
  77. DrawMajorBands="False"
  78. Focusable="False" BorderThickness="0"
  79. AutoRange="Always" DrawLabels="False"
  80. Width="0"
  81. DrawMajorGridLines="True" DrawMajorTicks="False">
  82. <sciChart:NumericAxis.GrowBy>
  83. <sciChart:DoubleRange Min="0.1" Max="0.1"/>
  84. </sciChart:NumericAxis.GrowBy>
  85. </sciChart:NumericAxis>
  86. </sciChart:SciChartSurface.YAxis>
  87. <!-- Create Y Axes on the Left and Right -->
  88. <sciChart:SciChartSurface.YAxes>
  89. <sciChart:NumericAxis TickTextBrush="Black" Id="PressureYAxisId" AxisAlignment="Left" MinWidth="75" MaxWidth="75" MouseEnter="NumericAxis_Pyro_MouseEnter" MouseLeave="NumericAxis_Pyro_MouseLeave" FontSize="20">
  90. <sciChart:NumericAxis.GrowBy>
  91. <sciChart:DoubleRange Min="0.1" Max="0.1"/>
  92. </sciChart:NumericAxis.GrowBy>
  93. </sciChart:NumericAxis>
  94. <sciChart:NumericAxis TickTextBrush="Black" Id="GeneralYAxisId" AxisAlignment="Right" MinWidth="75" MaxWidth="75" MouseLeave="NumericAxis_Reflect_MouseLeave" MouseEnter="NumericAxis_Reflect_MouseEnter" FontSize="20">
  95. <sciChart:NumericAxis.GrowBy>
  96. <sciChart:DoubleRange Min="0.1" Max="0.1"/>
  97. </sciChart:NumericAxis.GrowBy>
  98. </sciChart:NumericAxis>
  99. <!--<sciChart:NumericAxis TickTextBrush="Green" Id="CurvatureAxisId" AxisAlignment="Right" MinWidth="35" MaxWidth="35" MouseEnter="NumericAxis_Wrap_MouseEnter" MouseLeave="NumericAxis_Wrap_MouseLeave" FontSize="10">
  100. <sciChart:NumericAxis.GrowBy>
  101. <sciChart:DoubleRange Min="0.1" Max="0.1"/>
  102. </sciChart:NumericAxis.GrowBy>
  103. </sciChart:NumericAxis>-->
  104. </sciChart:SciChartSurface.YAxes>
  105. <!-- Vertical Lines Annotations>
  106. <sciChart:SciChartSurface.Annotations>
  107. <sciChart:VerticalLineAnnotation x:Name="vertical_Line1" X1="{Binding Time1,Mode=TwoWay}" X2="{Binding Time1,Mode=TwoWay}" Stroke="Red" VerticalAlignment="Stretch" ShowLabel="True" StrokeThickness="1.5" IsEditable="True" LabelTextFormatting="yyyy/MM/dd HH:mm:ss" IsHidden="True" LabelPlacement="Bottom" FontSize="10" Padding="0,0,0,20" />
  108. <sciChart:VerticalLineAnnotation x:Name="vertical_Line2" X1="{Binding Time2,Mode=TwoWay}" X2="{Binding Time2,Mode=TwoWay}" Stroke="Purple" VerticalAlignment="Stretch" ShowLabel="True" StrokeThickness="1.5" IsEditable="True" LabelTextFormatting="yyyy/MM/dd HH:mm:ss" IsHidden="True" LabelPlacement="Bottom" FontSize="10" />
  109. </sciChart:SciChartSurface.Annotations-->
  110. <!-- Specify interactivity modifiers -->
  111. <sciChart:SciChartSurface.ChartModifier>
  112. <sciChart:ModifierGroup ExecuteOn="MouseDoubleClick">
  113. <!-- Provides selection of series and custom styling to the selected series -->
  114. <!--<sciChart:SeriesSelectionModifier ExecuteOn="MouseLeftButton" ReceiveHandledEvents="True">
  115. <sciChart:SeriesSelectionModifier.SelectedSeriesStyle>
  116. <Style TargetType="sciChart:BaseRenderableSeries">
  117. <Setter Property="Width" Value="3"/>
  118. <Setter Property="PointMarkerTemplate">
  119. <Setter.Value>
  120. <ControlTemplate>
  121. <Ellipse Fill="#FFAA00AA" Stroke="Red" Width="8" Height="8"/>
  122. </ControlTemplate>
  123. </Setter.Value>
  124. </Setter>
  125. </Style>
  126. </sciChart:SeriesSelectionModifier.SelectedSeriesStyle>
  127. </sciChart:SeriesSelectionModifier>-->
  128. <sciChart:RubberBandXyZoomModifier x:Name="rubberBandZoomModifier" IsEnabled="True"
  129. IsXAxisOnly="False"
  130. ZoomExtentsY="False"
  131. IsAnimated="True" ExecuteOn="MouseLeftButton" ReceiveHandledEvents="True" />
  132. <!--<sciChart:ZoomExtentsModifier x:Name="zoomExtentsModifier" ExecuteOn="MouseDoubleClick"/>-->
  133. <sciChart:CursorModifier IsEnabled="True" ShowTooltipOn="MouseOver" ShowAxisLabels="True" SourceMode="AllSeries" ShowTooltip="False" />
  134. <!-- Provides a data source for the legend control -->
  135. <sciChart:LegendModifier ShowLegend="False" GetLegendDataFor="AllSeries" x:Name="legendModifier"/>
  136. <!--<sciChart:RubberBandXyZoomModifier IsEnabled="True" IsXAxisOnly="True"/>-->
  137. <!--<sciChart:CursorModifier IsEnabled="True"
  138. ShowAxisLabels="True"
  139. ShowTooltip="True" />-->
  140. <!--自由平移-->
  141. <sciChart:ZoomPanModifier x:Name="zoomPanModifier" IsEnabled="True" ExecuteOn="MouseRightButton" ClipModeX="None" />
  142. <!--移动鼠标时动态显示当前数据值-->
  143. <sciChart:RolloverModifier x:Name="rolloverModifier"
  144. UseInterpolation="False" FontSize="9" IsEnabled="True"
  145. DrawVerticalLine="False" FontFamily="Arial,SimSun"
  146. SnapsToDevicePixels="False"
  147. ShowAxisLabels="False" />
  148. <!--2020.3.1 upgrade to sciChart 6.0 this property is invalid =>TooltipLabelTemplate="{StaticResource RolloverLabelTemplate}" -->
  149. <!--<sciChart:LegendModifier x:Name="legendModifier" GetLegendDataFor="AllSeries"/>-->
  150. <!--<sciChart:RubberBandXyZoomModifier IsXAxisOnly="True"/>-->
  151. <!--<sciChart:XAxisDragModifier/>-->
  152. <!--<sciChart:YAxisDragModifier/>-->
  153. <!--<sciChart:ZoomExtentsModifier ExecuteOn="MouseDoubleClick"/>-->
  154. <!--双击自动显示全部视图-->
  155. <!--<sciChart:ZoomPanModifier ExecuteOn="MouseLeftButton"/>-->
  156. <!--
  157. <sciChart:XAxisDragModifier x:Name="xAxisDragModifier" IsEnabled="True" ClipModeX="None"/>
  158. <sciChart:YAxisDragModifier x:Name="yAxisRightDragmodifier" IsEnabled="True" YAxisId="DefaultAxisId"/>
  159. -->
  160. <sciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomModifier" XyDirection="XDirection"/>
  161. <!--滚轮滚动进行缩放操作-->
  162. <!--
  163. <sciChart:ZoomPanModifier ReceiveHandledEvents="True"></sciChart:ZoomPanModifier>
  164. <sciChart:ZoomExtentsModifier ExecuteOn="MouseDoubleClick"/>
  165. -->
  166. </sciChart:ModifierGroup>
  167. </sciChart:SciChartSurface.ChartModifier>
  168. </sciChart:SciChartSurface>
  169. <sciChart:SciChartLegend x:Name="legendControl" Visibility="Hidden"
  170. Grid.Row="0" Margin="5,5" ShowVisibilityCheckboxes="True"
  171. LegendData="{Binding LegendData, ElementName=legendModifier, Mode=OneWay}"
  172. FontSize="10" FontWeight="Light" />
  173. <!--<sciChart:SciChartOverview Grid.Row="1"
  174. ParentSurface="{Binding ElementName=sciChart}"
  175. SelectedRange="{Binding ElementName=sciChart, Path=XAxis.VisibleRange, Mode=TwoWay}"
  176. sciChart:ThemeManager.Theme="BlackSteel" BorderThickness="0,1,0,0" />-->
  177. <!-- Define a panel to display rollover results -->
  178. <!--
  179. <Border BorderBrush="#55000000" BorderThickness="2" Background="#77FFFFFF"
  180. VerticalAlignment="Top" CornerRadius="5"
  181. Margin="3,25,0,0" Padding="2" HorizontalAlignment="Left"
  182. Visibility="{Binding IsRolloverInfoDisplayEnabled,Converter={StaticResource bool2VisibilityConverter}}">
  183. <ItemsControl DataContext="{Binding ElementName=rolloverModifier}"
  184. ItemsSource="{Binding SeriesData.SeriesInfo}">
  185. <ItemsControl.ItemTemplate>
  186. <DataTemplate>
  187. <Grid Height="13" Opacity="0.9">
  188. <Grid.ColumnDefinitions>
  189. <ColumnDefinition Width="20"/>
  190. <ColumnDefinition Width="126"/>
  191. <ColumnDefinition Width="110"/>
  192. <ColumnDefinition Width="*"/>
  193. </Grid.ColumnDefinitions>
  194. <TextBlock Grid.Column="0" Background="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" Text=" " Margin="0" Height="8" />
  195. <TextBlock Grid.Column="1" Text="{Binding XValue,Converter={StaticResource rolloverDataTimeConverter}}" Margin="0" FontSize="9" FontFamily="Arial,SimSun" />
  196. <TextBlock Grid.Column="2" Margin="0" FontSize="9" FontFamily="Arial,SimSun">
  197. <TextBlock.Text>
  198. <MultiBinding Converter="{StaticResource rolloverDataValueConverter}">
  199. <Binding Path="Value"/>
  200. <Binding Path="RenderableSeries"/>
  201. </MultiBinding>
  202. </TextBlock.Text>
  203. </TextBlock>
  204. <TextBlock Grid.Column="3" Text="{Binding SeriesName}" Margin="0" FontSize="9" FontFamily="Arial,SimSun" HorizontalAlignment="Left"/>
  205. </Grid>
  206. </DataTemplate>
  207. </ItemsControl.ItemTemplate>
  208. </ItemsControl>
  209. </Border>
  210. -->
  211. <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="82,0,0,0">
  212. <!--<CheckBox Content="Display DataItems Panel" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="Black" IsChecked="True" Checked="checkConfigPanel_Checked" Unchecked="checkConfigPanel_Checked"/>-->
  213. <CheckBox Content="Auto Zoom" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" IsChecked="True" x:Name="ckAutoZoom" Checked="checkAutoRange_Checked" Unchecked="checkAutoRange_Checked"/>
  214. <!--
  215. <CheckBox Content="X轴滚动缩放" HorizontalAlignment="Left" IsChecked="{Binding IsXZoomEnabled}"/>
  216. <CheckBox Content="Y轴滚动缩放" HorizontalAlignment="Left" IsChecked="{Binding IsYZoomEnabled}" />
  217. -->
  218. <!--CheckBox Content="时间标尺 " HorizontalAlignment="Left" Name="checkTimeLine" Foreground="Black" VerticalAlignment="Center" Checked="checkTimeLine_Checked" Unchecked="checkTimeLine_Checked"/-->
  219. <Label Content="{Binding ProcessInfo}" VerticalAlignment="Center" Height="25" Margin="28,0,0,0" HorizontalAlignment="Left" BorderThickness="0" Width="auto" FontSize="12" FontFamily="Arial,SimSun" />
  220. </StackPanel>
  221. <Label Content="▲" HorizontalAlignment="Right" Margin="0,0,2,0" Name="warpAxisTopUp" BorderThickness="1" BorderBrush="Green" Width="34" HorizontalContentAlignment="Center" Padding="0.5" FontSize="13" FontWeight="ExtraBold" Background="White" Foreground="Green" Height="20" VerticalAlignment="Top" MouseLeave="NumericAxis_Wrap_MouseLeave" MouseLeftButtonDown="YAxisTopUp_Click" Tag="2" Visibility="Collapsed" />
  222. <Label BorderBrush="Red" BorderThickness="1" Content="▲" FontSize="13" FontWeight="ExtraBold" Height="20" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Name="pyroAxisTopUp" Padding="0.5" VerticalAlignment="Top" Width="34" Background="White" Foreground="Red" ForceCursor="False" MouseLeave="NumericAxis_Pyro_MouseLeave" MouseLeftButtonDown="YAxisTopUp_Click" Tag="0" Visibility="Collapsed" Margin="1,0,0,0" />
  223. <Label BorderBrush="Red" BorderThickness="1" Content="▼" FontSize="13" FontWeight="ExtraBold" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Margin="1,19,0,0" Name="pyroAxisTopDown" Padding="0.5" Width="34" Background="White" Foreground="Red" Height="20" VerticalAlignment="Top" ForceCursor="False" ClipToBounds="True" MouseLeave="NumericAxis_Pyro_MouseLeave" MouseLeftButtonDown="YAxisTopDown_Click" Tag="0" Visibility="Collapsed" />
  224. <Label BorderBrush="Green" BorderThickness="1" Content="▼" FontSize="13" FontWeight="ExtraBold" Height="20" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,19,2,0" Name="warpAxisTopDown" Padding="0.5" VerticalAlignment="Top" Width="34" Background="White" Foreground="Green" MouseLeave="NumericAxis_Wrap_MouseLeave" MouseLeftButtonDown="YAxisTopDown_Click" Tag="2" Visibility="Collapsed" />
  225. <Label Background="White" BorderBrush="Green" BorderThickness="1" Content="▲" FontSize="13" FontWeight="ExtraBold" Foreground="Green" Height="20" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,2,42" Name="warpAxisBottomUp" Padding="0.5" VerticalAlignment="Bottom" Width="34" MouseLeave="NumericAxis_Wrap_MouseLeave" Tag="2" MouseLeftButtonDown="YAxisBottomUp_Click" Visibility="Collapsed" />
  226. <Label Background="White" BorderBrush="Red" BorderThickness="1" Content="▲" FontSize="13" FontWeight="ExtraBold" Foreground="Red" Height="20" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Margin="1,0,0,42" Name="pyroAxisBottomUp" Padding="0.5" VerticalAlignment="Bottom" Width="34" ForceCursor="False" MouseLeave="NumericAxis_Pyro_MouseLeave" Tag="0" MouseLeftButtonDown="YAxisBottomUp_Click" Visibility="Collapsed" />
  227. <Label Background="White" BorderBrush="Red" BorderThickness="1" Content="▼" FontSize="13" FontWeight="ExtraBold" Foreground="Red" Height="20" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Margin="1,0,0,23" Name="pyroAxisBottomDown" Padding="0.5" VerticalAlignment="Bottom" Width="34" ForceCursor="False" MouseLeave="NumericAxis_Pyro_MouseLeave" Tag="0" MouseLeftButtonDown="YAxisBottomDown_Click" Visibility="Collapsed" />
  228. <Label Background="White" BorderBrush="Green" BorderThickness="1" Content="▼" FontSize="13" FontWeight="ExtraBold" Foreground="Green" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,2,23" Name="warpAxisBottomDown" Padding="0.5" Width="34" Height="20" VerticalAlignment="Bottom" MouseLeave="NumericAxis_Wrap_MouseLeave" Tag="2" MouseLeftButtonDown="YAxisBottomDown_Click" Visibility="Collapsed" />
  229. <Label Background="White" BorderBrush="Blue" BorderThickness="1" Content="▲" FontSize="13" FontWeight="ExtraBold" Foreground="Blue" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,36,0" Name="ReflectAxisTopUp" Padding="0.5" Width="34" MouseLeave="NumericAxis_Reflect_MouseLeave" MouseLeftButtonDown="YAxisTopUp_Click" Tag="1" Visibility="Collapsed" Height="20" VerticalAlignment="Top" />
  230. <Label Background="White" BorderBrush="Blue" BorderThickness="1" Content="▼" FontSize="13" FontWeight="ExtraBold" Foreground="Blue" Height="20" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,19,36,0" Name="ReflectAxisTopDown" Padding="0.5" VerticalAlignment="Top" Width="34" MouseLeave="NumericAxis_Reflect_MouseLeave" MouseLeftButtonDown="YAxisTopDown_Click" Tag="1" Visibility="Collapsed" />
  231. <Label Background="White" BorderBrush="Blue" BorderThickness="1" Content="▲" FontSize="13" FontWeight="ExtraBold" Foreground="Blue" Height="20" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,36,42" Name="ReflectAxisBottomUp" Padding="0.5" VerticalAlignment="Bottom" Width="34" MouseLeave="NumericAxis_Reflect_MouseLeave" Tag="1" MouseLeftButtonDown="YAxisBottomUp_Click" Visibility="Collapsed" />
  232. <Label Background="White" BorderBrush="Blue" BorderThickness="1" Content="▼" FontSize="13" FontWeight="ExtraBold" Foreground="Blue" Height="20" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Margin="0,0,36,23" Name="ReflectAxisBottomDown" Padding="0.5" VerticalAlignment="Bottom" Width="34" MouseLeave="NumericAxis_Reflect_MouseLeave" Tag="1" MouseLeftButtonDown="YAxisBottomDown_Click" Visibility="Collapsed" />
  233. </Grid>
  234. </Grid>
  235. </UserControl>