Skip navigation
depmar
Currently Being Moderated

Problem with axis labels and negative values

Apr 10, 2012 12:58 PM

Tags: #interval #minorinterval

I have problem with charts. I try to draw area charts for various values sets. I noticed that if  all values are negative, I have more data labels on vertical axis, than if all values are positive. Sometimes, when I have a large amount of data, labels for vertical axis are distorted, because they are to close each other. Interval and minorInterval parameter for negative values are smaller than for the same positive values.

 

I paste simple code:

 

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

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

 

<mx:Script>

    <![CDATA[

        import mx.charts.*;

        import mx.collections.*;       

 

        [Bindable]

        private var expenses:ArrayCollection;

               

        private var customNegativeNumbers:ArrayCollection = new ArrayCollection([

            {Month: "Jan", Profit: 2400, Expenses: -19.00000000000250007087980, Amount: 1450},

            {Month: "Feb", Profit: 1600, Expenses: -20.000000000001600098798, Amount: 1600},

            {Month: "Mar", Profit: 1900, Expenses: -21.0000000000020009987987, Amount: 2700},

            {Month: "Apr", Profit: 1700, Expenses: -19.00000000000250007087980, Amount: 1700},

            {Month: "Mai", Profit: 1600, Expenses: -20.0000000000020009987987, Amount: 2100}           

        ]);

       

        private var customPositiveNumbers:ArrayCollection = new ArrayCollection([

            {Month: "Jan", Profit: 2400, Expenses: 19.00000000000250007087980, Amount: 1450},

            {Month: "Feb", Profit: 1600, Expenses: 20.000000000001600098798, Amount: 1600},

            {Month: "Mar", Profit: 1900, Expenses: 21.0000000000020009987987, Amount: 2700},

            {Month: "Apr", Profit: 1700, Expenses: 19.00000000000250007087980, Amount: 1700},

            {Month: "Mai", Profit: 1600, Expenses: 20.0000000000020009987987, Amount: 2100}           

        ]);

       

        private function setData(dp:ArrayCollection):void

        {

            expenses = dp;           

        }

    ]]>

</mx:Script>

 

<mx:VBox height="100%" width="100%">

    <mx:HBox width="100%">

        <mx:Button click="setData(customNegativeNumbers)" label="show custom negative numbers"/>

        <mx:Button click="setData(customPositiveNumbers)" label="show custom positive numbers"/>

    </mx:HBox>

 

    <mx:AreaChart id="chart1" height="600" width="800" dataProvider="{expenses}" showDataTips="true">

        <mx:horizontalAxis>

            <mx:LinearAxis title="Profit" />

        </mx:horizontalAxis>

        <mx:verticalAxis>

            <mx:LinearAxis id="vaxis" baseAtZero="true" title="Expenses" />

        </mx:verticalAxis>

   

        <mx:series>

            <mx:Array>

                <mx:AreaSeries xField="Profit" yField="Expenses" name="Expenses/Profit" displayName="Profit2" />

            </mx:Array>

        </mx:series>

    </mx:AreaChart>

 

</mx:VBox>

</mx:Application>

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points