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

Line chart with groping seriesMapping.GroupingSettings.GroupDescriptors

8 Answers 237 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Dhaval
Top achievements
Rank 1
Dhaval asked on 09 Feb 2011, 02:34 PM
Hi All,

Status (string)
Stage (string)
Eatimated Revenue (Double)

Whenever i use group data with Stage or status and create line chart it's give me the POINT
DOESN'T display line between two POINT. I want to display line with different color according to group data.


SeriesMapping seriesMapping = new SeriesMapping();
          
            if (listOpp != null)
            {

                seriesMapping.SeriesDefinition = new LineSeriesDefinition();

                if (ddlchartby.SelectedItem.ToString() == "Status")
                {
                    seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Status"));
                    seriesMapping.ItemMappings.Add(new ItemMapping("Status", DataPointMember.XCategory));
                    seriesMapping.ItemMappings.Add(new ItemMapping("Status", DataPointMember.YValue, ChartAggregateFunction.Count));
                }
                else if (ddlchartby.SelectedItem.ToString() == "Stage")
                {
                    seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Stage"));
                    seriesMapping.ItemMappings.Add(new ItemMapping("Stage", DataPointMember.XCategory));
                    seriesMapping.ItemMappings.Add(new ItemMapping("Stage", DataPointMember.YValue, ChartAggregateFunction.Count));
                }
                radChart.SeriesMappings.Clear();
                radChart.SeriesMappings.Add(seriesMapping);
                List<CampaignChartModel> listchart = new List<CampaignChartModel>();
                foreach (CrmOpportunity opp in listOpp)
                {
                    listchart.Add(new CampaignChartModel(Convert.ToDouble(opp.EstimatedRevenue), opp.Status, opp.Stage));
                }
                this.radChart.ItemsSource = listchart;

            }

I have attached two image
LINE-CHART.jpg - I get
LINE-CHART-COPY.jpg - I want


Thanks,

8 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 10 Feb 2011, 04:25 PM
I think you're missing something.  Don't you have some kind of "value" for the YAxis?  For example, Stage and Status are probably both "textual" data.  You need some kind of numerical data field (value?).  In which case you can add multiple Groupings (ex. Group By Stage, Status and YAxis = Total of Value field).  What you're doing here is not how the chart should be used (unless of course both Stage and Status columns of your data source are the number of items in those Stages and Status, but even then your chart won't make sense).

My suggestion is to add a new field to your data source "value" or "ItemCount" and bind that to the YAxis.
0
Dhaval
Top achievements
Rank 1
answered on 11 Feb 2011, 01:55 PM
Hi,

Thanks for your quick reply.

Here is my code :

<UserControl x:Class="SilverlightApplication3.line"
    xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
 
    <Grid x:Name="LayoutRoot" Background="White">
        <telerikChart:RadChart x:Name="radChart" d:LayoutOverrides="Width, Height" BorderThickness="5" />
    </Grid>
</UserControl>
SeriesMapping seriesMapping = new SeriesMapping();
            seriesMapping.SeriesDefinition = new LineSeriesDefinition();
 
           
                seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Status"));
                //seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Stage"));
                //seriesMapping.GroupingSettings.ShouldCreateSeriesForLastGroup = false;
                seriesMapping.ItemMappings.Add(new ItemMapping("Status", DataPointMember.XCategory));
                seriesMapping.ItemMappings.Add(new ItemMapping("Status", DataPointMember.YValue, ChartAggregateFunction.Count));
                radChart.SeriesMappings.Clear();
                radChart.SeriesMappings.Add(seriesMapping);
 
                //public ProductSales(Double estimaterevenue,string stage , string status)
 
                List<ProductSales> persons = new List<ProductSales>();
                persons.Add(new ProductSales(1000, "Preliminary Quoted", "In Progress"));
                persons.Add(new ProductSales(3000, "Preliminary Quoted", "In Progress"));
                persons.Add(new ProductSales(2000, "Meeting Arranged", "Not Started"));
                persons.Add(new ProductSales(5000, "Meeting Arranged", "In Progress"));
                persons.Add(new ProductSales(7000, "Preliminary Quoted", "Not Started"));
                persons.Add(new ProductSales(8000, "Rewise Quote", "Completed-won"));
                persons.Add(new ProductSales(12000, "Rewise Quote", "Not Started"));
                persons.Add(new ProductSales(5000, "Meeting Arranged", "Not Started"));
 
                this.radChart.ItemsSource = persons;

