ChartDirector Support Forum Home   Search
Run time Chart Vertical axis
Posted by Abhi on Feb-22-2019 19:50
Hello,

I have a Scenario like  I need to show user to vertical axis  from 0 to 100 and also need to provide zoom and Pan function.

if i use below method i can see only value which is plotting between 0 to 100 range.

chartViewer.setFullRange("y",0,100);

Here my scenario is user has to see any value by zoom In/out function and also initially Y axis range should be 0 to 100.

And also we are providing Reset button to reset to earlier position(0 to 100 vertical Y axis)  after user did some zoom In/out or pan Function.

Hope You understand my scenarios.

Regards,
Abhishek MR

Re: Run time Chart Vertical axis
Posted by Peter Kwan on Feb-23-2019 19:17
Hi Abhi,

You can set a large full range (say 0 to 10000000), and set the initial viewport to display 0 to 100 only.

For example, consider the sample code "Zooming and Scrolling with Track Line (1)":

There are around 5 years of data, but the initial viewport is configured to display only the latest 20% of the data. For your case, you can use similar method to configure the viewport to initially display only a certain part of the data.

Hope this can help.

Regards
Peter Kwan

Re: Run time Chart Vertical axis
Posted by Abhi on Feb-25-2019 19:32
Hi peter,

For single Y axis its working fine but now for multiple Y axis its not working properly.Because for multiple Y axis i need to show initially different range for each y axis  like one Y axis range from 0 to 100 and next y axis range from 0 to 10.

let me know is there any alternate way to fix this issue.

Regards,
Abhishek MR

Re: Run time Chart Vertical axis
Posted by Peter Kwan on Feb-26-2019 02:56
Hi Abhi,

If you have multiple y-axis with different scales (eg. one at 0 to 100, and another one at 0 - 10), then when the user zooms out, does the axes zoom out at the same ratio? For example, if the first axis zooms out to 0 to 500, does it mean the second axis will also zoom out to 0 to 50?

If the all the axes zooms in and out at the same time, then you can just set different full ranges, like:

// The first axis is 10 times of that of the second axis
chartViewer.setFullRange("y",0,1000000);
chartViewer.setFullRange("y2",0,100000);

then in the axis scaling code:

viewer.syncLinearAxisWithViewPort("y", c.yAxis());
viewer.syncLinearAxisWithViewPort("y2", c.yAxis2());

Regards
Peter Kwan

Re: Run time Chart Vertical axis
Posted by Abhi on Feb-26-2019 23:31
Hi Peter,

If i use setfullrange for multiple y axis how can i show initially one y axis range from 0 to 100 and another one is 0 to 20.Because i cant able to set viewport height for multiple y axis .

Regards,
Abhi

Re: Run time Chart Vertical axis
Posted by Peter Kwan on Feb-27-2019 23:04
Hi Abhi.

If the two y-axis are zoom in and out at the same ratio, you can set their initial range to different values by setting their full range to different values. It is the same as the method I mentioned in my message.

As I am not sure which programming langauge you are using, or whether you are writing a web or desktop application, I will just use C#/Windows Forms as an example:

For example, in C#:

// During initialization
chartViewer.setFullRange("y",0,1000);
chartViewer.setFullRange("y2",0,200);

// Show 10% of the axis, which is 0 - 100 for y and 0 - 20 for y2
chartViewer.ViewPortLeft = 0.9;
chartViewer.ViewPortWidth = 0.1;

........

viewer.syncLinearAxisWithViewPort("y", c.yAxis());
viewer.syncLinearAxisWithViewPort("y2", c.yAxis2());

ChartDirector has built-in user interface for the user to change the viewport using mouse drag and mouse clicks. See the various "Zooming and Scrolling" sample code for details.

You can also create your own code to change the viewport by modifying the ViewPortLeft and ViewPortWidth, then call WinChartViewer.updateViewPort to trigger a ViewPortChanged event. For example, the following sample code uses a "Slider" to change the zoom ratio.