Skip to content

A WPF control library for responsive column, line, and pie charts

Notifications You must be signed in to change notification settings

JMHeartley/WPF-Chart-Controls

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📈 WPF Chart Controls 📊

A WPF control library for responsive column, line, and pie charts.

NuGet Version GitHub contributors GitHub last commit

🖥️ Demo

Check out the Example project

📊 2D Column Chart

Usage

  1. Import the namespace
xmlns:wpfChartControls="clr-namespace:WPFChartControls;assembly=WPFChartControls"
  1. Add chart
<wpfChartControls:_2DColumnChart />
  1. Bind data to Items property
    • using code-behind
    <wpfChartControls:_2DColumnChart x:Name="ColumnChart" />
    ColumnChart.Items = TestColumnItems.Case4;
    • using attribute binding
    <wpfChartControls:_2DColumnChart Items="{Binding Items}" />

Properties

  • Items - collection of ColumnItem items to be displayed in the chart
  • ColumnBrush - brush used for the ColumnItem items
  • Stroke - brush used to draw the axis and lines
  • StrokeThickness - thickness of the axis and lines
  • IntervalCount - number of intervals to be displayed on the Y-axis
  • InnerPadding - inner padding of the chart area

Related Objects

  • ColumnItem - an item in the column chart with a Header and Value
  • TestColumnItems - provides test case collections of ColumnItem instances

🥧 2D Pie Chart

Usage

  1. Import the namespace
xmlns:wpfChartControls="clr-namespace:WPFChartControls;assembly=WPFChartControls"
  1. Add chart
<wpfChartControls:_2DColumnChart />
  1. Bind data to Items property
    • using code-behind
    <wpfChartControls:_2DPieChart x:Name="PieChart" />
    PieChart.Categories = TestPieCategories.Case6;
    • using attribute binding
    <wpfChartControls:_2DPieChart Categories="{Binding Categories}" />

Properties

  • Categories - collection of PieCategory items to be displayed in the chart
  • StrokeBrush - brush used to draw the strokes of the pie slices
  • StrokeThickness - thickness of the strokes of the pie slices
  • LegendPosition - position of the legend relative to the chart

Related Objects

  • PieCategory - a category in a pie chart with a Percentage, Title, and ColorBrush
  • LegendPosition - position of the legend (values: Top, Left, Right, Bottom)
  • TestPieCategories - provides test case collections of PieCategory instances

📈 Line Chart

Usage

  1. Import the namespace
xmlns:wpfChartControls="clr-namespace:WPFChartControls;assembly=WPFChartControls"
  1. Add chart
<wpfChartControls:_2DColumnChart />
  1. Bind data to Items property
    • using code-behind
    <wpfChartControls:LineChart x:Name="LineChart" />
    LineChart.Values = TestLineValues.Case3;
    • using attribute binding
    <wpfChartControls:LineChart Values="{Binding Values}" />

Properties

  • Values - collection of LineValue items to be displayed in the chart
  • AxisStrokeBrush - brush used to draw the axis strokes
  • AxisStrokeThickness - thickness of the axis strokes
  • GridLineStrokeBrush - brush used to draw the grid lines
  • GridLineStrokeThickness - thickness of the grid lines
  • GridLineOpacity - opacity of the grid lines
  • InnerPadding - inner padding of the chart area
  • ValueLineStrokeBrush - brush used to draw the value line
  • ValueLineStrokeThickness - thickness of the value line
  • XIntervalCount - number of intervals to be displayed on the X-axis
  • YIntervalCount - number of intervals to be displayed on the Y-axis

Related Objects

  • LineValue - a value in a line chart with X and Y coordinates
  • TestLineValues - provides test case collections of LineValue instances

💪🏾 Credits

Thank you to Kareem Sulthan, who shared the code that became the foundation of WPF Chart Controls.

From there I did lots of refactoring, made each chart adjust sizing when the window height/width is changed, and added documentation comments to increase reusability.