Syncfusion Feedback


Overview

The WPF 100% stacked bar chart displays multiple series of data as stacked bars, ensuring that the cumulative proportion of each stacked element always totals 100%. Thus, the y-axis will always render within the range 0–100. This chart type is best suited for depicting the relative contribution of data points.

WPF 100 Percentage Stacked Bar Chart documentation

WPF 100 Percentage Stacked Bar Chart


Key features

WPF Vertical Stacked Bar Chart

Vertical chart

Rotate the WPF 100% stacked bar chart to plot data vertically and view it from a different perspective.

WPF Stacked Bar Chart showing Spacing between Bars

Spacing and width

Customize the spacing between two bars and the width of the bar.

WPF Grouped Stacked Bar Chart

Grouped stacked chart

Group a series with another series separately using a different group name.

WPF Stacked Bar Chart with Customized Border and Color

UI styling

Customize the color and border of the chart using built-in APIs to make it visually unique.


Code example

Easily get started with the WPF 100% Stacked Bar Chart using a few simple lines of C# code example as demonstrated below,

  1. <Window x:Class="ChartExample.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:local="clr-namespace:ChartExample"
  7. xmlns:chart="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF"
  8. mc:Ignorable="d"
  9. Title="WPF 100% Stacked Bar Chart" Height="450" Width="700">
  10. <!--Setting DataContext-->
  11. <Window.DataContext>
  12. <local:ViewModel/>
  13. </Window.DataContext>
  14. <StackPanel>
  15. <chart:SfChart Height="300" Width="500">
  16. <!--Initialize the horizontal axis for the WPF Chart-->
  17. <chart:SfChart.PrimaryAxis>
  18. <chart:DateTimeAxis LabelFormat="ddd" />
  19. </chart:SfChart.PrimaryAxis>
  20. <!--Initialize the vertical axis for the WPF Chart-->
  21. <chart:SfChart.SecondaryAxis>
  22. <chart:NumericalAxis />
  23. </chart:SfChart.SecondaryAxis>
  24.  
  25. <!--Adding 100% Stacked Bar Series to the SfChart-->
  26.  
  27. <chart:StackingBar100Series
  28. ItemsSource="{Binding Accidents}"
  29. StrokeThickness="3"
  30. XBindingPath="Month"
  31. YBindingPath="Bus">
  32. </chart:StackingBar100Series>
  33.  
  34. <chart:StackingBar100Series
  35. ItemsSource="{Binding Accidents}"
  36. StrokeThickness="3"
  37. XBindingPath="Month"
  38. YBindingPath="Car">
  39. </chart:StackingBar100Series>
  40.  
  41. <chart:StackingBar100Series
  42. ItemsSource="{Binding Accidents}"
  43. StrokeThickness="3"
  44. XBindingPath="Month"
  45. YBindingPath="Truck">
  46. </chart:StackingBar100Series>
  47. </chart:SfChart>
  48. </StackPanel>
  49. </Window>
  1. public class StackingBarChartModel
  2. {
  3. public DateTime Month { get; set; }
  4. public double Bus { get; set; }
  5. public double Car { get; set; }
  6. public double Truck { get; set; }
  7. }
  8.  
  9. public class ViewModel
  10. {
  11. public ObservableCollection<StackingBarChartModel> Accidents
  12. {
  13. get;
  14. set;
  15. }
  16.  
  17. public ViewModel()
  18. {
  19. this.Accidents = new ObservableCollection<StackingBarChartModel>();
  20. DateTime mth = new DateTime(2011, 1, 1);
  21.  
  22. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(6), Bus = 3, Car = 4, Truck = 5 });
  23. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(7), Bus = 4, Car = 5, Truck = 6 });
  24. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(8), Bus = 3, Car = 4, Truck = 5 });
  25. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(9), Bus = 4, Car = 5, Truck = 6 });
  26. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(10), Bus = 7, Car = 8, Truck = 7 });
  27. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(11), Bus = 4, Car = 5, Truck = 6 });
  28. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(12), Bus = 7, Car = 8, Truck = 7 });
  29. Accidents.Add(new StackingBarChartModel() { Month = mth.AddMonths(13), Bus = 4, Car = 5, Truck = 6 });
  30. }
  31. }

Learning resources

Navigate to GitHub code used to configure the WPF one hundred percent stacked bar chart

GitHub code

The WPF 100% Stacked Bar Chart configuration code is available in GitHub.

Navigate to the options available in the user guide to customize the WPF one hundred percent stacked bar chart

WPF 100% Stacked Bar Chart User Guide

Learn more about the available options to customize WPF 100% Stacked Bar Charts.

Navigate to the API references documentation of the WPF one hundred percent stacked bar chart.

WPF 100% Stacked Bar Chart API reference

Explore the WPF 100% Stacked Bar Chart APIs.

95+ WPF CONTROLS

Scroll up icon
Chat with us