|
How to make y-axis labels visible on zoom |
Posted by Dilip Agarwal on Feb-14-2014 16:43 |
|
Hi, I am using horizontal 3D bar graph with labels on y-axis and numerical values on x-axis.
In this graph when I zoom the graph then chart spread such that y-axis labels does not
show. Can you please help me show that labels show each time, either zoom or not.
Images are attached withoutzoom.jpeg and withzoom.jpeg
few important line of code regarding this are as below
Call c.yAxis().setLabelFormat("{value}")
Call c.yAxis().setLinearScale(0.0, c.yAxis().getMaxValue())
startLabelIndex = viewer.getValueAtViewPort("x", viewer.ViewPortLeft)
endLabelIndex = viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
viewer.ViewPortWidth)
Call c.xAxis().setLinearScale(startLabelIndex, endLabelIndex, cd.NoValue)
Dim myStep
myStep = (Int(endLabelIndex) - Int(startLabelIndex + 0.9999)) \\ 20 + 1
For i = Int(startLabelIndex + 0.9999) to endLabelIndex Step myStep
Call c.xAxis().addLabel(i, timeArray(i))
Next
Call viewer.syncLinearAxisWithViewPort("y", c.yAxis())
Call c.packPlotArea(10, title.getHeight() + 10, c.getWidth()-10, c.getHeight()-10)
|
Re: How to make y-axis labels visible on zoom |
Posted by Peter Kwan on Feb-15-2014 02:45 |
|
Hi Dilip,
I assume you are referring to the x-axis labels (because your chart is created with
swapXY, the x-axis is the vertical axis), as opposed to the y-axis labels.
For your case, it is perfectly possible for the zoomed-in chart to be no x-axis labels. In
the simplest case, if the user just zoomed around the gap between the bars, there will be
no labels.
There are many methods to solve this problem. One simple method is to disallow the user
from zooming to less than 1 bar slot using WebChartViewer.ZoomInHeightLimit.
There are also a few errors in the code. For example, the x-axis scale should be related
to ViewPortTop and ViewPortHeight (not ViewPortLeft and ViewPortWidth). Also, if you
have not reversed the x-axis, the bottom index should be the smaller index, no the top
index.
Assuming the x-axis is not reversed (Axis.setReverse is not called), I suggest to use
something like:
Call viewer.setFullRange("x", Ubound(timeArray) + 0.5, -0.5)
Call c.xAxis().setIndent(false)
viewer.ZoomInHeightLimit = 1.2 / Ubound(timeArray) 'show at least 1.2 bars
topLabelIndex = viewer.getValueAtViewPort("x", viewer.ViewPortTop)
bottomLabelIndex = viewer.getValueAtViewPort("x", viewer.ViewPortTop +
viewer.ViewPortHeight)
Call c.xAxis().setLinearScale(bottomLabelIndex, topLabelIndex, cd.NoValue)
myStep = (Int(topLabelIndex) - Int(bottomLabelIndex + 0.9999)) \\ 20 + 1
For i = Int(bottomLabelIndex + 0.9999) to topLabelIndex Step myStep
Call c.xAxis().addLabel(i, timeArray(i))
Next
Hope this can help.
Regards
Peter Kwan |
Re: How to make y-axis labels visible on zoom |
Posted by dilip on Mar-03-2014 15:13 |
|
Thanks Peter, It works fine. |
|