Tvd
Tvd

Reputation: 4601

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. Am I trying something that's not possible or need another way out for the same. My 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 :

<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.

Upvotes: 0

Views: 1762

Answers (1)

Kcvin
Kcvin

Reputation: 5163

Have you tried setting MinWidth of the chart or maybe the MaxWidth of the 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.

Upvotes: 1

Related Questions