Scroll bar in a chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Paola
Newbie
Newbie
Posts: 11
Joined: Thu Mar 19, 2015 12:00 am

Scroll bar in a chart

Post by Paola » Fri Feb 19, 2016 9:41 pm

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.
Attachments
2.png
2.png (9.92 KiB) Viewed 10706 times
1.png
1.png (23.71 KiB) Viewed 10707 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Scroll bar in a chart

Post by Christopher » Mon Feb 22, 2016 12:25 pm

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?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Paola
Newbie
Newbie
Posts: 11
Joined: Thu Mar 19, 2015 12:00 am

Re: Scroll bar in a chart

Post by Paola » Mon Feb 22, 2016 2:48 pm

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.
Attachments
Ejemplo (2).zip
Example
(203.2 KiB) Downloaded 849 times
3.png
3.png (33.67 KiB) Viewed 10692 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Scroll bar in a chart

Post by Christopher » Mon Feb 22, 2016 4:36 pm

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);
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Paola
Newbie
Newbie
Posts: 11
Joined: Thu Mar 19, 2015 12:00 am

Re: Scroll bar in a chart

Post by Paola » Mon Feb 22, 2016 7:41 pm

Thank you very much.. It was very useful.

Post Reply