|
line layer bug after calling packPlotArea |
Posted by at on Dec-20-2012 15:12 |
|
Hi Peter, I'm not sure if this is a bug on CD but I notice that after calling packPlotArea,
any chart having a line layer(including pareto), the line seems shifted but the dots,square,
etc (in the case of symbolline or pareto) is correct. The rest of my charts appear to be ok
after calling the method. I'm certain that I call packPlotArea after adding all the data and
layers, just before saving it to session. Any idea how to fix this? Thanks. |
Re: line layer bug after calling packPlotArea |
Posted by Peter Kwan on Dec-21-2012 00:47 |
|
Hi at,
I have just tested with the Pareto Chart sample code by removing the data symbols, so that the line no longer has any symbols. The line is accurate no matter packPlotArea is used or not.
I have also tried the Simple Line Chart sample code (which just contains a line with no data symbol). It works accurately with packPlotArea as well.
Note that if you use "packPlotArea", the plot area size may change. So it is normal everything may shift to fit the new plot area size. If you think the line is no longer accurate after packPlotArea, is it possible to provide an example (eg. by modifying the Simple Line Chart) to help me reproduce the problem.
Regards
Peter Kwan |
Re: line layer bug after calling packPlotArea |
Posted by at on Dec-21-2012 15:19 |
|
Hi Peter,
After investigating further, it appears that the shift of the line layer only occuring when
saved in session but not when using makeChart method. Attached is a pareto chart which
obviously showing the line shifted. Interesting is that it get corrected when I try to
perform a zoom or partial update the chart. I'm attaching also part of the code, hope you
can help me find out what wrong with it.
|
Re: line layer bug after calling packPlotArea |
Posted by Peter Kwan on Dec-22-2012 01:09 |
|
Hi at,
The issue is because your code calls "$c->layout();" before calling packPlotArea.
The purpose of BaseChart.layout is to configure the axis and layout the chart, so that you can obtain the axis scale, and determine the pixel coordinates of the data values by using XYChart.getXCoor or XYChart.getYCoor. If you change the axes afterwards (such as moving or resizing or rescaling the axes), the previously obtained pixel coordinates would not be useful. So BaseChart.layout is designed assuming you would not move or resize the axis afterwards.
The purpose of XYChart.packPlotArea is to move and resize the axes to make it fit within a certain bounding box. So this method should not be called after BaseChart.layout.
To solve the problem, please reverse the ordering of the method call. You may first layout the complete chart (including performing packPlotArea), before using BaseChart.layout and obtaining axis scale information,
Hope this can help.
Regards
Peter Kwan |
Re: line layer bug after calling packPlotArea |
Posted by at on Dec-22-2012 10:06 |
|
Hi Peter,
I remember removing the $c->layout() when I debugged this since I suspected that it is also the cause but it did not seem to work. Just wondering why only the line layer is affected by this. But just to make sure, I will do as you suggested when I get back to work probably next year.
Thanks again for the great support.
Merry Christmas and a Happy New Year! |
Re: line layer bug after calling packPlotArea |
Posted by Peter Kwan on Dec-24-2012 20:54 |
|
Hi at,
Some of the layers in ChartDirector compute their coordinates when it is actually being plotted, while some layers do this during layout. If a layer computes its coordinates during layout, but the axis scale or position changes afterwards, the coordinates will no longer be consistent with the axis scale.
The line layer is designed to compute its coordinates during layout because the line position may also be used by other layers (such as Inter-line layers). It is possible the line layer coordinates are required before the line is plotted. A convenient time to compute the coordinates is before any layer starts plotting, but after the axis scale has been fixed, and so the layout stage is chosen.
Regards
Peter Kwan |
|