The one with all the goofy heading names [Detailed information about the Silverlight Toolkit’s new stacked series support]


This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of dlaa.me.

See you there!

Comments (16)
  1. topas says:

    nice

  2. codekiwi says:

    Hi, I am LOVING the stacked series additions, they have replaced my own (average) implementation in my project. I am however having a problem when exporting the chart to an XPS report.

    I am aware of the issue regarding the "fade in" affect causing the series in the print out (or XPS) to be invisible.

    I have overcome this by setting the initial opacity to 1 in all control templates, this works for my line, column and Pie series. however the stacked column series still do not appear.

    I also cannot seem to extract the control templates using blend like I can with the other series?

    I suspect it may be because of the new way in which the stacked series were implemented. I cannot for the life of me figure out how to fix it.

    Any tips you could provide would preserve my sanity,

    Thanks.

  3. David Anson says:

    codekiwi,

    Thanks for the kind words – I’m glad to hear you like the new stacking support!

    Regarding the fade problems, I think you’re referring to our discussion on a different post and it sounds like you resolved them:

    http://blogs.msdn.com/delay/archive/2010/02/18/no-trees-were-harmed-in-the-making-of-this-blog-post-how-to-successfully-print-a-chart-with-the-silverlight-4-beta.aspx#10011342

    Regarding the opacity for StackedColumnSeries, have you set the opacity of the ColumnDataPoints via the DataPointStyle property? That’s what ought to do the trick. Though because there’s a ListBox that’s doing the actual rendering, it’ll be necessary to ensure that it has generated its containers (the ColumnDataPoint instances) as well. You may be able to use its ItemContainerGenerator to help ensure this?

    For control templates, I’m not sure why Blend would have troubles here – but I can tell you the default Template for the stacked series inherits from DefinitionSeries – so the default Template in DefinitionSeries.xaml (in the source code ZIP) is what you want to start from. This is all standard DefaultStyleKey stuff, so I’d expect the design tools to handle it correctly.

    Hope this helps – let me know if you’ve got other questions! 🙂

  4. codekiwi says:

    Hi Delay,

    Fantastic, it is great to wake up to some fresh ideas on how to address my problem, thank you for your help.

    I have set the opacity in the ControlTemplate of the DataPointStyle and have extracted the StackedColumnSeries control template, but I am unclear as to what you mean by "ensure it has generated its containers", and when you say use it’s ItemContainerGenerator do you mean a method in codebehind.

    Thank you for your help.

  5. David Anson says:

    codekiwi,

    I’m referring to the ItemsControl.ItemContainerGenerator property:

    http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemcontainergenerator(VS.96).aspx

    If you’re not familiar with the concept, here’s a good write-up by Dr. WPF (it’s for WPF, but most of the concepts are the same for Silverlight):

    http://drwpf.com/blog/2008/07/20/itemscontrol-g-is-for-generator/

    In particular, the section "Dealing with Asynchronous Container Generation" discusses the topic I was referring to.

  6. codekiwi says:

    Haha that is so funny, I was reading that exact article (well it’s predecessor ‘I is for Itemcontrol’) as you posted that.

    Thanks for your help, I will see how I go.

  7. kmkuntz says:

    Hi Delay –

    Quick question regarding the stacked series.  i was wondering if it is possible to group the stacks.  so, to use the above example, there would be an Alice column for 2009 and an Alice column for 2010, and so on with Bob and Eve.  

    Thanks

    Kevin

  8. David Anson says:

    Kevin,

    In the current bits, the stacked series will not group, sorry about that. If it's really important to you and you don't mind writing some code, some grouping logic is already present in the non-stacked series. It doesn't seem like it should be too, too difficult to pull that out and apply it here. Alternatively, you might consider a custom CategoryAxis implementation that works with a single StackedSeries and creates the grouping by laying similar things out close to each other. As I think about it more, this may actually be better because it'll give you more sensible category labels, too – and it shouldn't require modifying the series at all.

    Hope this helps!

  9. kmkuntz says:

    Thanks for the advice – I'll give it a try and let you know if i land anything worth sharing.

    Kevin

  10. Andreas says:

    Hi David,

    Very informative – as always. I am currently binding a dynamic amount of series to a chart as described by Beat Kiener in his Blog blog.thekieners.com/…/databinding-multi-series-charts.

    Now I want to include support for Stacked Bars as well and therefore would like to ask if there is a way to bind a list of SeriesDefinitions to e.g. a StackedBar. I tried it using the SetriesDefinitions attribute of the StackedBarSeries but always end up with an error (either XAML parsing or Child is already Element of another…). Can you comment on that? Thanks!

    Regards,

    Andreas

  11. David Anson says:

    Andreas,

    The DefinitionSeries.SeriesDefinitions collection-typed property is deliberately *not* a DependencyProperty (for the same reason that Chart.Axes isn't; you can read more about why here: cesso.org/…/DTDPDEFSHARE). Because Binding only works with DependencyProperties, I suspect this is the reason for the trouble you've had so far.

    That said, the Chart.Series property is the same kind of thing, so I'd expect that if you take the same approach Beat writes about in the link you reference (subclassing and adding a DependencyProperty for Binding), it would work for *this* scenario as well (except in this case you'll subclass StackedBarSeries instead of Chart).

    If you try this, I'd love to hear how it works out!

    (But if not, then you should always be able to create the SeriesDefinitions in code – you just won't be able to leverage Binding the same way.)

  12. Andreas says:

    Hi David, thanks for the tipp and the additional explanations. As you suggested, I derived from StackedBarSeries. It works perfectly fine and finally gives me the flexibility to mix stacked series with other series now dynamically. Regards, Andreas

  13. Timmy says:

    Hi Delay,

    it is possible that StackedSeries removed from WPF Toolkit, because I get the error that StackedBarSeries not exists in 'clr-namespace …DataVisualization.Toolkit'.

    I used v3.5.40128.1.

  14. David Anson says:

    Timmy,

    The WPF Toolkit hasn't released a new version since the April 2010 Silverlight Toolkit was released with stacked series support, so what's in the current download is not the latest stuff. However, you can get the latest version of the Data Visualization assembly (binaries and code) for all supported platforms as part of my Development Release: blogs.msdn.com/…/phone-y-charts-silverlight-wpf-data-visualization-development-release-4-and-windows-phone-7-charting-sample.aspx

    Hope this helps!

  15. Joel Barsotti says:

    One thing I was using in the old column/bar stack was that it would squish multiple columns into the same category.

    Now it seems to try and do a stack column/bar but with data from several data series, so instead it overlaps based on the series index.

  16. David Anson says:

    Joel Barsotti,

    The "staggering" behavior you mention didn't seem to make the same sense for stacked series, so they use the same "stacking" behavior as is used for different SeriesDefinitions. As far as I know, this works properly, but it sounds like maybe you think there's a bug as well?

Comments are closed.