How to add/show scrollviewer for teechart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
gilbert
Newbie
Newbie
Posts: 21
Joined: Fri Sep 28, 2012 12:00 am

How to add/show scrollviewer for teechart

Post by gilbert » Tue Apr 30, 2013 2:07 pm

Hi,

I am working on teechart using line series to display csv file data.
My requirement is to scroll the teechart line series as they go beyond the x axis and if I move scrollviewer forward, then current line series should be shown.

I can achieve it using AxisArrow on x-axis which will result displaying left arrow and right arrow on x axis and the data can be scrolled back and forth once we click on arrow.

But I would like to have a scrollviewer down the teechart and should show the same behaviour with its mousewheel/scroll changed.
I would like to show the scrollviewer for the teechart and achieve the scrolling functionality for the teechart lines.

Please help me to solve the problem.


Thanks,
Archana

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: How to add/show scrollviewer for teechart

Post by Sandra » Thu May 02, 2013 3:27 pm

Hello Archana,

Sorry for the delay. I think you could use a similar code as All Features\Welcome !\Axes\Opaque zones. For this reason, I have made a simple code in Wpf based in this example, but using a scrollviewer. Is possible you need adjust the ScrollChange event values.

C# code

Code: Select all

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false; 
            tChart1.Series.Add(new Steema.TeeChart.WPF.Styles.FastLine()).FillSampleValues(100);
           scrollviewer1.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
           scrollviewer1.ScrollChanged += scrollviewer1_ScrollChanged;
           tChart1.Axes.Bottom.SetMinMax(0, 50); 
        }

        void scrollviewer1_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {

           double tmp = 0.01 * ((int)e.HorizontalChange-10) * (tChart1[0].XValues.Maximum - tChart1[0].XValues.Minimum);
           tChart1[0].GetHorizAxis.SetMinMax(tChart1[0].XValues.Maximum + tmp, tChart1[0].XValues.Minimum + tmp);
          
        }
xaml code

Code: Select all

   <ScrollViewer HorizontalAlignment="Left" Height="600" VerticalAlignment="Bottom" Width="800" Name="scrollviewer1">
        <WPF:TChart Height="600" Width="1000" x:Name="tChart1"/>
     
    </ScrollViewer>
Can you tell us if previous code help you achieve as you want?
Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

gilbert
Newbie
Newbie
Posts: 21
Joined: Fri Sep 28, 2012 12:00 am

Re: How to add/show scrollviewer for teechart

Post by gilbert » Fri May 03, 2013 5:13 am

Hi Sandra,

Thank you for the reply.
In this case,Horizontal scrollviewer is applying for teechart control.
But I would like to have a scrollbar/scrollviewer for the line series in teechart control i.e., the live data(line series) flowing in teechart control should scroll back and forward on the scrolling event.

I just tried below link to achieve it.
http://www.teechart.net/support/viewtop ... f=4&t=1924

Which works for the series in teechart.

Thanks

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: How to add/show scrollviewer for teechart

Post by Sandra » Fri May 03, 2013 2:00 pm

Hello Archana,

I have modified my code because the line series does scroll. To achieve it, I have used a stackpanel with a size that is three times the size of scrollviewer. After, you only need relate the Axis bottom with scrollviewer and I achieved scrolling line with scrollviewer. I think you can do something as next:

C# MainWindow code:

Code: Select all

        public MainWindow()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            scrollviewer1.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scrollviewer1.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
            Random Rnd = new Random();
            tChart1.Aspect.View3D = false;
            tChart1.Series.Add(new Steema.TeeChart.WPF.Styles.Line());
            for (int i = 0; i <= 100; i++)
                tChart1.Series[0].Add(i, Rnd.Next(100), "");
            tChart1.Axes.Bottom.SetMinMax(0, 50);
            scrollviewer1.ScrollToHorizontalOffset(0);
          
        }
        int AxisMax = 0;
        int AxisMin = 100;

        private void scrollviewer1_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            
            if (e.HorizontalChange< 50)
                tChart1.Axes.Bottom.SetMinMax(AxisMin - (10 -e.HorizontalOffset), AxisMax - (10- e.HorizontalOffset));
            else
                tChart1.Axes.Bottom.SetMinMax(AxisMin + (e.HorizontalOffset - 10), AxisMax + (e.HorizontalOffset - 10));
            tChart1.Invalidate();
        }
Xaml MainWindow code:

Code: Select all

    <Grid Width="692.537" Margin="0,0,0,0">
        <WPF:TChart Height="451.865" Width="685" x:Name="tChart1" />
        <ScrollViewer   HorizontalAlignment="Left" Height="100" 
           Margin="0,0,0,0" VerticalAlignment="Bottom" Width="685"
            Name="scrollviewer1" 
           ScrollChanged="scrollviewer1_ScrollChanged">
            <StackPanel  Height="0" Width="2055" OverridesDefaultStyle="False" />    <!--<WPF:TChart Height="451.865" Width="685" x:Name="tChart1" />-->
        </ScrollViewer>
    </Grid>
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

gilbert
Newbie
Newbie
Posts: 21
Joined: Fri Sep 28, 2012 12:00 am

Re: How to add/show scrollviewer for teechart

Post by gilbert » Sat May 04, 2013 9:55 am

Hi Sandra,

I will try the code and let you know.

Thank You.

Post Reply