6 Answers, 1 is accepted
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}"
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
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.
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
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;
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