You mean it's in front of the gridlines?
The gridlines that appear in charts by default is really just another
backgroundElement. by default, each chart creates a single instance of the
mx.charts.GridLines class, and inserts it into the backgroundElements array. If
you set your own background elements, you end up overriding the default. But if
you still want Gridlines, you can explicitly create your own gridlines instance
in the backgroundElements:
<ColumnChart>
<backgroundElements>
<MyCustomBackgroundElement />
<Gridlines ... />
</backgroundElements>
...
You can put it in front or behind your other background elements by changing
the order in the array (i.e., in the MXML).
Ely.
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Sönke
Rohde
Sent: Tuesday, November 28, 2006 12:09 AM
To: [email protected]
Subject: RE: [flexcoders] Flex 2 Charting dynamic backgroundElements
Hi Ely,
thank you for your detailed answer and the code examples.
This was not exactly what I am looking for but gave me the hints to solve my
problem.
The key is that your backgroundElement extends ChartingElement.
But now I have got the problem that the backgroundElement is in front of the
PlotChart lines.
How can I swap them?
Again thanks a lot,
Sönke
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
Ely Greenfield
Sent: Monday, November 20, 2006 7:15 PM
To: [email protected]
Subject: RE: [flexcoders] Flex 2 Charting dynamic backgroundElements
Hi Sonke (sorry, can't figure out how to type an umlaud (sp?) on an
American keyboard ):
It sounds like your problem is a prime candidate for a custom
background element. If your shapes depend on the min max of the axes, that
probably means you want to annotate/illustrate a particular data value/range,
yes? Any time you're trying to draw data values, you should really be creating
a chart element (that's pretty much what they're there for). That means a
series, a backgroundElement, or an annotationElement.
I've attached a simple example of a custom background element that
takes a series of data values and draws matching bands in the background. It
should give you a starting point for what you're trying to do.
Ely.
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
Sönke Rohde
Sent: Sunday, November 19, 2006 6:43 AM
To: [email protected]
Subject: [flexcoders] Flex 2 Charting dynamic backgroundElements
Hi,
I have to draw shapes and lines into the background of a Plotchart.
The size/position of the shapes and lines depends on the minimum and
maximum
of the horizontal and vertical linear axis.
My first try was to use the backgroundElements to solve this problem.
I created a shape, drawed a polygon on it and added it to the
backgroundElements:
var shape:Shape = new Shape();
var gr:Graphics = shape.graphics;
gr.moveTo(0, 20);
gr.beginFill(0xFF9900, 50);
gr.lineTo(0, 0);
gr.lineTo(100, 0);
gr.lineTo(100, 100);
gr.lineTo(0, 20);
gr.endFill();
backgroundElements.reverse();
backgroundElements.push( shape );
I reversed the array to keep the GridLines in the front.
The polygon is visible in the background but it is scaled to fit the
size of
the PlotChart.
The shape has to keep its scaling.
How do I know the width/height of the PlotChart content area?
With this information and the min/max of the x/y axis I am able to do
the
drawing.
Any hint is very appreciated.
Cheers,
Sönke