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

Simple stacked bar example

6 Answers 295 Views
Chart
This is a migrated thread and some comments may be shown as answers.
ebaker
Top achievements
Rank 1
ebaker asked on 23 Sep 2010, 05:29 PM
Can someone please give me a simple example on how  to make a horizontal stacked bar chart? I'm finding it very difficult to grasp the charting controls, and I'm under a tight deadline at the moment. I just need a single horizontal bar (not 3D) with 3 stacks colored green, red, and gray. I can get 3 separate bars to display, but I can't stack them into a single bar. What am I missing? If someone can throw together a few lines of code to show me an example, that would be very helpful.

Thanks,
Eric

6 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 27 Sep 2010, 03:19 PM
Hi Eric,

This is a sample of Horizontal Stacked Bar made of three Series as you requested.

<my:RadChart x:Name="radChart1">
           <my:RadChart.DefaultView>
               <Charting:ChartDefaultView>
                   <Charting:ChartDefaultView.ChartArea>
                       <Charting:ChartArea>
                           <Charting:ChartArea.DataSeries>
                               <!-- Series 1 -->
                               <Charting:DataSeries LegendLabel="Series 1">
                                   <Charting:DataSeries.Definition>
                                       <Charting:HorizontalStackedBarSeriesDefinition>
                                       </Charting:HorizontalStackedBarSeriesDefinition>
                                   </Charting:DataSeries.Definition>
                                   <Charting:DataPoint YValue="20"/>
                               </Charting:DataSeries>
                               <!-- Series 2 -->
                               <Charting:DataSeries LegendLabel="Series 2">
                                   <Charting:DataSeries.Definition>
                                       <Charting:HorizontalStackedBarSeriesDefinition>
                                       </Charting:HorizontalStackedBarSeriesDefinition>
                                   </Charting:DataSeries.Definition>
                                   <Charting:DataPoint YValue="10"/>
                               </Charting:DataSeries>
                               <!-- Series 3 -->
                               <Charting:DataSeries LegendLabel="Series 3">
                                   <Charting:DataSeries.Definition>
                                       <Charting:HorizontalStackedBarSeriesDefinition>
                                       </Charting:HorizontalStackedBarSeriesDefinition>
                                   </Charting:DataSeries.Definition>
                                   <Charting:DataPoint YValue="40"/>
                               </Charting:DataSeries>
                           </Charting:ChartArea.DataSeries>
                       </Charting:ChartArea>
                   </Charting:ChartDefaultView.ChartArea>
               </Charting:ChartDefaultView>
           </my:RadChart.DefaultView>
       </my:RadChart>
 
Additionally you can set custom color for each Series as shown in this help topic - http://www.telerik.com/help/silverlight/radchart-styling-and-appearance-styling-chart-series.html

Hope this helps.

Best wishes,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ebaker
Top achievements
Rank 1
answered on 27 Sep 2010, 03:33 PM
Thanks! That was exactly what I needed.

Eric
0
Abhishek
Top achievements
Rank 1
answered on 23 Aug 2011, 03:20 PM
Hi,
I have some other problems. I have to place 4 checkboxes on the chart as I have 4 series in a single stack bar. Now when i want to do filtering through the check boxes, as depending on the boxes to be checked the graph would show only those serieses.

Please give me some idea.

Thank you.
0
Evgenia
Telerik team
answered on 26 Aug 2011, 09:56 AM
Hi Abhishek,

Take a look at our demo with source code that will help you achieve your scenario.

Kind regards,
Evgenia
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Ammar
Top achievements
Rank 1
answered on 11 Aug 2015, 06:19 AM
What is namespace "my:" is referring to ? ,in the example you posted.
0
Evgenia
Telerik team
answered on 12 Aug 2015, 07:19 AM
Hello Eric,

I was not able to find the namespace you mentioned in the source code of the demo. Are we looking at one and the same online example? I would be helpful if you could send us a code snippet where this namespace is used.

Let me know if you need a runnable version of one of our online demos and we'll provide it.

Regards,
Evgenia
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
ebaker
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
ebaker
Top achievements
Rank 1
Abhishek
Top achievements
Rank 1
Ammar
Top achievements
Rank 1
Share this question
or