Search code examples
apache-flexactionscriptflex-charting

Position of axis labels on a Flex Chart, and how to position things relative to them


I am using an AxisRenderer that is positioned to the right of a BarChart and am looking for a way to position a title for the values in the AxisRenderer above them.

How do you find the position of the labels in an axis renderer? It seems like AxisRenderer.width returns the width of the chart and AxisRenderer.x returns the edge of the whole charts.

Here's an attempts at a picture:

                                Title
xxxxxxxxxxxxxxxxxxxxx   
xxxxxxxxxxxxxxxxxxxxx           axis value
xxxxxxxxxxxxxxxxxxxxx   

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  axis value
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  

xxxxxxxxx   
xxxxxxxxx                       axis value
xxxxxxxxx   

I'm trying to position the title above the "axis values" positioned by the AxisRenderer. Basically, for a non absolutely positioned axis, how do you determine where it is?


Solution

  • I've done a bit of digging into this problem and i've probably come to the same conclusion that you have - there's no easy way to do this. In my experience AxisRenderers are pretty bloody complicated under the hood (and not written in a particularly understandable way).

    However to achieve what you want to achieve you could create your own IAxisRenderer to construct exactly what you want (this is a nightmare... i've done it and it was painful). You could also attempt to extend AxisRenderer and try to override the particular method that positions it's in built titleRenderer (again this isn't particularly easy or clean as in my opinion AxisRenderer hasn't been built with extension in mind).

    Two easy solutions that will save you a massive amount of time. Hard code the position of the title in a place that looks ok. I would say in the majority of cases the axis labels won't change that often although obviously i'm making an assumption there. In my opinion the easiest solution... change the design. You're probably going to take quite a bit of time to get the title exactly as you want it. You need to ask yourself if the value you get from it is worth the effort you're putting in.

    Sorry I can't be any more help.

    J