Page 1 of 1
How to add/show scrollviewer for teechart
Posted: Tue Apr 30, 2013 2:07 pm
by 16063571
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
Re: How to add/show scrollviewer for teechart
Posted: Thu May 02, 2013 3:27 pm
by 10050769
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,
Re: How to add/show scrollviewer for teechart
Posted: Fri May 03, 2013 5:13 am
by 16063571
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
Re: How to add/show scrollviewer for teechart
Posted: Fri May 03, 2013 2:00 pm
by 10050769
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,
Re: How to add/show scrollviewer for teechart
Posted: Sat May 04, 2013 9:55 am
by 16063571
Hi Sandra,
I will try the code and let you know.
Thank You.