Hi,
I am showing a stacked bar chart with Flex, and I am dynamically changing the data of the dataprovider.
However, the minimum and maximum for the y-axis do not get reset with the new data. So if one dataset had a value of -100,000, but the next dataset has only positive values, the y-axis still starts at -100,000.
How can I force the chart to redraw. I tried myChart.validateNow(), dataprovider.refresh(), etc.
<mx:ColumnChart id="myChart"
dataProvider="{_arrCol_chartData}"
columnWidthRatio="0.8"
type="stacked"
width="100%"
height="100%">
<mx:annotationElements>
<mx:CartesianDataCanvas id="canvas"
includeInRanges="true"/>
</mx:annotationElements>
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{_arrCol_chartData}"
categoryField="Month"
id="a1"/>
</mx:horizontalAxis>
<mx:verticalAxisRenderers>
<mx:AxisRenderer axis="{a1}"
tickPlacement="none"
showLabels="false"
showLine="false"/>
</mx:verticalAxisRenderers>
<mx:series>
<mx:ColumnSeries yField="invisible"
displayName="invisible"
showDataEffect="slideIn"
hideDataEffect="slideOut">
<mx:fill>
<!--Set alpha to 0 to hide invisible column.-->
<mx:SolidColor color="0xFFFFFF"
alpha="0"/>
</mx:fill>
</mx:ColumnSeries>
<mx:ColumnSeries yField="freeCashflow"
styleName="standardSeries"
labelFunction="setCurrencyLabel">
<mx:fill>
<mx:SolidColor color="0xCCCCCC"
alpha="1"/>
</mx:fill>
</mx:ColumnSeries>
<mx:ColumnSeries yField="invisibleTop"
displayName="invisible"
showDataEffect="slideIn"
hideDataEffect="slideOut">
<mx:fill>
<!--Set alpha to 0 to hide invisible column.-->
<mx:SolidColor color="0xFFFFFF"
alpha="0"/>
</mx:fill>
</mx:ColumnSeries>
<mx:ColumnSeries yField="bottom"
styleName="standardSeries"
labelFunction="setCurrencyLabel">
<mx:fill>
<mx:SolidColor color="0x1B95D5"
alpha="1"/>
</mx:fill>
</mx:ColumnSeries>
<mx:ColumnSeries yField="top"
id="topColumn"
styleName="standardSeries"
labelFunction="setCurrencyLabel">
<mx:fill>
<mx:SolidColor color="0x00FF00"
alpha="1"/>
</mx:fill>
</mx:ColumnSeries>
</mx:series>
</mx:ColumnChart>
[Bindable]
private var _arrCol_chartData : ArrayCollection = new ArrayCollection([
{ ID: FREE_CASHFLOW, Month: "Free Cashflow", freeCashflow: 0, invisible: 0, invisibleTop: 5000 },
{ ID: CAPITAL_RESERVES, Month: "Capital Reserves", bottom: 0, invisible: 0 },
{ ID: REINVESTMENT_MONEY, Month: "Reinvestment Money", bottom: 0, invisible: 0 },
{ ID: PROFIT_SHARING, Month: "Profit Sharing", bottom: 0, invisible: 0 },
{ ID: DISTRIBUTABLE, Month: "Distributable", top: 0, invisible: 0 }]);
function changeDate() : void {
_arrCol_chartData.getItemAt( 0 ).bottom = 1000;
_arrCol_chartData.refresh();
}
Thx, Martin