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

Combine stacked BarSeries with LineSeries

3 Answers 81 Views
Chart
This is a migrated thread and some comments may be shown as answers.
JW
Top achievements
Rank 1
JW asked on 07 Jul 2020, 09:16 AM

I would like to create a chart where a stacked BarSeries is combined with a LineSeries. The horizontal axis is Categorical and shows week numbers (Category), the vertical is Linear (Value). The example data is this:

            List<Data> barCollection = new List<Data>();
            barCollection.Add(new Data { Category = "Wk 1", Label = "Preperation", Value = 5 });
            barCollection.Add(new Data { Category = "Wk 2", Label = "Preperation", Value = 3 });
            barCollection.Add(new Data { Category = "Wk 3", Label = "Preperation", Value = 4 });
            barCollection.Add(new Data { Category = "Wk 1", Label = "Production", Value = 4 });
            barCollection.Add(new Data { Category = "Wk 2", Label = "Production", Value = 3 });
            barCollection.Add(new Data { Category = "Wk 3", Label = "Production", Value = 3 });

            List<Data> lineCollection = new List<Data>();
            lineCollection.Add(new Data { Category = "Wk 1", Label = "Project", Value = 8 });
            lineCollection.Add(new Data { Category = "Wk 2", Label = "Project", Value = 7 });
            lineCollection.Add(new Data { Category = "Wk 3", Label = "Project", Value = 4 });
            lineCollection.Add(new Data { Category = "Wk 1", Label = "QuoteAndProjects", Value = 8 });
            lineCollection.Add(new Data { Category = "Wk 2", Label = "QuoteAndProjects", Value = 9 });
            lineCollection.Add(new Data { Category = "Wk 3", Label = "QuoteAndProjects", Value = 7 });

The bar-items need to be stacked in each week. The line-items (Two lines, based on the Label) are separate from each other. They need to be shown in front of the bars, since they might not be visible otherwise.

I have found several simple examples of individual portions of this question, but the combination is what makes it difficult. Can anyone help me in the right direction? 

3 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 08 Jul 2020, 11:00 AM

Hi,

I have created a sample that shows how combine mode can be achieved with 3 barseries and 1 lineseries. Mainly you have to set the combinemode to stack or cluster to the series. 

Please download the attached file and give it a try.

I hope the provided information was helpful.

Regards,
Didi
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
JW
Top achievements
Rank 1
answered on 09 Jul 2020, 09:26 AM

Thank you Didi.

Technically, this answered my question and enabled me to generate the chart I need. I have one more question though; Is it possible to do this with a SeriesProvider, so I can add and remove series later without having to change the xaml?

0
Didi
Telerik team
answered on 10 Jul 2020, 10:34 AM

Hi,

I am afraid this scenario could not be achieved using SeriesProvider. 

I have attached sample of how seriesprovider could be used using line or barseries. 

If you want to add/remove different series to the chart I can suggest you place buttons above the chart to add/remove series to the chart.

another suggestion is described at the following link in our forum:  https://www.telerik.com/forums/dynamic-adding-of-different-type-of-series

I hope the provided information was helpful.

Regards,
Didi
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Chart
Asked by
JW
Top achievements
Rank 1
Answers by
Didi
Telerik team
JW
Top achievements
Rank 1
Share this question
or