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
I should add....
If I define my same components statically in mxml, the stacked chart renders fine. It only appears to be a problem if the series is built dynamically.
Here's what the series component equivalent looks like in mxml (where it stacks just fine):
<mx:series>
<mx:Array>
<mx:ColumnSet type="stacked">
<mx:series>
<mx:Array>
<mx:ColumnSeries .../>
<mx:ColumnSeries .../>
<mx:ColumnSeries .../>
</mx:Array>
</mx:series>
</mx:ColumnSet>
<mx:LineSeries ..../>
<mx:LineSeries..../>
<mx:PlotSeries.../>
</mx:Array>
</mx:series>
Thx,
JJ
Allears42 -
Unfortunately, I never did find a solution, and you're the only person that every responded to any of my posts about it.
We ended up holding off on making a planned change to use stacked bars in our application because of this issue.
I think it's a bug in ActionScript, but I haven't seen anyone else indicating they also saw it before now, so I was reluctant to open a ticket on it.
Please let me know if you find a solution, and I will do the same.
Thx,
JJ
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>
madStacked.series = newSeries;
Ah yes....It makes sense that that would be a good workaround to try since it works if everything is defined in MXML, but kudos to you for thinking of it. I tried a lot of other stuff, and that seems so obvious now that you mentioned it, but I never thought of trying it.
Thanks for sharing. I'll try implementing that too.
JJ
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.
I revisited this again, and can't seem to get it work any differently than before...still get overlaid results. I tried calling invalidateStacking(), and even added a call to 'stack()' after adding the series. I also went back to using a fully-dynamically defined coumnSet (as opposed to a statically-defined empty columnSet object tried after an earlier reply above). None of these variations seem to correct the problem on my end.
At this point, we are looking to move away from Flex for this application anyway, and are already in the process of implementing parts of the application using a different technology.
Thanks for the ideas though!
North America
Europe, Middle East and Africa
Asia Pacific