New to Telerik UI for WPF? Download free 30-day trial

Creating a Chart With Custom Layout

If the default layout provided by the RadChart.DefaultView does not fit your scenario, then you can define your own layout where to put all the elements you need. Moreover - you can add as many ChartArea, ChartLegend and ChartTitle as you need.

If, for example, you want to show the monthly sales of cars for the year 2009 on one chart and next to it, as a second chart to display the sales per car manufacturer with a legend, then you have to set UseDefaultLayout to False and to define your own. In this example, you have Grid with two rows and three columns. On the first row two ChartTitle elements are placed in the first and the second columns where the chart areas will be placed. On the second row will be added two ChartArea controls in the first two columns and a ChartLegend in the third column.

<telerik:RadChart UseDefaultLayout="False" Height="362" Width="1042" VerticalAlignment="Bottom"> 
    <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,10,0,20"> 
            <RowDefinition Height="Auto" /> 
            <RowDefinition Height="" /> 
            <ColumnDefinition Width="" /> 
            <ColumnDefinition Width="*" /> 
            <ColumnDefinition Width="Auto" /> 
        <telerik:ChartTitle Margin="0,0,0,10" HorizontalAlignment="Center" Content="Monthly Sales for 2009"  
            Grid.Row="0" Grid.Column="0" /> 
        <telerik:ChartArea HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  
            Grid.Row="1" Grid.Column="0"> 
                <!-- Line Chart --> 
                        <telerik:LineSeriesDefinition /> 
                    <telerik:DataPoint YValue="38" XCategory="Jan"/> 
                    <telerik:DataPoint YValue="65" XCategory="Feb"/> 
                    <telerik:DataPoint YValue="30" XCategory="Mar"/> 
                    <telerik:DataPoint YValue="63" XCategory="Apr"/> 
                    <telerik:DataPoint YValue="98" XCategory="May"/> 
                    <telerik:DataPoint YValue="47" XCategory="Jun"/> 
                    <telerik:DataPoint YValue="91" XCategory="Jul"/> 
                    <telerik:DataPoint YValue="99" XCategory="Aug"/> 
                    <telerik:DataPoint YValue="32" XCategory="Sep"/> 
                    <telerik:DataPoint YValue="77" XCategory="Oct"/> 
                    <telerik:DataPoint YValue="62" XCategory="Nov"/> 
                    <telerik:DataPoint YValue="38" XCategory="Dec"/> 
        <telerik:ChartTitle HorizontalAlignment="Center" Content="Sales per Manufacturer" 
            Margin="0,0,0,10" Grid.Row="0" Grid.Column="1" /> 
        <telerik:ChartArea LegendName="ChartLegendManufacturers" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"  
            Margin="0,0,0,15" Grid.Row="1" Grid.Column="1"> 
                <!-- Doughnut Chart --> 
                        <telerik:DoughnutSeriesDefinition ItemLabelFormat="p"> 
                    <telerik:DataPoint YValue="0.215208267" LegendLabel="Toyota"/> 
                    <telerik:DataPoint YValue="0.192960612" LegendLabel="General Motors"/> 
                    <telerik:DataPoint YValue="0.151830229" LegendLabel="Volkswagen"/> 
                    <telerik:DataPoint YValue="0.125964366" LegendLabel="Ford"/> 
                    <telerik:DataPoint YValue="0.091152353" LegendLabel="Honda"/> 
                    <telerik:DataPoint YValue="0.079093251" LegendLabel="Nissan"/> 
                    <telerik:DataPoint YValue="0.079093251" LegendLabel="PSA"/> 
                    <telerik:DataPoint YValue="0.06469767" LegendLabel="Hyundai"/> 
        <telerik:ChartLegend x:Name="ChartLegendManufacturers" 
                             Grid.Row="1" Grid.Column="2" /> 

In the image bellow you can see how the custom layout chart looks like:

See Also

In this article
Not finding the help you need? Improve this article