How to set scrollbar min,max to teechart bottom axis min max
Posted: Mon May 06, 2013 6:11 am
Hi,
I am binding a collection of data from csv file to teechart.
I am showing a scrollbar for teechart data, when it scrolls the data in teechart will get moved.
But I am not able to set correct teechart bottom axis min max values to scrollbar minimum and maximum values.
Also what value can I set the scrollbar value initially on teechart data.
Please suggest to set exact minimum and maximum values for scrollbar from teechart bottom axis.
I have given my code below which works fine showing scrollbar and able to scroll the data.
Scrollbar showing the correct maximum value but minimum value is not equal to teechart bottom axis minvalue.
Please suggest me on this.
I am binding a collection of data from csv file to teechart.
I am showing a scrollbar for teechart data, when it scrolls the data in teechart will get moved.
But I am not able to set correct teechart bottom axis min max values to scrollbar minimum and maximum values.
Also what value can I set the scrollbar value initially on teechart data.
Please suggest to set exact minimum and maximum values for scrollbar from teechart bottom axis.
I have given my code below which works fine showing scrollbar and able to scroll the data.
Scrollbar showing the correct maximum value but minimum value is not equal to teechart bottom axis minvalue.
- <---Xaml code ---->
<Grid>
<Stackpanel>
<tChart:TChart x:Name="_TChart" ></tChart:TChart>
<ScrollBar Style="{StaticResource ScrollBarStyle}" Orientation="Horizontal" Height="15" x:Name="PART_HScrollBar"></ScrollBar>
</Stackpanel>
</Grid>
<----- C# code ------>
double AxisMax = 100;
double AxisMin = 0;
double value;
InitializeChart()
{
MapData();
// Set the Horizondal axis Span
double minTimeSpan = DateTime.FromOADate(maximumSeriesValue).AddSeconds(GetDisplaySpanInSeconds(TimeSpanType.Minitues) * -1 * timeSpan).ToOADate();
double maxTimeSpan = DateTime.FromOADate(maximumSeriesValue).AddSeconds(GetDisplaySpanInSeconds(TimeSpanType.Minitues) * 1 * timeSpan).ToOADate();
tchart.Axes.Bottom.SetMinMax(minTimeSpan, maxTimeSpan);
hscrollBar.Minimum = tchart.Axes.Bottom.Minimum;
hscrollBar.Maximum = tchart.Axes.Bottom.Maximum;
value = tchart.Axes.Bottom.Minimum + ((tchart.Axes.Bottom.Maximum - tchart.Axes.Bottom.Minimum) / 2);
//hscrollBar.Value = value;
AxisMin = hscrollBar.Minimum;
AxisMax = hscrollBar.Maximum;
}
private void hscrollBar_Scroll(object sender, ScrollEventArgs e)
{
if (hscrollBar.Value < value)
tchart.Axes.Bottom.SetMinMax(AxisMin - (value - hscrollBar.Value), AxisMax - (value - hscrollBar.Value));
else
tchart.Axes.Bottom.SetMinMax(AxisMin + (hscrollBar.Value - value), AxisMax + (hscrollBar.Value - value));
tchart.Invalidate();
}
Please suggest me on this.