ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  ViewPortControl
Posted by N_M on Apr-27-2018 14:37
Hi,

I have plotted graph with viewportcontrol and graph is showing data of 15 days. Initially when i plot graph, viewport is showing in left position or right position but i want viewport in middle position.

For Example-
Graph is plotted for 15 days(From 01 April 2018 to 15 April 2018) then initially viewport control should be show in middle position(05 April 2018-08 April 2018).
How can i show viewport control in middle position initially.


Thanks & Regards
N_M

  Re: ViewPortControl
Posted by Peter Kwan on Apr-27-2018 17:21
Hi N_M,

You can always set the viewport left and width to any position you like. The exact code depends on your programming language and whether you are writing a web or desktop application.

For example, in the C# Windows Forms version of the "Zooming and Scrolling with Viewport Control (Windows)", you can find the lines:

// Set the full x range to be the duration of the data
viewer.setFullRange("x", timeStamps[0], timeStamps[timeStamps.Length - 1]);

// Initialize the view port to show the latest 20% of the time range
viewer.ViewPortWidth = 0.2;
viewer.ViewPortLeft = 1 - viewer.ViewPortWidth;

As you can see from the comments above, it is setting the viewport to the latest 20%, which is the right side. If your data range contains 15 days, and you want to view from the 5th day to the 8th day, then the viewport left and width must be:

viewer.ViewPortWidth = 4.0 / 16;  //duration = 4 days
viewer.ViewPortLeft = 4.0 / 16;     //start from the 5th day

(I am not sure exactly sure what you mean by 01 April 2018 to 15 April 2018. I assume you mean 01 Apr 1018 00:00:00 to 15 Apr 2018 23:59.59.9999. So in total there will be 16 days.)

Regards
Peter Kwan