我的图表有大量数据,需要滚动才能正确查看。我尝试将滚动查看器添加到我的 userControl(包含图表)、窗口、图表内部,但我无法滚动图表。我是在尝试一些不可能的事情,还是需要另一种方法。我的用户控件 xml:
<UserControl x:Class="WellBore.Graphs.BaseCaseSiReturnPlot"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:DV="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:DVC="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="1500">
<Grid>
<DVC:Chart Name="siReturnChart" Title="Base Case Si Return" LegendTitle="Legend">
<!-- Add Title on Y axis and X Axis -->
<DVC:Chart.Axes>
<DVC:LinearAxis Orientation="Y" Title="Chemical Concentration" HorizontalAlignment="Center" Location="Left" FontWeight="Bold" />
<DVC:LinearAxis Orientation="X" Location="Bottom" Interval="100" />
<DVC:CategoryAxis Orientation="X" Title="Production time (days)" HorizontalAlignment="Center" Location="Bottom" FontWeight="Bold" />
</DVC:Chart.Axes>
<DVC:Chart.Series>
<DVC:LineSeries Name="layer1Chart" Title="Layer 1" IndependentValueBinding="{Binding X}" DependentValueBinding="{Binding Y}" />
<DVC:LineSeries Name="layer2Chart" Title="Layer 2" IndependentValueBinding="{Binding X}" DependentValueBinding="{Binding Y}" />
<DVC:LineSeries Name="layer3Chart" Title="Layer 3" IndependentValueBinding="{Binding X}" DependentValueBinding="{Binding Y}" />
<DVC:LineSeries Name="layer4Chart" Title="Layer 4" IndependentValueBinding="{Binding X}" DependentValueBinding="{Binding Y}" />
<DVC:LineSeries Name="layer5Chart" Title="Layer 5" IndependentValueBinding="{Binding X}" DependentValueBinding="{Binding Y}" />
<DVC:LineSeries Name="wellChart" Title="Whole Well" IndependentValueBinding="{Binding X}" DependentValueBinding="{Binding Y}" />
</DVC:Chart.Series>
</DVC:Chart>
</Grid>
窗口 xml:
<Window x:Class="WellBore.Graphs.ViewGraphWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Graph Window" Height="680" Width="1300"
WindowStartupLocation="CenterOwner"Topmost="True" >
<ScrollViewer HorizontalScrollB Visibility="Visible" VerticalScrollBarVisibility="Visible" CanContentScroll="True" Margin="0, -28, 0, 28" >
<Grid Name="gridContent" Height="600" Background="DarkGray">
</Grid>
</ScrollViewer>
</Window>
要添加到窗口网格:
private void AddChild(UserControl uc)
{
gridContent.Children.Clear();
gridContent.Children.Add(uc);
}
知道为什么图表不可滚动吗?它正好适合窗口大小。即使最大化窗口也不能使图表数据完全可见——点是重叠的。
滚动此类图表对于此图表非常重要。