Flex-reset chart-Achsen-minimum/maximum

Zeige ich ein gestapeltes Balkendiagramm mit Flex, und ich bin dynamisch ändern die Daten des Datenproviders.

Jedoch, das minimum und maximum für die y-Achse nicht wieder mit den neuen Daten. Also, wenn ein Datensatz hatte einen Wert von -100,000, aber der nächste Datensatz hat nur positive Werte, auf der y-Achse startet nach wie vor bei -100,000.

Wie kann ich erzwingen, das Diagramm neu zu zeichnen. Ich habe versucht, 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

  • Nach einigen code aus dem Diagramm, wo Sie die Initialisierung und festlegen von Eigenschaften auf die Achse, und einige code zu erklären, wie Sie ändern die Daten im Datenprovider enthalten sind.
InformationsquelleAutor martin | 2009-11-11
Schreibe einen Kommentar