Page 1 of 1
Scroll bar in a chart
Posted: Fri Feb 19, 2016 9:41 pm
by 15673318
Hi.
I'm working with vb net.
I get a graph like the attached (1.png). I zoom until I can see the point I want (2.png), but after that it takes for ever to reach the last point on the right by dragging with right click. And It is not functional for my application. Is it possible to include scroll bars (vertical and horizontal) in a graph?
And I also lose the axis ticks, Is it possible to redraw them every time I zoom?
Thanks in advance for your help.
Re: Scroll bar in a chart
Posted: Mon Feb 22, 2016 12:25 pm
by Christopher
Hello Paola,
Paola wrote:I get a graph like the attached (1.png). I zoom until I can see the point I want (2.png), but after that it takes for ever to reach the last point on the right by dragging with right click. And It is not functional for my application. Is it possible to include scroll bars (vertical and horizontal) in a graph?
And I also lose the axis ticks, Is it possible to redraw them every time I zoom?
Would you please be so kind as to post a "
Short, Self Contained, Correct (Compilable), Example" with which I can reproduce your issue here?
Re: Scroll bar in a chart
Posted: Mon Feb 22, 2016 2:48 pm
by 15673318
Hi
I attached my example. (I had to omit the teechart.dll file because of the size...).
Some of the points of the graph are really close and they look overlaped, so I have to zoom-in them in order to check them correctly. But I need a scrollbar in order to check, quickly on the graph , other points in the limits (such as point d-28) ... besides I can not use right mouse bottom to drag and get that point, because I need right clic for a context menu strip
I want some scrollbars as drawn in 3.png. Is it possible?
Thanks in advance.
Re: Scroll bar in a chart
Posted: Mon Feb 22, 2016 4:36 pm
by Christopher
Paola,
Paola wrote:
I want some scrollbars as drawn in 3.png. Is it possible?
Yes, I think so. Please find following a code example in C# - apologies for not writing it in VB.NET, but I am not so proficient in that language. If you need help in porting from C# to VB.NET, please let me know.
Code: Select all
HScrollBar scrollBar;
private void InitializeChart()
{
scrollBar = new HScrollBar();
scrollBar.Dock = DockStyle.Bottom;
tChart1.Controls.Add(scrollBar);
scrollBar.Visible = false;
scrollBar.Scroll += ScrollBar_Scroll;
tChart1.Aspect.View3D = false;
tChart1.Series.Add(typeof(Line)).FillSampleValues(200);
tChart1.Zoom.Direction = ZoomDirections.Horizontal;
tChart1.Zoomed += TChart1_Zoomed;
tChart1.UndoneZoom += TChart1_UndoneZoom;
}
private void TChart1_UndoneZoom(object sender, EventArgs e)
{
scrollBar.Visible = false;
}
private void ScrollBar_Scroll(object sender, ScrollEventArgs e)
{
double maxDiff = tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum;
tChart1.Axes.Bottom.Minimum = e.NewValue;
tChart1.Axes.Bottom.Maximum = e.NewValue + maxDiff;
}
private void TChart1_Zoomed(object sender, EventArgs e)
{
double maxDiff = tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum;
scrollBar.Visible = true;
scrollBar.Minimum = Utils.Round(tChart1[0].XValues.Minimum);
scrollBar.Maximum = Utils.Round(tChart1[0].XValues.Maximum - maxDiff);
scrollBar.Value = Utils.Round(tChart1.Axes.Bottom.Minimum + (maxDiff / 2));
scrollBar.LargeChange = Utils.Round(tChart1.Axes.Bottom.Increment);
}
Re: Scroll bar in a chart
Posted: Mon Feb 22, 2016 7:41 pm
by 15673318
Thank you very much.. It was very useful.