ItemToolTipFormat not accepting DateTime format strings

7 posts, 1 answers
  1. Rodney Foley
    Rodney Foley avatar
    72 posts
    Member since:
    Oct 2009

    Posted 08 Nov 2010 Link to this post

    I set ItemToolTipFormat="#Y{#} on #XCAT{MM/dd/yyyy}" and the DataTime format strings that are supposed to work per the Telerik's Format Expressions documentation and it is ignored. #XCAT is a DateTime and it is displaying as if I gave it the following format string "MM/dd/yyyy HH:mm:ss".  Which is what it shows if I take the format string off and leave it only #XCAT.  The format string for fine for my #Y which is an int, and I have set it to others to make sure it is working and it does. Seems to not like the DateTime format strings that are acceptable.
  2. Answer
    Evgeni "Zammy" Petrov
    Admin
    Evgeni "Zammy" Petrov avatar
    168 posts

    Posted 11 Nov 2010 Link to this post

    Hello Rodney Foley,

    This is not working because #XCAT actually returns a string not DateTime as you expect. It is already formated. You need to use something similar to this expression 

    "#Y{#} on #DATAITEM.BirthDate{MM/dd/yyyy}"
    to get the desired effect.
    This takes the actual DataItem (the object that is represented in the chart) and takes the BirthDate property.
    Just replace BirthDate with the appropriate property name.
    I hope this information helps.

    Sincerely yours,
    Evgeni "Zammy" Petrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Rodney Foley
    Rodney Foley avatar
    72 posts
    Member since:
    Oct 2009

    Posted 11 Nov 2010 Link to this post

    Hi Zammy,

    Thanks that did the trick.

    However I think this is an issue with the XCAT that makes is useless in most cases.  I go to the trouble of setting a DefaultLabelFormat for my AxisX on the ChartArea. If XCAT is going to be pre-formated string I would expect it to use the DefaultLabelFormat I have set for AxisX.  This would make XCAT useful to anyone who has set the DefaultLabelFormat, otherwise it is only use to people who leave the formating to the default settings.
  4. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 16 Nov 2010 Link to this post

    Hello Rodney Foley,

    The XCategory of a DataPoint is a string. DefaultLabelFormat is a formatting string which is applied to numeric or DateTime values when XValue is used, in order to achieve certain appearance. However, it has no effect when applied to strings -- this actually works just as plain .net ToString() method. This is why we have provided the #DATAITEM token, so that you have access to the underlying data object and retrieve and format any information you may need.

    Best regards,
    Ves
    the Telerik team
    See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  5. Rodney Foley
    Rodney Foley avatar
    72 posts
    Member since:
    Oct 2009

    Posted 16 Nov 2010 Link to this post

    Hi Ves, thanks but your co-worker Zammy already answered and explained the situation. I even posted my thanks.  You are just duplicating Zammy's effort, as it has no relevance to my additional comments requesting a feature (or rather a bug fix in my opinion) that #XCAT stay in sync with the AxisX DefaultLabelFormat. Otherwise #XCat is useless to anyone who uses DefaultLabelFormat as now I have to format the data TWICE now instead of just once, this is a volition of the DRY principle.  If I want to format the Label differntly in a tool tip then the #DATAITEM is great, however if I want it to be formated the same as what I already asked the control to format the label to be then why make me do it twice?
  6. Igor T
    Igor T avatar
    8 posts
    Member since:
    Mar 2010

    Posted 16 Nov 2010 Link to this post

    Hi,
    Not to convolute the thread, but I have a similar situation. I can't get the tooltip to display Creation field (it just gives me the formatting expression back) please see code snippet below in bold. However if I remove "ChartAggregateFunction.Sum" below it displays fine. Can you please tell me the correct way to access that? 

    I was following the example for charts and everything works, except the tooltip - Creation part. I've attached an image of demo example.


    Here's the snippet, my source is a List<MyChartItem>, where MyChartItem contains two properties: int Interest, DateTime Creation.

    SeriesMapping seriesMapping = new SeriesMapping();
                seriesMapping.SeriesDefinition = new BarSeriesDefinition();
                seriesMapping.SeriesDefinition.ShowItemLabels = false;
                seriesMapping.SeriesDefinition.ShowItemToolTips = true;
                seriesMapping.SeriesDefinition.ItemToolTipFormat = string.Concat("Month: ", "#DATAITEM.Creation{MMM-yy}", "\r\nInterest: #Y");

     

                seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartYearGroupDescriptor());
                seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartMonthGroupDescriptor());
                seriesMapping.ItemMappings.Add(new ItemMapping("Interest", DataPointMember.YValue, ChartAggregateFunction.Sum));
                seriesMapping.ItemMappings.Add(new ItemMapping("Creation", DataPointMember.XCategory));
                MyChart.SeriesMappings.Add(seriesMapping);
                MyChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM-yy";
               

                this.MyChart.ItemsSource = chartItems;

  7. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 19 Nov 2010 Link to this post

    Hi Rodney,

    Thanks for the feedback. I will forward it to our developers, though I am not sure if an update will be provided, given the relatively easy way to implement this through #DATAITEM.

    Igor, I can see Evgenia has replied to the other forum post of yours and it seems to work good for you. Let us know if further issues arise.

    Kind regards,
    Ves
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top