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

How to get a percentage value when using grouping and an aggregator function

1 Answer 54 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 26 Feb 2015, 03:05 PM
Hi there,

I'm using a RadChart to create some bar graphs of the total number of projecs per project type. I'm using a group descriptor to group the data:

<telerikCharting:SeriesMapping.GroupingSettings>
    <telerikCharting:GroupingSettings ShouldCreateSeriesForLastGroup="True">
        <telerikCharting:GroupingSettings.GroupDescriptors>
            <telerikCharting:ChartGroupDescriptor Member="ProjectType"/>
        </telerikCharting:GroupingSettings.GroupDescriptors>
    </telerikCharting:GroupingSettings>
</telerikCharting:SeriesMapping.GroupingSettings>

My item mappings looks like this:

<telerik:SeriesMapping.ItemMappings>
    <telerik:ItemMapping FieldName="ProjectType" DataPointMember="XCategory" />
    <telerik:ItemMapping FieldName="Name" DataPointMember="YValue" AggregateFunction="Count" />
</telerik:SeriesMapping.ItemMappings>

I'm attaching a screenshot showing what this currently looks like. What I want though, is to show the percentages of each category in addition to the number of projects. I don't know ahead of time how many project types will be included in the data being graphed.

I appreciate any help I can get with this.

Thanks,
Jonathan

1 Answer, 1 is accepted

Sort by
0
Accepted
Peshito
Telerik team
answered on 02 Mar 2015, 09:33 AM
Hi Jonathan,

Simply use the ItemLabelFormat property of the SeriesDefinition like shown below:
<telerik:RadChart.SeriesMappings>
      <telerik:SeriesMapping>
          <telerik:SeriesMapping.SeriesDefinition>
              <telerik:BarSeriesDefinition ItemLabelFormat="#DATAITEM.Value %"/>
          </telerik:SeriesMapping.SeriesDefinition>
          <telerik:SeriesMapping.ItemMappings>
              <telerik:ItemMapping FieldName="Title" DataPointMember="XCategory" />
              <telerik:ItemMapping FieldName="Value2" DataPointMember="YValue" />
          </telerik:SeriesMapping.ItemMappings>
      </telerik:SeriesMapping>
  </telerik:RadChart.SeriesMappings>
The above code will just add the percentage sign to the item's value. You can use a custom or standard numeric format expression to further specify the format.

More about expressions can be found in our Format Expressions help topic.

Regards,
Peshito
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ChartView
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or