10 Replies Latest reply on Mar 22, 2012 1:36 AM by NewFLexCoder_Me_Me

    Trouble with ColumnChart

    nschlatter
      I am trying to get a ColumnChart to display with negative value. Here is the 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.collections.ArrayCollection;
      import mx.charts.LinearAxis;
      import mx.controls.Alert;

      [Bindable]
      public var expenses_1 : ArrayCollection = new ArrayCollection( [{Month : "Jan", Profit : -1500, Expenses : -1500}] );

      [Bindable]
      public var expenses_2 : ArrayCollection = new ArrayCollection( [{Month : "Jan", Profit : 0, Expenses : 0}, {Month : "Feb", Profit : -6.658, Expenses : -6.658}] );

      ]]>
      </mx:Script>
      <mx:Panel title="Column Chart" x="395" y="95">
      <mx:ColumnChart id="myChart" dataProvider="{expenses_1}" showDataTips="true">
      <mx:horizontalAxis>
      <mx:CategoryAxis id="ca" dataProvider="{expenses_1}" categoryField="Month"/>
      </mx:horizontalAxis>
      <mx:series>
      <mx:Array>
      <mx:ColumnSeries id="columnSeries1" yField="Profit" displayName="Profit" />
      <mx:ColumnSeries id="columnSeries2" yField="Expenses" displayName="Expenses" />
      </mx:Array>
      </mx:series>
      </mx:ColumnChart>
      <mx:Legend dataProvider="{myChart}"/>
      </mx:Panel>


      </mx:Application>

      The chart renders, but it is showing just a blank chart where I should be seeing a bar in the negative. Is anyone else experiencing this? Can anyone please shed some light on this. I am working on a bug for my company's website and need to figure this out ASAP.

      Regards,
      Neal
        • 1. Re: Trouble with ColumnChart
          ANewFlexUser Level 1
          In poking around the Flex 3 livedoc, it appears that you can allow for negative rendering by wrapping your Series in a ColumnSet class, like in the attached example. I'm not positive, since I don't have a working example to base this off of, but it's worth a try. The 'Overlaid' type is described as having no special behavior applied, so that should function properly. I can't testify about 'allowNegativeForStacked' since the documentation is erroneously copy-pasted from the 'type' description, but given a cursory glance, I would think it's worth a shot.

          Example:
          • 2. Re: Trouble with ColumnChart
            nschlatter Level 1
            I tried wrapping my series in a ColumnSet, but Flex threw an error. I tried to put the columnSet inside of the series and this compiled, but to no avail. i think that, by default, ColumnChart uses "overlaid" for its ColumnSets. allowNegativeForStacked would probably only be applicable to type "stacked". How come Flex is throwing up when both data series values are negative and equal?
            • 3. Re: Trouble with ColumnChart
              Level 7

              "nschlatter" <webforumsuser@macromedia.com> wrote in message
              news:gbdf6d$jeb$1@forums.macromedia.com...
              >I am trying to get a ColumnChart to display with negative value. Here is
              >the
              > code:

              There's an example here that I believe shows a column chart with negative
              data:
              http://www.rphelan.com/2008/05/23/taking-control-of-flex-charting-styles/


              • 4. Re: Trouble with ColumnChart
                nschlatter Level 1
                It's not that the colum chart can't render negative data, it is only when the first column set has series data that is equal and negative (Month: "Jan", Profit: -1500, Expenses: -1500). Can you run the example and see if the chart renders for you? I guess my main question is whether or not this is an issue. If other people can run the example and see the data, then there must be something I am doing wrong. ATM, I only see a blank chart when there should be data [pulling out hair]. All other variations will render (i.e. Month: "Jan", Profit: +1500, Expenses: +1500; Month: "Jan", Profit: +1500, Expenses: -1500; Month: "Jan", Profit: -1500, Expenses: -1501, etc...)
                • 5. Re: Trouble with ColumnChart
                  ANewFlexUser Level 1
                  I ran the example you posted, and I see two bars, both of which stretch from '0' at the top to '-1500' at the bottom of the screen. I wish I had a more helpful response, but I have no idea where the issue is, sorry. =\
                  • 6. Re: Trouble with ColumnChart
                    Level 7

                    "nschlatter" <webforumsuser@macromedia.com> wrote in message
                    news:gbdlsj$rkd$1@forums.macromedia.com...
                    > It's not that the colum chart can't render negative data, it is only when
                    > the
                    > first column set has series data that is equal and negative (Month: "Jan",
                    > Profit: -1500, Expenses: -1500). Can you run the example and see if the
                    > chart
                    > renders for you? I guess my main question is whether or not this is an
                    > issue.
                    > If other people can run the example and see the data, then there must be
                    > something I am doing wrong. ATM, I only see a blank chart when there
                    > should be
                    > data [pulling out hair]. All other variations will render (i.e. Month:
                    > "Jan",
                    > Profit: +1500, Expenses: +1500; Month: "Jan", Profit: +1500,
                    > Expenses: -1500;
                    > Month: "Jan", Profit: -1500, Expenses: -1501, etc...)

                    Why don't you post it somewhere and see what happens when people run it?


                    • 7. Re: Trouble with ColumnChart
                      nschlatter Level 1
                      ANewFlexUser - Do you know what version of Flex Builder you are using? I am using Flex Builder 2. I wonder if the problem was fixed in Version 3. Thanks.
                      • 8. Re: Trouble with ColumnChart
                        Level 7

                        "nschlatter" <webforumsuser@macromedia.com> wrote in message
                        news:gbdmqm$soe$1@forums.macromedia.com...
                        > ANewFlexUser - Do you know what version of Flex Builder you are using? I
                        > am using Flex Builder 2. I wonder if the problem was fixed in Version 3.
                        > Thanks.

                        There was also a recent upgrade to Flex 3 that fixed some issues in
                        DataVisualization.

                        HTH;

                        Amy


                        • 9. Re: Trouble with ColumnChart
                          ANewFlexUser Level 1
                          I am using Flex Builder 3, build 3.0.194161
                          • 10. Re: Trouble with ColumnChart
                            NewFLexCoder_Me_Me

                            Now, I have the same problem. Could you tell me how can I fix it? Thanks so much!