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

Axis Label custom DataTemplate

2 Answers 82 Views
Chart
This is a migrated thread and some comments may be shown as answers.
leblanc
Top achievements
Rank 1
leblanc asked on 16 Jun 2012, 01:03 AM

I'm using RadChart and have three series defined each with an XCategory defined in ItemMappings
<telerik:ItemMapping FieldName="CategoryX" DataPointMember="XCategory" />

FieldName CategoryX is a partial class property which allows the X axis to have the data I want. I could probably use FormatExpressions to accomplish similar.  I need more than just a TextBlock...


and each series is defined with 1 y value (OpenedPercentage, ClickedPercentage, DeliveredPercentage)
<telerik:ItemMapping FieldName="OpenedPercentage" DataPointMember="YValue" />

 



My attempts to replace the style of the axis label has not worked.  



How can i provide a custom data template (a lot of controls) to the axis label that can bind to all the dataitem properties?

I am using 2012 Q2. Thanks ahead of time!

 

 

 

2 Answers, 1 is accepted

Sort by
0
leblanc
Top achievements
Rank 1
answered on 17 Jun 2012, 09:42 PM
In my first post I attached an image of what the view looks like today.  I want to improve the x axis label to just be an image and then use a tooltip to give you the details.

The problem is if i try to use styles I can't bind to the item in my MVVM.

System.Windows.Data Error: BindingExpression path error: 'CategoryX' property not found on 'Telerik.Windows.Controls.Charting.TickPoint' 'Telerik.Windows.Controls.Charting.TickPoint' (HashCode=40306186). BindingExpression: Path='CategoryX' DataItem='Telerik.Windows.Controls.Charting.TickPoint' (HashCode=40306186); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'ToolTip' (type 'System.Object')..


            <Charting:ChartArea.AxisX>
                <Charting:AxisX MajorGridLinesVisibility="Visible" StripLinesVisibility="Visible">
                    <Charting:AxisX.AxisStyles>
                        <Charting:AxisStyles ItemLabelStyle="{StaticResource CustomLabel}" />
                    </Charting:AxisX.AxisStyles>
                </Charting:AxisX>
            </Charting:ChartArea.AxisX>
 
 
<Style x:Key="CustomLabel" TargetType="TextBlock">
    <Setter Property="Width" Value="50" />
    <Setter Property="TextWrapping" Value="Wrap" />
    <Setter Property="ToolTipService.ToolTip" Value="{Binding CategoryX}" />
</Style>



How would you accomplish changing the xaxis to be an image with a tooltip with a stackpanel and multiple textboxes?

Thanks
0
Yavor
Telerik team
answered on 20 Jun 2012, 08:00 PM
Hello,

This can be achieved with RadChartView as it enables you to set custom template for your categorical axis labels. In the LabelTemplate you can put a stacked panel with multiple textboxes and images with ease.

All the best,
Yavor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
leblanc
Top achievements
Rank 1
Answers by
leblanc
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or