Page 1 of 1
Scrolling and Paging with AutoScroll
Posted: Wed Feb 11, 2015 11:27 am
by 16071129
In one of our requirement we need to scroll bottom X Axis with Page.AutoScale=True. We are using a ScrollBar control to handle TeeCharts Scroll and Paging Event together.
Here is the Sample Code:
Code: Select all
Form Load Event:
totalSampleValues =1000;
displayValues=50;
pageNumber = totalSampleValues / displayValues;
this.tChart1.Page.MaxPointsPerPage = displayValues;
this.tChart1.Page.Current = pageNumber;
this.tChart1.Page.AutoScale = true;
this.tChart1.Draw();
On ScrollBar Event
if (currentMinMargin < previousMinMargin-displayValues)
{
this.tChart1.Page.Previous();
pageNumber = pageNumber - 1;
this.tChart1.Page.Current = pageNumber;
previousMinMargin = currentMinMargin;
previousMaxMargin = currentMaxMargin;
}
else if (currentMaxMargin > previousMaxMargin + displayValues)
{
this.tChart1.Page.Next();
pageNumber = pageNumber + 1;
this.tChart1.Page.Current = pageNumber;
previousMinMargin = currentMinMargin;
previousMaxMargin = currentMaxMargin;
}
this.tChart1.Invalidate();
Above code works fine for the paging and scrolling purpose but
AutoScale Property only works at Page Change Event. It should work for every scroll event.
Please help us to resolve this.
Re: Scrolling and Paging with AutoScroll
Posted: Wed Feb 11, 2015 3:00 pm
by Christopher
Hello Quant,
This is the code I am using with TeeChart.dll v.4.1.2014.12150:
Code: Select all
int totalSampleValues, displayValues, pageNumber;
private void InitializeChart()
{
totalSampleValues = 1000;
displayValues = 50;
pageNumber = totalSampleValues / displayValues;
this.tChart1.Page.MaxPointsPerPage = displayValues;
this.tChart1.Page.Current = pageNumber;
this.tChart1.Page.AutoScale = true;
this.tChart1.Draw();
tChart1.Series.Add(typeof(Line)).FillSampleValues(totalSampleValues);
Steema.TeeChart.Tools.LegendScrollBar scroll = new Steema.TeeChart.Tools.LegendScrollBar(tChart1.Chart);
scroll.Scrolled += scroll_Scrolled;
}
int previousMaxMargin, currentMinMargin, previousMinMargin, currentMaxMargin;
void scroll_Scrolled(object sender, EventArgs e)
{
if (currentMinMargin < previousMinMargin - displayValues)
{
this.tChart1.Page.Previous();
pageNumber = pageNumber - 1;
this.tChart1.Page.Current = pageNumber;
previousMinMargin = currentMinMargin;
previousMaxMargin = currentMaxMargin;
}
else if (currentMaxMargin > previousMaxMargin + displayValues)
{
this.tChart1.Page.Next();
pageNumber = pageNumber + 1;
this.tChart1.Page.Current = pageNumber;
previousMinMargin = currentMinMargin;
previousMaxMargin = currentMaxMargin;
}
this.tChart1.Invalidate();
}
Here, scrolling the scrollbar successfully updates and AutoScales the current page.
Re: Scrolling and Paging with AutoScroll
Posted: Thu Feb 12, 2015 5:17 am
by 16071129
Hi Christopher,
We appreciate your example. But that is not our requirement, and we already checked this option. What we require is scrolling the teechart using .Net's own ScrollBar control.
As we wrote we are able to scroll TeeChart using Scrollbar control, but while scrolling we are not getting page AutoScale property right.
Re: Scrolling and Paging with AutoScroll
Posted: Thu Feb 12, 2015 9:20 am
by Christopher
Quant,
Again, with the following code I am second guessing as to what your problem may be:
Code: Select all
int totalSampleValues, displayValues, pageNumber;
private void InitializeChart()
{
totalSampleValues = 1000;
displayValues = 50;
pageNumber = totalSampleValues / displayValues;
tChart1.Series.Add(typeof(Line)).FillSampleValues(totalSampleValues);
this.tChart1.Page.MaxPointsPerPage = displayValues;
this.tChart1.Page.Current = pageNumber;
this.tChart1.Page.AutoScale = true;
VScrollBar scroll = new VScrollBar();
scroll.Height = tChart1.Height;
tChart1.Controls.Add(scroll);
scroll.Scroll += scroll_Scroll;
scroll.Minimum = 1;
scroll.Maximum = this.tChart1.Page.Count;
}
void scroll_Scroll(object sender, ScrollEventArgs e)
{
this.tChart1.Page.Current = e.NewValue;
}
again, this code works as expected here. Would you be so kind as to modify the above code snippet so I can reproduce your problem here?
Re: Scrolling and Paging with AutoScroll
Posted: Thu Feb 12, 2015 11:43 am
by 16071129
Hi,
We solved this problem by combining our code with the code presented here
http://www.teechart.net/support/viewtopic.php?t=5060.
Thanks for your help.