RadCartesianChart : Any property to say that there is Data on chart.

8 posts, 1 answers
  1. sri
    sri avatar
    22 posts
    Member since:
    Oct 2012

    Posted 07 Dec 2015 Link to this post

    Hi There,

     Is there any way where we can find if chart is some data or not. I know it will display "No Data" template when there is no data I want know a property which triggers it. Why I need so because we have chart and some other UI  element like grid... which should syn other UI element when there is some data on chart.

    Basically I am looking  for some property like "IsChartHasSomeData"  . Please help me to know this  I mean how can we do this.?

     

     

  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 08 Dec 2015 Link to this post

    Hi,

    The chart does not have a property to indicate whether the empty content message is shown. However, you can deduct this from the information in the chart, if it has no series - the empty content message is shown. If it has series, but none of the series have data points - again the message is shown. I suspect that if you use MVVM you can easily track if the chart is fed by some items source or not. Let us know how it goes.

    Regards,
    Petar Marchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. sri
    sri avatar
    22 posts
    Member since:
    Oct 2012

    Posted 08 Dec 2015 in reply to Petar Marchev Link to this post

    Well.. 

     

    I did this EmptyContent="{Binding NoDataDisplay,Mode=TwoWay}"  . when there is no data  " NoDataDisplay"  is set with string "No Data to plot."

     But when  chart gets data  above property(EmptyContent) is not Set.Hence so I dont know when data has arrived .

     So I still have issue . Please help if you any other idea.

     

    Thankyou

  5. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 09 Dec 2015 Link to this post

    Hi Sri,

    You are mistaken the purpose of the EmptyContent property. It is the content that gets displayed when there is no data. It is not set/reset in order to notify you in code when there is no data.

    As I mentioned earlier, if you use MVVM, this means that in the view models you know if you have or have not passed any items for display, so when there are no items, the chart is empty. I will give you a very simple example - if your view model is named MainViewModel, it probably has a property similar to Data. Data is some collection that has a Count property. When the count is zero - there is no data in the chart. When the count is not zero, there is some data in the chart. So, if you use MVVM it should be obvious when there is and when there isn't data in the chart.

    Regards,
    Petar Marchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. sri
    sri avatar
    22 posts
    Member since:
    Oct 2012

    Posted 09 Dec 2015 in reply to Petar Marchev Link to this post

    Understood. that. We are exposing Observablecollection properties on Viewmodel. this collection be set based on some events... 

    And events are based on some calculations.  So there is need to say that chart has some data or not i.e calculations result data point count may be zero.  when Chart has no data we will display some other custom UI elemnts on chart.. for this reason we are looking for some kind of property or some work around.

  7. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 10 Dec 2015 Link to this post

    Hello Sri,

    I am a bit confused. Do you still need our help?

    You mentioned that the observable collection is set in some events. If these events are in your view models, you can execute a quick check when they occur - if the observable collection is empty or not. If the collection is empty - the chart is empty. So you can expose a new property in your view models to indicate whether or not there is any data.

    Even if these events are not in the view models, you can add a collection changed handler to the observable collection and get the same results.

    Once you introduce this IsDataEmpty property in your view models, you can easily update the UI when there is and when there is no data.

    Let us know if you need further assistance.

    Regards,
    Petar Marchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. sri
    sri avatar
    22 posts
    Member since:
    Oct 2012

    Posted 10 Dec 2015 in reply to Petar Marchev Link to this post

    I know we can do this from viewmodel. but due to complexity of view model and event logic we have to write alot of plumbing code.

    So was trying to check if we can find any thing on chart itself.

  9. Answer
    Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 15 Dec 2015 Link to this post

    Hello Sri,

    I have attached a small project that demonstrates one possible way to detect whether the empty content presenter is visible or not. Essentially, we are looking inside the visual tree to find the empty content presenter and start listening for visibility changes. We understand that the given work-around is a bit cumbersome and we would suggest that you only use it if you insist on this functionality and cannot achieve it via view models. Let us know if you need more information.

    Regards,
    Petar Marchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner