简体   繁体   English

wpf图表为什么图表不滚动? 不可能吗

[英]wpf charting Why chart doesn't scroll ? Is it not possible?

My charts have huge data and need it to scroll to view it properly. 我的图表包含大量数据,需要滚动才能正确查看。 I tried adding scrollviewer to my userControl (that contains chart), to window, inside the chart but in no way I am able to scroll the chart. 我尝试将scrollviewer添加到我的userControl(包含图表)中,图表内的窗口中,但无法以任何方式滚动图表。 Am I trying something that's not possible or need another way out for the same. 我是在尝试一些不可能的事情还是需要另一种出路呢? My UserControl xml : 我的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>

Window xml : 窗口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>

To add to the window grid : 要添加到窗口网格中:

private void AddChild(UserControl uc)
{
     gridContent.Children.Clear();
     gridContent.Children.Add(uc);
}

Any idea why the chart is not scrollable ? 知道为什么图表不可滚动吗? It just fits in the window size. 它恰好适合窗口大小。 Even maximize window doesn't make the chart data completely visible - dots are overlapped. 即使最大化窗口也无法使图表数据完全可见-点是重叠的。

Scrolling such charts is very important for this chart. 滚动此类图表对于此图表非常重要。

Have you tried setting MinWidth of the chart or maybe the MaxWidth of the gridContent ? 您是否尝试设置MinWidth图表或也许MaxWidth中的gridContent Since no widths are set, the controls are defaulting to Double.NaN so they are sizing to however the control defines them to size. 由于未设置宽度,因此控件默认为Double.NaN因此将它们调整为适合控件大小的尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM