Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
375
Remove/Hide Column Fragment by clicking on series in legend.
posted

So, I have a xamDataChart that displays a stacked column series, along with a legend showing each column fragment. I have tied into the LegendItemMouseLeftButtonUp event and set the correct column fragment series' Opacity to 0, in order to "hide" that series without removing it from the legend. Then if I click the legend again I set the Opacity back to 1 to "show" the series. The problem I am having is that after the series is "hidden" the remaining "shown" series have gaps between them and some even look like they are floating. How would I go about refreshing the chart so that the remaining "shown" series are neatly stacked one on top of the other? I attached an image of the floating bars.

Parents
  • 34510
    Offline posted

    Hello Joe,

    The only way to remove those gaps is to remove the StackedFragmentSeries from the collection.  The issue with doing this though, is that it also removes the item from the legend so you wouldn't be able to bring the series back by clicking on it.  To get around this you can create a dummy chart that sits behind your main one.  Inside this dummy chart you would have an exact copy of your StackedColumnSeries and your Legend would be tied to this.  In your main chart, you would remove the Legend.  This would allow you to detect which legend item was clicked on so you could add/remove the series accordingly without altering the legend.  I've attached a sample that demonstrates how you can do this.

    Let me know if you have any questions on it.

    SilverlightApplication1.zip
Reply Children