Legend Labeling

4 posts, 0 answers
  1. cmr
    cmr avatar
    7 posts
    Member since:
    Jun 2010

    Posted 18 Jun 2010 Link to this post

    Within the chart legend, I would like to add a summary total for all the series mapping totals such as Girls [SeriesMapping 1], Boys [SeriesMapping 2], and Total.  The total should be positioned below all the legend labels. 

    1. The first attempt was to create a Total SeriesMapping; however, the chart plot sets aside space to occupy this data for the BarSeriesDefinition chart type, which is not being set, and the label within the legend was erratically being placed in different positions.
    2. The second attempt was to add a ChartLegendItem with the "Total" label to the radChart1.DefaultView.ChartLegend.Items which results in the "Total" summary displayed above the rest of the legend labels.

    Any ideas?

  2. Nikolay
    Admin
    Nikolay avatar
    397 posts

    Posted 24 Jun 2010 Link to this post

    Hi cmr,

    If you need to explicitly create legend items, set the value of the property UseAutoGeneratedItems to False and manually add the items which you need to the chart legend, as in the following sample :

    <chart:ChartDefaultView.ChartLegend>
                        <chart:ChartLegend x:Name="chartLegend"                                         
                                                UseAutoGeneratedItems="False">
                            <chart:ChartLegend.Items>
                                <chart:ChartLegendItem Background="Red"
                                                            Label="Girls" />
                                <chart:ChartLegendItem Background="Blue"
                                                            Label="Boys" />
                                <chart:ChartLegendItem Background="Green"
                                                            Label="Total" />
                            </chart:ChartLegend.Items>
                        </chart:ChartLegend>
                    </chart:ChartDefaultView.ChartLegend>

    For more information on Chart Legend, please, refer to this help topic. Perhaps this blogpost would also be useful for you.

    Sincerely yours,
    Nikolay
    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
  3. Przemyslaw
    Przemyslaw avatar
    21 posts
    Member since:
    Oct 2007

    Posted 20 Jul 2010 Link to this post

    Hi,

    My problem is similar. I display a number of series. I want to override the legend names and preserve the default coloring. When I set the UseAutoGeneratedItems to False and add ChartLegendItems then the colors for my series stop matching the colors in the legend. How to programatically just change the legend names?

    Przemek
  4. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 21 Jul 2010 Link to this post

    Hi Przemyslaw,

    You can set the desired legend label for each series via the respective DataSeries.LegendLabel property (if you are building your series manually) or via the respective SeriesMapping.LegendLabel property (if you are using the chart databinding feature).

    Hope this helps.


    All the best,
    Freddie
    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
Back to Top