4 Replies Latest reply on Mar 18, 2008 11:04 AM by ybjames

    Centering columns

      For some reason the columns in my column charts will not center. Changing offset has not effect, they are always placed so their right edge is just left of center. I can post code if it will help. Any ideas what might cause this?
        • 1. Re: Centering columns
          Sreenivas R Adobe Employee
          Posting code would help
          • 2. Re: Centering columns
            ybjames Level 1
            The following code demonstrates the problem:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" >
            import mx.collections.ArrayCollection;

            public var graphData:ArrayCollection = new ArrayCollection( [
            {date: "20080227", count: "23", close: 95.0}, {date: "20080228", count: "27", close: 101.0}, {date: "20080229",count: "16", close: 100.5}

            public function parseDate(s:String):Date {

            // Create the new Date object. Subtract one from
            // the month property because months are zero-based in
            // the Date constructor.
            var year:String = s.substr(0,4);
            var month:Number = Number(s.substr(4,2)) - 1 ;
            var day:String = s.substr(6,2);
            var newDate:Date = new Date(year, month, day);

            return newDate;


            <mx:Panel title="Chart" width="640" height="480">
            <mx:ColumnChart id="myChart" showDataTips="true" height="100%" width="100%" dataProvider="{graphData}">
            <mx:DateTimeAxis id="h1" dataUnits="days" labelUnits = "days" displayLocalTime="true" parseFunction="parseDate"/>

            <mx:LinearAxis id="v1" />


            <mx:ColumnSeries horizontalAxis="{h1}" dataProvider="{graphData}" displayName="neg" xField = "date" yField="count"/>

            xField = "date"


            With this code the columns are centered, but if I uncomment the LineSeries definition the columns are shifted to the left. I cannot force them back to center using offset.

            Thanks for the help.

            • 3. Re: Centering columns
              Deeptika Gottipati Adobe Employee
              ColumnChart usually expects all its series to be ColumnSeries. So, when there are two objects in its series array, it shifts the first series to the left, to accommodate the second one to its right. But as we are using LineSeries instead of ColumnSeries as second series, this shifting looks odd. Using CartesianChart instead of ColumnChart would help.
              • 4. Centering columns
                ybjames Level 1
                Do you have an example of using CartesianChart directly (with columns)? When I attempt to replace my ColumnChart declarations with CartesianChart it fails saying that it cannot convert a CartesianChart to a ColumnChart.


                Apparently CartesianChart doesn't like ColumnSet. Removing the ColumnSet I had around my ColumnSeries fixed the problem.