Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping panning of Scattergraph after reaching the end of plot area

I want to restrict panning of scattergraph after user scrolls to the end of the graph.  Currently even after reaching the end, user can still continue dragging the white area.

 

Full graph:

fullgraph.png

User scrolls to white area:

 

panned graph.png

0 Kudos
Message 1 of 6
(3,042 Views)

Hi arunkumar.s,

 

One way to go about this would be to disable panning altogether and instead add a horizontal scrollbar. This scrollbar could control the X Axis for the graph, and restrict the user to only scrolling through the "allowed" range for the graph.

NickelsAndDimes
Product Support Engineer - sbRIO
National Instruments
0 Kudos
Message 2 of 6
(3,009 Views)

Hi NickelsAndDimes,

 

I allow pan only if user zooms the graph.  So, panning is necessary here.  As you suggest, if I want to disable the panning and add scroll bar, I don't see an inbuilt scroll facility in scattergraph.  Do you have a sample code to achieve this?

0 Kudos
Message 3 of 6
(3,006 Views)

I don't have any sample code available, but there's a class called "HScrollBar" under "All Windows Forms" that's essentially just a numeric control. You could set this to have a minimum of 0, and a maximum of ([last x value]-[x width displayed]). Your chart can then read from this scrollbar to set its X scale from [HScrollBar.value] to [HScrollBar.value+x width].

NickelsAndDimes
Product Support Engineer - sbRIO
National Instruments
0 Kudos
Message 4 of 6
(2,996 Views)

In which event of graph should I set X scale from [HScrollBar.value] to [HScrollBar.value+x width]?  The graph does not have a onscroll event.

0 Kudos
Message 5 of 6
(2,973 Views)

You'll want to use the hScrollBar_Scroll or hScrollBar_ValueChanged event to detect when a change is made, and then edit the graph's X range from that method.

NickelsAndDimes
Product Support Engineer - sbRIO
National Instruments
0 Kudos
Message 6 of 6
(2,956 Views)