Hi,
I was trying to change the Value Cell Format like #.00 € (screenshot1.png) but it seems not working (screenshot2.png)
You can test it directly on your demo
I was trying to change the Value Cell Format like #.00 € (screenshot1.png) but it seems not working (screenshot2.png)
You can test it directly on your demo
7 Answers, 1 is accepted
0
Hello Stefania,
Currently, the StringFormat of the aggregate description is not taken into account when displaying the chart's data item tooltips. To achieve this, you will need to create an appropriate converter for these bindings access the format string trough the data provider and parse it accordingly. Here's an example which you will need to customize to suit your particular setup:
I've taken the liberty of logging a new feature request in our feedback portal for such functionality. You can vote for the item to raise its priority in our backlog as well as subscribe to it to get notified about any changes in its status.
I do hope you find the aforementioned approach applicable for the time being.
Regards,
Dilyan Traykov
Progress Telerik
Currently, the StringFormat of the aggregate description is not taken into account when displaying the chart's data item tooltips. To achieve this, you will need to create an appropriate converter for these bindings access the format string trough the data provider and parse it accordingly. Here's an example which you will need to customize to suit your particular setup:
public
class
MyConverter : IMultiValueConverter
{
public
object
Convert(
object
[] values, Type targetType,
object
parameter, CultureInfo culture)
{
var item = values[1]
as
PivotChartItem;
var nameX = item.NameX;
var nameY = item.NameY;
var fieldList = values[2]
as
RadPivotFieldList;
var provider = fieldList.DataProvider;
var settings = provider.Settings;
var aggregateDescription = (settings.AggregateDescriptions
as
IEnumerable<AggregateDescriptionBase>).First()
as
PropertyAggregateDescription;
if
(aggregateDescription !=
null
&& aggregateDescription.StringFormat !=
null
)
{
return
string
.Format(
"{0:"
+ aggregateDescription.StringFormat.Replace(
"#"
,
"0"
) +
"}"
, values[0]);
}
return
values[0];
}
public
object
[] ConvertBack(
object
value, Type[] targetTypes,
object
parameter, CultureInfo culture)
{
throw
new
NotImplementedException();
}
}
<
UserControl.Resources
>
<
local:MyConverter
x:Key
=
"myConverter"
/>
<!-- -->
</
UserControl.Resources
>
<
telerik:RadCartesianChart.TooltipTemplate
>
<
DataTemplate
>
<
Grid
>
<
Path
Data
=
"M-1236,-441 L-1180,-441 -1180,-424 -1228,-424 -1230.5,-420 -1233,-424 -1236,-424 z"
Stretch
=
"Fill"
Fill
=
"{telerik:Windows8Resource ResourceKey=MainBrush}"
Stroke
=
"{telerik:Windows8Resource ResourceKey=AccentBrush}"
StrokeThickness
=
"2"
/>
<
StackPanel
Orientation
=
"Vertical"
Margin
=
"5,5,5,18"
>
<
TextBlock
Text
=
"{Binding Path=DataItem.NameY}"
FontSize
=
"11"
Foreground
=
"{telerik:Windows8Resource ResourceKey=StrongBrush}"
/>
<
TextBlock
Text
=
"{Binding Path=DataItem.NameX}"
FontSize
=
"11"
Foreground
=
"{telerik:Windows8Resource ResourceKey=StrongBrush}"
/>
<
TextBlock
FontWeight
=
"Bold"
FontSize
=
"11"
Foreground
=
"{telerik:Windows8Resource ResourceKey=MarkerBrush}"
>
<
TextBlock.Text
>
<
MultiBinding
Converter
=
"{StaticResource myConverter}"
>
<
Binding
Path
=
"DataItem.Value"
/>
<
Binding
Path
=
"DataItem"
/>
<
Binding
Path
=
"."
Source
=
"{x:Reference fieldList}"
/>
</
MultiBinding
>
</
TextBlock.Text
>
</
TextBlock
>
</
StackPanel
>
</
Grid
>
</
DataTemplate
>
</
telerik:RadCartesianChart.TooltipTemplate
>
I've taken the liberty of logging a new feature request in our feedback portal for such functionality. You can vote for the item to raise its priority in our backlog as well as subscribe to it to get notified about any changes in its status.
I do hope you find the aforementioned approach applicable for the time being.
Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Stefania
Top achievements
Rank 2
answered on 07 Feb 2018, 02:23 PM
Ok, it works, thank you. How can I gat a similar behaviour in Labels?
0
Hello Stefania,
To achieve the desired effect, you can specify a template for the label definition of your series. You can do this either directly on the series or in the SeriesCreated event of the series provider if you're using one, like so:
If you wish to apply this template through a style, you can create an attached property for the same:
The attached property can then be set like so:
Please let me know whether this would work for you. I look forward to your reply.
Regards,
Dilyan Traykov
Progress Telerik
To achieve the desired effect, you can specify a template for the label definition of your series. You can do this either directly on the series or in the SeriesCreated event of the series provider if you're using one, like so:
private
void
ChartSeriesProvider_SeriesCreated(
object
sender, Controls.ChartView.ChartSeriesCreatedEventArgs e)
{
e.Series.LabelDefinitions.Add(
new
Controls.ChartView.ChartSeriesLabelDefinition()
{
Template =
this
.Resources[
"LabelTemplate"
]
as
DataTemplate
});
}
If you wish to apply this template through a style, you can create an attached property for the same:
public
static
class
ChartSeriesLabelDefinitionUtilities
{
public
static
DataTemplate GetTemplate(DependencyObject obj)
{
return
(DataTemplate) obj.GetValue(TemplateProperty);
}
public
static
void
SetTemplate(DependencyObject obj, DataTemplate value)
{
obj.SetValue(TemplateProperty, value);
}
public
static
readonly
DependencyProperty TemplateProperty = DependencyProperty.RegisterAttached(
"Template"
,
typeof
(DataTemplate),
typeof
(ChartSeriesLabelDefinitionUtilities),
new
PropertyMetadata(
null
, TemplateChanged));
private
static
void
TemplateChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
{
CartesianSeries series = (CartesianSeries) target;
series.LabelDefinitions.Clear();
DataTemplate template = (DataTemplate) args.NewValue;
if
(template !=
null
)
{
series.LabelDefinitions.Add(
new
ChartSeriesLabelDefinition() { Template = template });
}
}
}
The attached property can then be set like so:
<
Style
TargetType
=
"telerik:BarSeries"
x:Key
=
"barCategoricalSeriesDescriptorStyle"
BasedOn
=
"{StaticResource BarSeriesStyle}"
>
<
Setter
Property
=
"CombineMode"
Value
=
"{Binding ElementName=CombineMode, Path=SelectedItem, Mode=TwoWay}"
/>
<
Setter
Property
=
"LegendSettings"
>
<
Setter.Value
>
<
telerik:SeriesLegendSettings
Title
=
"{Binding Name}"
/>
</
Setter.Value
>
</
Setter
>
<
Setter
Property
=
"ShowLabels"
Value
=
"True"
/>
<
Setter
Property
=
"helpers:ChartSeriesLabelDefinitionUtilities.Template"
Value
=
"{StaticResource LabelTemplate}"
/>
</
Style
>
Please let me know whether this would work for you. I look forward to your reply.
Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Stefania
Top achievements
Rank 2
answered on 09 Feb 2018, 11:38 AM
Hi,
i have used the first solution and it works.
But if i add two aggregate fields and i set format #.00 € on the first one and #.00 °C on the second one, all these two fields use the first format.
How can i fix it?
0
Hi Stefania,
Let me check this out and I will contact when I have more information about your case.
Regards,
Dinko
Progress Telerik
Let me check this out and I will contact when I have more information about your case.
Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Hello Stefania,
When dealing with multiple aggregate descriptions, you will need to choose the correct one base on the NameX and NameY of the current PivotChartItem. Here's an example of how this can be done:
Please let me know if this works for you.
Regards,
Dilyan Traykov
Progress Telerik
When dealing with multiple aggregate descriptions, you will need to choose the correct one base on the NameX and NameY of the current PivotChartItem. Here's an example of how this can be done:
public
object
Convert(
object
[] values, Type targetType,
object
parameter, CultureInfo culture)
{
var item = values[1]
as
PivotChartItem;
var nameX = item.NameX;
var nameY = item.NameY;
var fieldList = values[2]
as
RadPivotFieldList;
var provider = fieldList.DataProvider;
var settings = provider.Settings;
var aggregateDescriptions = (settings.AggregateDescriptions
as
IEnumerable<AggregateDescriptionBase>);
AggregateDescriptionBase aggregateDescription;
if
(aggregateDescriptions.Count() > 1)
{
aggregateDescription = aggregateDescriptions.FirstOrDefault(x => nameX.Contains(x.DisplayName) || nameY.Contains(x.DisplayName));
}
else
{
aggregateDescription = aggregateDescriptions.FirstOrDefault();
}
PropertyAggregateDescription propertyAggregateDescription = aggregateDescription
as
PropertyAggregateDescription;
if
(propertyAggregateDescription !=
null
&& propertyAggregateDescription.StringFormat !=
null
)
{
return
string
.Format(
"{0:"
+ propertyAggregateDescription.StringFormat.Replace(
"#"
,
"0"
) +
"}"
, values[0]);
}
return
values[0].ToString();
}
Please let me know if this works for you.
Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Stefania
Top achievements
Rank 2
answered on 21 Feb 2018, 08:18 AM
Ok, it works, thank you.