TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
Quant
- Advanced
- Posts: 142
- Joined: Tue Dec 30, 2014 12:00 am
Post
by Quant » Wed Feb 11, 2015 11:27 am
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.
-
Christopher
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Post
by Christopher » Wed Feb 11, 2015 3:00 pm
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.
-
Quant
- Advanced
- Posts: 142
- Joined: Tue Dec 30, 2014 12:00 am
Post
by Quant » Thu Feb 12, 2015 5:17 am
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.
-
Christopher
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Post
by Christopher » Thu Feb 12, 2015 9:20 am
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?