Itmelabelformat

5 posts, 0 answers
  1. he seaman
    he seaman avatar
    10 posts
    Member since:
    May 2010

    Posted 17 Nov 2010 Link to this post

    when i binding a  SeriesMapping,the Itmelabelformat do not work.Code as foollowing:
        SeriesMapping mapping1 = new SeriesMapping();
                mapping1.SeriesDefinition = new BarSeriesDefinition();
                mapping1.SeriesDefinition.ItemLabelFormat = "#Y{}";
                mapping1.SeriesDefinition.ShowItemLabels = true;
                       ChartAggregateFunction aggFunct = (ChartAggregateFunction)Enum.Parse(typeof(ChartAggregateFunction), "Sum", true);
                ItemMapping itemMapping = new ItemMapping();
                itemMapping.FieldName = item[0].ToString().Trim();
                itemMapping.DataPointMember = DataPointMember.YValue;
                itemMapping.AggregateFunction = aggFunct;
                mapping1.ItemMappings.Add(itemMapping);

    When I use other AggregateFunction such as "min","max","average" ,the ItemLabel dispaly as i want,but AggregateFunction is Sum,it do not work correctly.

    Can you help me ?
  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 19 Nov 2010 Link to this post

    Hello he seaman,

    I reproduced your scenario and everything is working as expected to me. Take a look at the code snippet below:
    public partial class MainPage : UserControl
     {
         public MainPage()
         {
            InitializeComponent();
             List<Company> sampleData = new List<Company>();
             sampleData.Add(new Company(100, new DateTime(2010, 6, 23)));
             sampleData.Add(new Company(210, new DateTime(2009, 5, 12)));
             sampleData.Add(new Company(89, new DateTime(2010, 3, 12)));
             sampleData.Add(new Company(104, new DateTime(2009, 5, 12)));
             sampleData.Add(new Company(69, new DateTime(2010, 7, 31)));
             SeriesMapping seriesMapping = new SeriesMapping();
             seriesMapping.SeriesDefinition = new BarSeriesDefinition();
             seriesMapping.SeriesDefinition.ItemLabelFormat = "#Y{}";
             seriesMapping.SeriesDefinition.ShowItemLabels = true;
             ChartAggregateFunction aggFunct = (ChartAggregateFunction)Enum.Parse(typeof(ChartAggregateFunction), "Sum", true);
             seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartYearGroupDescriptor());
             seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartMonthGroupDescriptor());
             seriesMapping.ItemMappings.Add(new ItemMapping("Interest", DataPointMember.YValue, aggFunct));
             seriesMapping.ItemMappings.Add(new ItemMapping("Creation", DataPointMember.XCategory));
             RadChart1.SeriesMappings.Add(seriesMapping);
             RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM-yy";
             RadChart1.ItemsSource = sampleData;
         }
         public class Company
         {
             public double Interest { get; set; }
             public DateTime Creation { get; set; }
             public Company(double interest, DateTime creation)
             {
                 Interest = interest;
                 Creation = creation;
             }
         
     }

    Sincerely yours,
    Evgenia
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. he seaman
    he seaman avatar
    10 posts
    Member since:
    May 2010

    Posted 21 Nov 2010 Link to this post

    would you like try de code like this? the ItemLabelFormat do not work!

    public partial class MainPage : UserControl
     {
         public MainPage()
         {
            InitializeComponent();
             List<Company> sampleData = new List<Company>();
             sampleData.Add(new Company(100, new DateTime(2010, 6, 23)));
             sampleData.Add(new Company(210, new DateTime(2009, 5, 12)));
             sampleData.Add(new Company(89, new DateTime(2010, 3, 12)));
             sampleData.Add(new Company(104, new DateTime(2009, 5, 12)));
             sampleData.Add(new Company(69, new DateTime(2010, 7, 31)));
             SeriesMapping seriesMapping = new SeriesMapping();
             seriesMapping.SeriesDefinition = new BarSeriesDefinition();
             seriesMapping.SeriesDefinition.ItemLabelFormat = "#Y{}";
             seriesMapping.SeriesDefinition.ShowItemLabels = true;
             ChartAggregateFunction aggFunct = (ChartAggregateFunction)Enum.Parse(typeof(ChartAggregateFunction), "Sum", true);
             //seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartYearGroupDescriptor());
             //seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartMonthGroupDescriptor());
             seriesMapping.ItemMappings.Add(new ItemMapping("Interest", DataPointMember.YValue, aggFunct));
             seriesMapping.ItemMappings.Add(new ItemMapping("Creation", DataPointMember.XCategory));
             RadChart1.SeriesMappings.Add(seriesMapping);
             RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM-yy";
             RadChart1.ItemsSource = sampleData;
         }
         public class Company
         {
             public double Interest { get; set; }
             public DateTime Creation { get; set; }
             public Company(double interest, DateTime creation)
             {
                 Interest = interest;
                 Creation = creation;
             }
         
     }


  4. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 23 Nov 2010 Link to this post

    Hello he seaman,

    As I mentioned in my previous post everything is working as expected with ChartAggregateFunction.Sum
    The Item Label shows value 572 which is the correct sum of the given Yvalues.

    Did you mean that
    RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM-yy";
    is not working? When using Aggregation without Grouping the XAxis can't define the XCategory it should show when summing the Bars values.

    Have in mind that it is recommended to use Aggregation with Grouping as described in our help topic - http://www.telerik.com/help/silverlight/radchart-features-grouping-and-aggregation.html. If you uncomment the Groupings you will be able to see the AxisXDefaultLabelFormat (MMM-yy) correctly displayed for each of the bars.

    Please, find attached a small example, which works as expected. Please, give it a try and let us know if it works fine for you too.

    Sincerely,
    Evgenia
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  5. he seaman
    he seaman avatar
    10 posts
    Member since:
    May 2010

    Posted 25 Nov 2010 Link to this post

    I have result the problem,First i should have a setting
    " RadChart1.DefaultView.ChartArea.LabelFormatBehavior = LabelFormatBehavior.None;" 

    thanks a lot
Back to Top