4 Replies Latest reply on Nov 20, 2007 9:37 AM by Malenitah2

    simple bar chart question

    lw1001
      I can't get the bar chart to produce any visible output (or fail trying).

      This is my chart mxml:
      <mx:BarChart x="0" y="327" id="barchart1" height="126" width="312" dataProvider="{progress}" >
      <mx:verticalAxis>
      <mx:CategoryAxis dataProvider="{progress}" categoryField="name"/>
      </mx:verticalAxis>
      <mx:series>
      <mx:BarSeries dataProvider="{progress}" displayName="Progress" xField="value" />
      </mx:series>
      </mx:BarChart>

      Progress is an arrayCollection containing two simple objects. Each object has a name field and a value field.
      The names of the actual data are "Work" and "Time" and the values 16 (Number type) and 10, respectively. All I want is this (excuse the ascii art):

      Work - XXXXXXXXXXXXXXXX
      Time - XXXXXXXXXXX

      What am I doing wrong?
        • 1. Re: simple bar chart question
          chris.huston.t10 Level 3
          Below is a sample app based on your specs that outputs a bar chart:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:Script>
          <![CDATA[
          import mx.collections.ArrayCollection;
          [Bindable]
          private var progress:ArrayCollection = new ArrayCollection([
          {name:'Time', value:12},
          {name:'Work',value:16}
          ]);

          ]]>
          </mx:Script>

          <mx:BarChart x="0" y="327" id="barchart1" height="126" width="312" dataProvider="{progress}" >
          <mx:verticalAxis>
          <mx:CategoryAxis dataProvider="{progress}" categoryField="name"/>
          </mx:verticalAxis>
          <mx:series>
          <mx:BarSeries dataProvider="{progress}" displayName="Progress" xField="value" />
          </mx:series>
          </mx:BarChart>
          </mx:Application>

          I would check your arrayCollection. You might be able to find the problem there.

          Vygo
          • 2. Re: simple bar chart question
            M._Tonelli
            Hi guys,

            I'm having problems to define the interval from a barchart, by default it's (0.2, 0.4, 0.6, 0.8, 1), and I just wanna see entire values, (0, 1, 2, 3...).

            I hope someone can help me...

            thx
            • 3. Re: simple bar chart question
              chris.huston.t10 Level 3
              You can set the maximum, minimum and interval values for your bar chart by using a horizontal axis tag:

              <mx:horizontalAxis>
              <mx:LinearAxis maximum="10" interval="1"/>
              </mx:horizontalAxis>

              Vygo
              • 4. Re: simple bar chart question
                Malenitah2
                Hi, I am migrating a prototype I have made in java to Flex. I am fascinated with flex but I have one problem. I am using horizontal barcharts, the Y axis represents categories and the X axis numeric values. My problem is that the name of the categories on the Y axis goes to small, even for a graph of 10 rows (or bars), do you have any suggestions of how I can increase the size of the font? Thanks,