2 Replies Latest reply on Mar 18, 2009 3:14 PM by orrbernstein

    Axis titles don't display on cartesian chart

    orrbernstein
      I use Adobe Flex Builder 3 to create charts for use in a larger web application. Since moving from Flex Builder 2 to Flex Builder 3, the axis titles are no longer being displayed.

      In my mx:Application, I declare an mx:CartesianChart. I dynamically add ColumnSeries to a ColumnSet based on the contents of an XML file loaded using a URLRequest. I then add the ColumnSet as the only element of the chart.series Array. The rest of the chart (including the legend) displays correctly.

      The axes are explicitly defined as part of the mx:CartesianChart:
      <mx:CartesianChart left="{legend.width}" top="30" right="0" bottom="0" id="chart" dataProvider="{xmlDoc.elements()}" showDataTips="true" dataTipFunction="formatDataTips">
      <mx:verticalAxis>
      <mx:LinearAxis id="vAx" autoAdjust="true" title="Dollars" labelFunction="formatVerticalLabel"/>
      </mx:verticalAxis>
      <mx:horizontalAxis>
      <mx:CategoryAxis id="hAx" categoryField="Year" title="Year"/>
      </mx:horizontalAxis>
      <mx:horizontalAxisRenderers>
      <mx:AxisRenderer axis="{hAx}" labelRotation="-60"/>
      </mx:horizontalAxisRenderers>
      </mx:CartesianChart>

      Thanks in advance for your help.
        • 1. Re: Axis titles don't display on cartesian chart
          ofeet Level 1
          might be a problem in your custom labeling function? I made a test app to check this out. here's what I got. maybe it will help give insight.

          [code]
          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
          <mx:Script>
          <![CDATA[
          import mx.collections.ArrayCollection;
          private var _dp:ArrayCollection = new ArrayCollection([
          {date:new Date(), dollars:23.44},
          {date:new Date(), dollars:23.44},
          {date:new Date(), dollars:23.44},
          {date:new Date(), dollars:23.44},
          {date:new Date(), dollars:23.44}
          ]);
          public function formatDataTips(one, two, three):String {
          return 'datatip';
          }
          public function formatVerticalLabel(one, two, three):String {
          return 'label';
          }
          ]]>
          </mx:Script>
          <mx:CartesianChart top="30" right="0" bottom="0" id="chart" dataProvider="{_dp}" showDataTips="true" dataTipFunction="formatDataTips">
          <mx:verticalAxis>
          <mx:LinearAxis id="vAx" autoAdjust="true" title="Dollars" labelFunction="formatVerticalLabel"/>
          </mx:verticalAxis>
          <mx:horizontalAxis>
          <mx:CategoryAxis id="hAx" categoryField="Year" title="Year"/>
          </mx:horizontalAxis>
          <mx:horizontalAxisRenderers>
          <mx:AxisRenderer axis="{hAx}" labelRotation="-60"/>
          </mx:horizontalAxisRenderers>
          </mx:CartesianChart>
          </mx:Application>
          [/code]
          • 2. Re: Axis titles don't display on cartesian chart
            orrbernstein Level 1
            I've isolated the issue, but I'm not sure if it's a bug or if something I'm doing wrong. The following simplified version of my chart application doesn't display the axis titles:

            [code]
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
            <mx:Legend dataProvider="{chart}" left="0" top="25" id="legend"/>
            <mx:CartesianChart left="{legend.width}" top="30" right="0" bottom="0" id="chart">
            <mx:verticalAxis>
            <mx:LinearAxis title="Dollars"/>
            </mx:verticalAxis>
            <mx:horizontalAxis>
            <mx:CategoryAxis title="Year"/>
            </mx:horizontalAxis>
            </mx:CartesianChart>
            </mx:Application>
            [/code]

            The following version does:
            [code]
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
            <mx:Legend dataProvider="{chart}" left="0" top="25" id="legend"/>
            <mx:CartesianChart left="{0}" top="30" right="0" bottom="0" id="chart">
            <mx:verticalAxis>
            <mx:LinearAxis title="Dollars"/>
            </mx:verticalAxis>
            <mx:horizontalAxis>
            <mx:CategoryAxis title="Year"/>
            </mx:horizontalAxis>
            </mx:CartesianChart>
            </mx:Application>
            [/code]

            The only difference is the left definition for mx:CartesianChart. When it's defined in terms of the width of the legend, the axis titles disappear. Is there another way that I should be displaying my chart using the full span of the application?

            Thanks again for your help.