I have a simply dual axis chart similar to the samples found all over
the internet.  The chart has a line series on one Linear vertical axis
and a column series on another Linear vertical axis.  The problem is
that when certain events in the application happen, the min and max of
one of the axis is reset to 0, 100.  To avoid this I can set the min and
max values, but I would like to avoid this as the axis should auto scale
just like it does when it is first created.

Here is some sample code to show the problem.  The code is basically a
chart with a button.  When the button is clicked a new styleSheet is
loaded and it is then that the axis is set to 0, 100.

<code>

<?xml version="1.0" encoding="utf-8"?>

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009";

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

showStatusBar="false">



<fx:Script>

<![CDATA[

import mx.collections.ArrayCollection;

import mx.core.FlexGlobals;



[Bindable]

public var SMITH:ArrayCollection = new ArrayCollection([

{date:"22-Aug-05", close:41.87},

{date:"23-Aug-05", close:45.25},

{date:"24-Aug-05", close:42.77},

{date:"25-Aug-05", close:48.02},

]);



[Bindable]

public var DECKER:ArrayCollection = new ArrayCollection([

{date:"22-Aug-05", close:157.59},

{date:"23-Aug-05", close:160.3},

{date:"24-Aug-05", close:150.71},

{date:"25-Aug-05", close:156.88},

]);



private function onButtonClick():void

{

StyleManager.getStyleManager(FlexGlobals.topLevelApplication.moduleFacto\
ry).loadStyleDeclarations("style01.swf",true);

}



]]>

</fx:Script>



<s:VGroup width="100%" height="100%" horizontalAlign="center">



<s:Button label="Click" click="onButtonClick()" />



<mx:ColumnChart id="myChart" width="100%" height="100%"
showDataTips="true">

<mx:horizontalAxis>

<mx:CategoryAxis id="h1" categoryField="date"/>

</mx:horizontalAxis>



<mx:verticalAxis>

<mx:LinearAxis id="v1" />

</mx:verticalAxis>



<mx:verticalAxisRenderers>

<mx:AxisRenderer placement="left" axis="{v1}" />

<mx:AxisRenderer placement="right" axis="{v2}" />

</mx:verticalAxisRenderers>



<mx:series>

<mx:ColumnSeries id="cs1"

horizontalAxis="{h1}"

dataProvider="{SMITH}"

displayName="Smith"

yField="close">

<mx:verticalAxis>

<mx:LinearAxis id="v2" />

</mx:verticalAxis>

</mx:ColumnSeries>





<mx:LineSeries id="cs2"

horizontalAxis="{h1}"

verticalAxis="{v1}"

dataProvider="{DECKER}"

displayName="Decker"

yField="close" />



</mx:series>

</mx:ColumnChart>



<mx:Legend dataProvider="{myChart}" direction="horizontal"/>



</s:VGroup>



</s:WindowedApplication>

</code>



The style sheet which is loaded is basically a blank stylesheet which is
compiled to swf.



/* CSS file */

@namespace s "library://ns.adobe.com/flex/spark";

@namespace mx "library://ns.adobe.com/flex/mx";



global

{

font-family: "Verdana";

}

Reply via email to