Skip navigation
Currently Being Moderated

Dynamic ColumnSet rendering as 'overlaid' instead of 'stacked'

Apr 18, 2011 1:14 PM

Hi all...

I'm struggling to get a stacked column set working within a cartesian chart. The chart object and horizontal axis are defined statically within mxml code, and the column set, column series, vertical axis, and other vertical axes, axis renderers, and line/plot series components are all defined dynamically in actionscript.  I've seen several examples online, and I appear to be doing everything the same way, yet when I specify my ColumnSet object's type attribute to 'stacked' it renders all the column series data as overlaid instead of stacked.  I can specify 'clusterd' dynamically (leaving everything else the same) and it will re-render correctly as clustered, but I've tried several different 'workarounds' to try and force stacked to occur without any luck.

 

Has anyone else seen this sort of prolbem before?  I'm using Flex 3.5 and run inside Flash Player 10.

 

I've been struggling to get this working for several days now, so any help would be appreciated.

 

Here's a snippet of the MXML definitions:

 

                    <mx:CartesianChart id="myColumnChart"
                                    doubleClickEnabled="true"
                                    width="100%"
                                    height="100%"
                                    paddingTop="2"
                                    paddingRight="2"
                                    styleName="ColumnChart"
                                       showDataTips="true"
                                       dataTipFunction="dTips">

 

                        <mx:seriesFilters>
                            <mx:Array/>
                        </mx:seriesFilters>

 

                        <mx:horizontalAxis>
                            <CommonCtrlElem:EspDateTimeAxis autoAdjust="true" baseAtZero="false"
                                              displayLocalTime="false" 
                                              displayName="{myTSField}"
                                              dataUnits="{myTSPrecision}"
                                              labelUnits="{myLabelPrecision}"
                                              maximum="{maxHorAxisVal}"
                                              minimum="{minHorAxisVal}" 
                                              />
                        </mx:horizontalAxis>
                        <mx:horizontalAxisRenderers>
                            <mx:AxisRenderer axis="{myColumnChart.horizontalAxis}"
                                             cachePolicy="off" canDropLabels="false" canStagger="false"/>
                        </mx:horizontalAxisRenderers>
   
                       <!-- The series data for this chart will be
                              determined by the updateChart() function
                        -->
                    </mx:CartesianChart>

 

 

The overall chart 'series' is built as an Array object, with the first element being a ColumnSet containing an array of ColumnSeries elements as the ColumnSet object's 'series' element value.  Then there are other Plot/Line series elements appended to the top chart's 'series' array before it gets tied to the chart object as its new 'series' component value.

 

There is alot of other stuff going on within the actionscript, which is why I have just summarized the order of it above rather than include it.  As I mentioned previously, it works fine if I specify the ColumnSet's type attribute to 'clustered', so I know all the data is there and getting set up properly...it's just showing up as 'overlaid' instead of 'stacked' if I specify 'stacked.'


Thanks in advance,

JJ

 
Replies
  • Currently Being Moderated
    Jul 20, 2011 12:18 PM   in reply to talijj

    I have the same problem.  Did you ever find a solution?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2011 12:43 PM   in reply to talijj

    I believe I have a workaround.  I created a single empty placeholder in the mxml like so:

     

    <mx:ColumnSet id="madStacked" type="stacked">     
         <mx:ColumnSeries />
    </mx:ColumnSet>
    
    Now when I replace the series in actionscript the stacked chart displays correctly:
    madStacked.series = newSeries;
     
    
    -ears

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 1, 2012 4:34 PM   in reply to talijj

    I have had this problem as well but I found that it was just due to the fact that there were no series inside the columnSet when the ColumnSet.stacked() function was being called and then it was never being called again. the stacked() called is only called after stackingIsDirty flag is set but adding new series to the set did not make the flag dirty. The only paths that seem to invalidate the stacking is when you change the stack type and when you change the allowNegativeForStacked parameter. If you create from MXML then the series are all created from static data when the set is created so this isnt a problem but if you create dynamically then I suspect your creating the set and then adding series to it. I got around this problem by ensuring that after I added the series to the set I called invalidateStacking(). This solved my problems completely. If I didnt do this then I just got an overlaid chart.

     

    I think this is really a bug as if you create dynamically then I think it is basically impossible to get it working without calling invalidateStacking() but Ive not seen this mentioned anywhere in the docs.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points