Skip to main content
June 29, 2010
Question

Flex 4 - Axis Title Bug

  • June 29, 2010
  • 1 reply
  • 1371 views

When the verticalAxisTilteAlignment is 'vertical', the title will 'move' down and left off of the chart each time new line series are created.  The problem code is in ChartLabel:

            var p:AxisRenderer = AxisRenderer(parent);
            if (p.getStyle('verticalAxisTitleAlignment') == 'vertical')
            {
                _label.rotation = 180;
                _label.y = _label.y + _label.height;
                _label.x = _label.x + _label.width;

            }

After the first time through, the x and y are added to continuously causing the title to 'move' off the chart.  My (admittedly hackish) work-around is a TitleRenderer that extends ChartLabel with an overridden 'updateDisplayList' like so:

getChildAt(0).x = 0;

getChildAt(0).y = 0;
super.updateDisplayList(unscaledWidth, unscaledHeight);

This topic has been closed for replies.

1 reply

Participant
August 3, 2012

I'm running into the same problem. Any chance you can show your code showing the TitleRenderer that extends ChartLabel, as well as how it's called? I've never done something like that before in Flex.

UPDATE:

I found a nice tutorial here:

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c39.html

The workaround, thanks to vsimons (really -- thank you!!!):

package path.to.this.file

{

          import flash.display.*;

          import flash.geom.Matrix;

          import mx.charts.*;

          import mx.charts.chartClasses.ChartLabel;

          public class MyTitleRenderer extends ChartLabel {

                    public functionMyTitleRenderer() {

  super();

                    }

                    override protected function updateDisplayList(w:Number, h:Number):void { 

                              getChildAt(0).x = 0;

                              getChildAt(0).y = 0;

                              super.updateDisplayList(unscaledWidth, unscaledHeight);

                    }

          }

}