Here output will be fine but i have only one issue
it's display points which are not connected with line
I have also try

//seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Stage"));
                //seriesMapping.GroupingSettings.ShouldCreateSeriesForLastGroup = false;

add this code above source code but not get proper output

Thanks,


0
Dhaval
Top achievements
Rank 1
answered on 18 Feb 2011, 10:53 AM
Hi All,

If any one got the same issue so pls help me on that,
It's very urgent.

I have posted sample xaml and c# file code, so you can easily identify my issue.

Thanks,

0
Nikolay
Telerik team
answered on 21 Feb 2011, 09:30 AM
Hello Dhaval,

The dots in your sample are not connected because they are from two different Line series, with one point each. You can achieve the desired behavior by creating one Line series with two points and use the LegendDisplayMode property, instead of grouping. Please, note that you would also need a numeric value for the mapping to DataPointMember.YValue. Here is a sample code snippet:
SeriesMapping seriesMapping = new SeriesMapping(); 
seriesMapping.SeriesDefinition = new LineSeriesDefinition(); 
seriesMapping.ItemMappings.Add(new ItemMapping("Stage", DataPointMember.XCategory)); 
seriesMapping.ItemMappings.Add(new ItemMapping("Score", DataPointMember.YValue)); 
seriesMapping.ItemMappings.Add(new ItemMapping("Stage", DataPointMember.LegendLabel)); 
seriesMapping.SeriesDefinition.LegendDisplayMode = LegendDisplayMode.DataPointLabel; 
RadChart1.SeriesMappings.Add(seriesMapping);

Hope this helps.

Greetings,
Nikolay
the Telerik team
0
Dhaval
Top achievements
Rank 1
answered on 21 Feb 2011, 12:04 PM
Hi Nikolay,

I got your point but i want to display line in between two point which is from different Line series with different line color.

Thanks,
0
Nikolay
Telerik team
answered on 21 Feb 2011, 01:13 PM
Hello Dhaval,

Please, find attached a small sample project, which demonstrates how to achieve this. Attached is also the output. Please, note that you cannot connect the labels of the series, but only the pointmarks.

All the best,
Nikolay
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Dhaval
Top achievements
Rank 1
answered on 01 Mar 2011, 10:44 AM
did you mean Grouping is not possible in line chart?

I refer your code but what about this line of code

"seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Status"));"

i need to add group by "Status" in LineSeriesDefinition.

Thanks,
0
Ves
Telerik team
answered on 04 Mar 2011, 10:01 AM
Hi Dhaval,

Grouping is not related to the series type. Grouping is performed over data and influences how the resulting chart items (bars, line points, bubbles, etc.) are grouped into series. Grouping is available for line charts. Note, that if you have two records with different value for the  "Status" column/property, you will get two DataSeries with one item each. And the paradigm of line chart dictates showing a line between points of the same series. This is why you would get only points with no connecting line.

You can set the seriesMapping.GroupingSettings.ShouldFlattenSeries property to true in order to get a flat series with multiple items (as shown in this example) or remove the grouping at all. Then you can set the SeriesDefinition.LegendDisplayMode  to LegendDisplayMode.DataPointLabels. This will force the chart to show an item in the legend for each datapoint within the series and in addition each pointmark will be drawn with its own color according to the palette.

Kind regards,
Ves
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Chart
Asked by
Dhaval
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Dhaval
Top achievements
Rank 1
Nikolay
Telerik team
Ves
Telerik team
Share this question
or