locked
charting: how can I make "No Data In Range" and "Waiting For Selections" controltemplates? RRS feed

  • Question

  • I have a wpf window which contains a couple of datepickers and some buttons and a chart.  The chart is populated and bound at runtime according to the clicks and selections from the buttons and datepickers.

    What I would like to do is override the default controltemplate for the chart that just shows me a gradient as the background and insert a textblock that says "Waiting on Selections" for when the chart is unbound and empty.  And I would like to have a controltemplate that says "No Data Available in selected range" when they pick dates that return no entries that I can convert to data points.

    Has anyone else done this? I have not yet found an example that shows me this specific functionality and I am sure that I have left out a few steps required when thinking this through in my head.

    I figure that I need some type of trigger on the chart to set the "No data available" template as the background whenever my item.count = 0 but I do not understand how I can link my collection item count to that template? Also I am not totally sure I understand how to override the default template if it is more complicated than a custom style which takes the original control template and adds just one textblock.

    Can anyone point me in the right direction so that I can implement this?

    Wednesday, June 2, 2010 9:05 PM

Answers

  • Hi  Vegeta4ss,

    I do not think create a control template for the chart is a good solution, since the template is too complex and the chart has many sub elements like Axes, Series, it is hard to design a template for all elements.  A simple solution is to create a cover control (like rectangle or other controls Popup, Grid with TextBlock) with the message and display this cover control over the chart. It is easy to bind value for these control. When the SelectedItem is empty, set the cover control visibility to Visible (and Opacity ... ) and show a message; if the data is available, show a different message. Otherwise, hide the cover control.

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Jie Bao Wednesday, June 9, 2010 1:40 AM
    Friday, June 4, 2010 6:52 AM

All replies

  • Hi  Vegeta4ss,

    I do not think create a control template for the chart is a good solution, since the template is too complex and the chart has many sub elements like Axes, Series, it is hard to design a template for all elements.  A simple solution is to create a cover control (like rectangle or other controls Popup, Grid with TextBlock) with the message and display this cover control over the chart. It is easy to bind value for these control. When the SelectedItem is empty, set the cover control visibility to Visible (and Opacity ... ) and show a message; if the data is available, show a different message. Otherwise, hide the cover control.

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Jie Bao Wednesday, June 9, 2010 1:40 AM
    Friday, June 4, 2010 6:52 AM
  • Bob,

    Thanks for the reply. This is an idea I had not considered. I can figure out something to bind on to determine when to show these overlays on my chart but I am not sure I totally understand how to do set the z-index so it will show over top of the chart. Is this something that stackpanel can do or is there some other wpf layout control I will use for this function? I am still very much a beginner at this stuff :).

    Friday, June 4, 2010 2:35 PM
  • Hi,

    You could take a look at Panel.ZIndex in WPF, it decides the Z-index of the controls in the WPF panel.


    Best day, Best life
    Friday, June 4, 2010 8:44 PM
  • Hi Vegeta4ss,

    Panel.ZIndex can help you to control the elements z-index in one panel. Elements with a higher Panel.ZIndex appear on top of those with a lower Panel.ZIndex. Of cause, you could also set the elements UIElement.Visibility property to show and hide a element.

    Hope this helps.

    Sincerely,

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, June 7, 2010 2:06 AM