4 Replies Latest reply on Jun 12, 2009 12:16 PM by Francisc

    Name axis for charts

    Francisc Level 3

      For this code:

       

      var ls1:LineSeries=new LineSeries();

      ls1.xField="Xf"; ls1.yField="Yf";

      ls1.displayName="Test";

      ls1.setStyle('form',"curve"); ls1.setStyle('lineStroke',s1);//s1 is defined as a Stroke

       

      How can I name the X and Y axis? Add title to them.

      ls1.verticalAxis = "The Y axis"; returns a 'title is read-only' error.

       

      Thanks!

        • 1. Re: Name axis for charts
          Gregory Lafrance Level 6

          Use <mx:VerticalAxis> as in the following sample code:

           

           

          <?xml version="1.0"?>
          <!-- charts/BasicBar.mxml -->
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script><![CDATA[
               import mx.collections.ArrayCollection;
               [Bindable]
               public var expenses:ArrayCollection = new ArrayCollection([
                  {Month:"Jan", Profit:2000, Expenses:1500},
                  {Month:"Feb", Profit:1000, Expenses:200},
                  {Month:"Mar", Profit:1500, Expenses:500}
               ]);
            ]]></mx:Script>
            <mx:Panel title="Bar Chart">
               <mx:BarChart id="myChart" dataProvider="{expenses}" showDataTips="true">
                  <mx:verticalAxis>
                     <mx:CategoryAxis 
                          dataProvider="{expenses}" 
                          categoryField="Month"
                     />
                  </mx:verticalAxis>
                  <mx:series>
                     <mx:BarSeries 
                          yField="Month" 
                          xField="Profit" 
                          displayName="Profit"
                     />
                     <mx:BarSeries 
                          yField="Month" 
                          xField="Expenses" 
                          displayName="Expenses"
                     />
                  </mx:series>
               </mx:BarChart>
               <mx:Legend dataProvider="{myChart}"/>
            </mx:Panel>
          </mx:Application>
          


          If this post answers your question or helps, please mark it as such.

          • 2. Re: Name axis for charts
            Francisc Level 3

            Hey hey hey! I always mark answers...

             

            The example above doesn't help because as I've said I have to create it all in AS.

            How can I do this in AS please?

            • 3. Re: Name axis for charts
              Gregory Lafrance Level 6
              1 person found this helpful
              • 4. Re: Name axis for charts
                Francisc Level 3

                Thank you, Greg. I had read that livedoc before posting and looked at it once more.

                I can't see any indication as how to add axis title via action script.