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

Message ListMessage List     Post MessagePost Message

  SetLinearScale and syncLinearAxisWithViewPort ticks problem
Posted by Cody on Feb-06-2016 00:51
I've got a bar graph set up that I'm trying to make display a tick every 24 units, and when
I don't sync the axis to the viewport this works fine. It goes up "0, 24, 48, 72..." just fine.

However, when I try to sync the axis to the viewport so I can have zoom and drag
functionalities, new ticks appear ever 20 units on top of the ones that appear every 24
units.

I am trying to figure out how I can use the viewport but still have the x-axis display the
scale set to increments of 24 and not the increments of 20.

Any help is appreciated!

  Re: SetLinearScale and syncLinearAxisWithViewPort ticks problem
Posted by Cody on Feb-09-2016 22:10
Attachments:
Hello,

I should also clarify that I have seen the previous thread with a similar problem, and I use
the method suggested to only have setLinerScale used once, but I still get a combination of
ticks from both methods.

Thanks Again,
Cody
Compared.jpg

  Re: SetLinearScale and syncLinearAxisWithViewPort ticks problem
Posted by Peter Kwan on Feb-10-2016 05:35
Hi Cody,

Sorry for the late reply.

If you use setLinearScale to set the labels, you cannot also use
"syncLinearAxisWithViewPort". It is because "syncDateAxisWithViewPort" will also set
the labels.

When "syncDateAxisWithViewPort" is used, the axis scale depends on the zooming and
scrolling of the user, and can be anything. For example, the axis scale can be 0 to 408,
or it can be 1 to 11 (the user potentially zoom to this level). If you force the labels to be
at 0, 12, 24, ... and so on, there will be no labels if the axis scale is 1 to 11. To ensure
there is some axis labels, the "syncDateAxisWithViewPort" will automatically compute
the labels based on the visible axis scale.

For your case, if you would like to use your own labels, the code is like (in C#):

//The specified labels
c.xAxis().setLinearScale(0, 408, 12);

viewer.setFullRange("x", 0, 408);
double xStart = viewer.getValueAtViewPort("x", viewer.ViewPortLeft);
double xEnd = viewer.getValueAtViewPort("x", viewer.ViewPortLeft +
viewer.ViewPortWidth);

//Set the x-axis scale to the zoomed position, but do not add any label
c.xAxis().setLinearScale(xStart, xEnd, Chart.NoValue);

Hope this can help.

Regards
Peter Kwan

  Re: SetLinearScale and syncLinearAxisWithViewPort ticks problem
Posted by Cody on Feb-10-2016 06:33
Peter,

That was exactly what I was looking for. It never even occurred to me to manually set the
viewport's left and width values. Completely solved the issue.

Appreciated,
Cody