kokot-san
03-11-2009, 03:36 AM
Hi,
I have to draw a horizontal line for a stacked bar in a BarChart. I have seen that I can use CartesianDataCanvas, but this seems to be limited. If I draw lines from one point to another point, it is always in the middle of one bar to the middle of another bar (like in the example below). But, I need to draw from the left side of a specific bar to the right side of the same bar. How can I modify the example to make this possible?
Thank you!
Andrej
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{Month:"Jan", Profit:2000, Expenses:1500, Max:450},
{Month:"Feb", Profit:1000, Expenses:200, Max:600},
{Month:"Mar", Profit:1500, Expenses:500, Max:300},
])
private function onComplete() : void
{
canvas.clear();
canvas.lineStyle(1, 0x000000, .75, true,
LineScaleMode.NORMAL, CapsStyle.NONE,
JointStyle.MITER, 2);
canvas.moveTo("Jan", 450);
canvas.lineTo("Feb", 600);
}
]]>
</mx:Script>
<mx:Panel >
<mx:CartesianChart dataProvider="{expenses}" creationComplete="onComplete()" >
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{expenses}" categoryField="Month"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries yField="Profit" displayName="Profit"/>
<mx:ColumnSeries yField="Expenses" displayName="Expenses"/>
</mx:series>
<mx:annotationElements>
<mx:CartesianDataCanvas id="canvas" />
</mx:annotationElements>
</mx:CartesianChart>
</mx:Panel>
</mx:Application>
I have to draw a horizontal line for a stacked bar in a BarChart. I have seen that I can use CartesianDataCanvas, but this seems to be limited. If I draw lines from one point to another point, it is always in the middle of one bar to the middle of another bar (like in the example below). But, I need to draw from the left side of a specific bar to the right side of the same bar. How can I modify the example to make this possible?
Thank you!
Andrej
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{Month:"Jan", Profit:2000, Expenses:1500, Max:450},
{Month:"Feb", Profit:1000, Expenses:200, Max:600},
{Month:"Mar", Profit:1500, Expenses:500, Max:300},
])
private function onComplete() : void
{
canvas.clear();
canvas.lineStyle(1, 0x000000, .75, true,
LineScaleMode.NORMAL, CapsStyle.NONE,
JointStyle.MITER, 2);
canvas.moveTo("Jan", 450);
canvas.lineTo("Feb", 600);
}
]]>
</mx:Script>
<mx:Panel >
<mx:CartesianChart dataProvider="{expenses}" creationComplete="onComplete()" >
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{expenses}" categoryField="Month"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries yField="Profit" displayName="Profit"/>
<mx:ColumnSeries yField="Expenses" displayName="Expenses"/>
</mx:series>
<mx:annotationElements>
<mx:CartesianDataCanvas id="canvas" />
</mx:annotationElements>
</mx:CartesianChart>
</mx:Panel>
</mx:Application>