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

Message ListMessage List     Post MessagePost Message

  Zoomable Chart with multiple Axes.
Posted by Timo Becker on Dec-10-2010 21:51
Hello together ;)

i'am trying to design a web application that serves a zoomable chart with multiple axes.
I create those axes inside a For Loop like:


"
for i = 0 to eg.count

    Dim Axes as Axis
    Dim layer as linelayer
    Axes = c.addAxis(...)
        layer = c.addlinelayer2()
    layer.addDataset(...)
...

Next
"

After the first run of the loop i call c.layout to be able to use Axes.getMaxValue or getMinValue(). This works!

After the 2nd run of the loop i call c.layout again. Now i can't use Axes.getMaxValue or getMinValue anymore. It always returns 0(min) 100(max) now.

So it seems like that after calling c.layout im no longer possible to get values of my dynamic created axis.

so...what am i doing wrong? :/ How can i get the min / max Values of dynamic created Axes?

Looking forward to hear from you guys ;)

greetz
Timo

  Re: Zoomable Chart with multiple Axes.
Posted by Dimitry on Sep-25-2011 09:10
Timo,
have you ever gotten an answer to your question on zoom with
dynamically created axis? I have the same problem.
Thanks,
Dimitry

Timo Becker wrote:

Hello together ;)

i'am trying to design a web application that serves a zoomable chart
with multiple axes.
I create those axes inside a For Loop like:


"
for i = 0 to eg.count

    Dim Axes as Axis
    Dim layer as linelayer
    Axes = c.addAxis(...)
        layer = c.addlinelayer2()
    layer.addDataset(...)
...

Next
"

After the first run of the loop i call c.layout to be able to use
Axes.getMaxValue or getMinValue(). This works!

After the 2nd run of the loop i call c.layout again. Now i can't use
Axes.getMaxValue or getMinValue anymore. It always returns
0(min) 100(max) now.

So it seems like that after calling c.layout im no longer possible to
get values of my dynamic created axis.

so...what am i doing wrong? :/ How can i get the min / max Values
of dynamic created Axes?

Looking forward to hear from you guys ;)

greetz
Timo

  Re: Zoomable Chart with multiple Axes.
Posted by Peter Kwan on Sep-26-2011 02:35
Hi Dimitry,

The function of XYChart.layoutAxes is to layout and auto-scale all axes. This method can only be called once. After that, the axis scales are fixed and cannot be changed.

In Timo's case, after layoutAxes is called in the first iteration, all axes that exist before the call are auto-scaled. However, if additional axes are added after that, these axes will not be auto-scaled (as layoutAxes can only be called once and all subsequent calls will have no effect), so they will maintain their default scale 0 - 100. In fact, one should not add axes after layoutAxes.

So the code I suggest is (in VB.NET):


Dim Axes As ArrayList = new ArrayList();

'Add all data
For i = 0 to eg.Count
    Axes.Add(c.addAxis(...))
    layer = c.addLineLayer2()
    layer.addDataset(...)
...
Next

'Auto-scale Axes
c.layoutAxes()

'Now you can get the min and max values
For i = 0 To Axes.Count - 1
    Axis a = DirectCast(Axes(i), Axis)
    Dim minV As Double = a.getMinValue()
    Dim maxV As Double = a.getMaxValue()
   ....
Next


Hope this can help.

Regards
Peter Kwan

  Re: Zoomable Chart with multiple Axes.
Posted by Dimitry on Sep-27-2011 12:26
Thank you, Peter. It works.

  Re: Zoomable Chart with multiple Axes.
Posted by Dimitry on Oct-19-2011 00:54
Attachments:
Peter,
I can't understand the problem. Please help.
There are 4 different groups of time series by placement on the chart.
Group #3 and #4 are to be plotted on y2 reversed, y reversed.
When the charts are plotted initially-the time series for group 3 (to be
plotted on the y2 axis reversed) are showing up as not reversed, but
after I zoom - redraw the chart it is plotted as intended.

Please see attachments. The code is not optimized yet:)

Thank you,
Dimitry
PlotChart.zip
PlotChart.zip

5.54 Kb
    
Clipboard01.jpg
Clipboard02.jpg

  Re: Zoomable Chart with multiple Axes.
Posted by Peter Kwan on Oct-19-2011 03:04
Hi Dimitry,

As your code is quite complicated and over 500 lines and its working depends on user inputs, it is hard for me to diagnose the code. Anyway, I am guessing, may be your code calls Axis.setReverse. Then later it also calls Axis.setLinearScale with a reversed scale (with lowerLimit > upperLimit), so the axis is double reversed, and therefore not reversed.

Specifically, I found that in your code there are two lines:

clChartSetup.AxisMin = a.getMinValue()
clChartSetup.AxisMax = a.getMaxValue()

Subsequently, it seems Axis.setLinearScale is called based on values derived from AxisMin and AxisMax. You may try to modified the code to:

clChartSetup.AxisMin = Math.Min(a.getMinValue(), a.getMaxValue())
clChartSetup.AxisMax = Math.Max(a.getMinValue(), a.getMaxValue())


Regards
Peter Kwan

  Re: Zoomable Chart with multiple Axes.
Posted by Dimitry on Oct-19-2011 11:54
Peter,
Sorry for the long code-just didn't know where to look.
Despite that, you were spot on. The axis was reversed back by
Axis.setLinearScale.

Thanks so much for the great support!!!

Dimitry