This is a migrated thread and some comments may be shown as answers.

ItemToolTipFormat not accepting DateTime format strings

6 Answers 122 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Rodney Foley
Top achievements
Rank 1
Rodney Foley asked on 09 Nov 2010, 12:10 AM
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.

6 Answers, 1 is accepted

Sort by
0
Accepted
Evgeni "Zammy" Petrov
Telerik team
answered on 11 Nov 2010, 09:31 AM
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
0
Rodney Foley
Top achievements
Rank 1
answered on 11 Nov 2010, 05:52 PM
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.
0
Ves
Telerik team
answered on 16 Nov 2010, 01:55 PM
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>>
0
Rodney Foley
Top achievements
Rank 1
answered on 16 Nov 2010, 05:59 PM
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?
0
Igor T
Top achievements
Rank 1
answered on 16 Nov 2010, 09:11 PM
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;

0
Ves
Telerik team
answered on 19 Nov 2010, 03:35 PM
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
Tags
Chart
Asked by
Rodney Foley
Top achievements
Rank 1
Answers by
Evgeni "Zammy" Petrov
Telerik team
Rodney Foley
Top achievements
Rank 1
Ves
Telerik team
Igor T
Top achievements
Rank 1
Share this question
or