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 ?
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 ?
4 Answers, 1 is accepted
0
Hello he seaman,
I reproduced your scenario and everything is working as expected to me. Take a look at the code snippet below:
Sincerely yours,
Evgenia
the Telerik team
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
0
he seaman
Top achievements
Rank 1
answered on 22 Nov 2010, 05:27 AM
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;
}
}
}
0
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
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
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";
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
0
he seaman
Top achievements
Rank 1
answered on 25 Nov 2010, 07:11 AM
I have result the problem,First i should have a setting
" RadChart1.DefaultView.ChartArea.LabelFormatBehavior = LabelFormatBehavior.None;"
thanks a lot
" RadChart1.DefaultView.ChartArea.LabelFormatBehavior = LabelFormatBehavior.None;"
thanks a lot