views:

38

answers:

0

Hi guys,

I have created a flex chart with multiple Y axis. I want that it shows origin for one of the data series. It shows the line, but on the wrong plase.

Maybe it is because I didn't tell to GridLines which axis use as a source? But, I am not sure if it is possible to do...

Please help if you know how to show horizontal origin on a chart with multiple axis.

Here is an examle which reproduses my problem.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" 
           xmlns:local="*" 
           height="450" 
           width="500" xmlns:components="components.*" xmlns:charts="components.charts.*">
<s:layout>
    <s:BasicLayout/>
</s:layout>

<fx:Declarations>
    <mx:ArrayCollection id="arrColl">
        <mx:source>
            <fx:Array>
                <fx:Object name="R Winn"    slg="445" avg="0.300" />
                <fx:Object name="P Feliz"   slg="418" avg="-0.253" />
                <fx:Object name="O Vizquel" slg="316" avg="0.246" />
                <fx:Object name="B Molina"  slg="433" avg="-0.276" />
                <fx:Object name="R Durham"  slg="343" avg="0.218" />
            </fx:Array>
        </mx:source>
    </mx:ArrayCollection>       
</fx:Declarations>

<mx:ColumnChart 
             showDataTips="true"
             dataProvider="{arrColl}"
             width="100%"
             height="100%">

    <mx:backgroundElements>
        <mx:GridLines id="grid1"
                      gridDirection="both"
                      horizontalShowOrigin="true">
            <mx:horizontalOriginStroke>
                <s:SolidColorStroke color="red" weight="3" alpha="1" /> 
            </mx:horizontalOriginStroke>
        </mx:GridLines>
    </mx:backgroundElements>

    <mx:verticalAxisRenderers>
        <mx:AxisRenderer placement="left" axis="{axis1}" />
        <mx:AxisRenderer placement="right" axis="{axis2}" />
    </mx:verticalAxisRenderers>

    <mx:horizontalAxis>
        <mx:CategoryAxis categoryField="name"/>
    </mx:horizontalAxis>

    <mx:series>
        <mx:ColumnSeries yField="avg" xField="name">
            <mx:verticalAxis>
                <mx:LinearAxis id="axis1"/>
            </mx:verticalAxis>
        </mx:ColumnSeries>
        <mx:LineSeries yField="slg" xField="name">
            <mx:verticalAxis>
                <mx:LinearAxis id="axis2"/>
            </mx:verticalAxis>
        </mx:LineSeries>
    </mx:series>
</mx:ColumnChart>

</s:Application>