Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:wpf:charting [2010/11/15 16:24] smayr |
swdev:dotnet:wpf:charting [2010/11/16 15:55] (current) smayr |
||
---|---|---|---|
Line 1: | Line 1: | ||
== Charting == | == Charting == | ||
+ | |||
+ | == Using MS Chart == | ||
+ | * Create a WPF (.NET 4.0) project. | ||
+ | * Add Assembly references: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * Place a '' | ||
+ | * Place a '' | ||
+ | |||
+ | Create a bar chart: | ||
+ | <code xml> | ||
+ | <Window x: | ||
+ | xmlns=" | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | Title=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Add code behind to populate the chart: | ||
+ | <code csharp> | ||
+ | |||
+ | using System; | ||
+ | using System.Collections.Generic; | ||
+ | using System.Linq; | ||
+ | using System.Text; | ||
+ | using System.Windows; | ||
+ | using System.Windows.Controls; | ||
+ | using System.Windows.Data; | ||
+ | using System.Windows.Documents; | ||
+ | using System.Windows.Input; | ||
+ | using System.Windows.Media; | ||
+ | using System.Windows.Media.Imaging; | ||
+ | using System.Windows.Navigation; | ||
+ | using System.Windows.Shapes; | ||
+ | using System.Windows.Forms.DataVisualization.Charting; | ||
+ | |||
+ | namespace MSChart | ||
+ | { | ||
+ | /// < | ||
+ | /// Interaction logic for MainWindow.xaml | ||
+ | /// </ | ||
+ | public partial class MainWindow : Window | ||
+ | { | ||
+ | public MainWindow() | ||
+ | { | ||
+ | InitializeComponent(); | ||
+ | |||
+ | // Create Chart Area | ||
+ | ChartArea chartArea1 = new ChartArea(); | ||
+ | |||
+ | // Add Chart Area to the Chart | ||
+ | chart1.ChartAreas.Add(chartArea1); | ||
+ | |||
+ | // Create a data series | ||
+ | Series series1 = new Series(); | ||
+ | Series series2 = new Series(); | ||
+ | |||
+ | // Add data points to the first series | ||
+ | series1.Points.Add(34); | ||
+ | series1.Points.Add(24); | ||
+ | series1.Points.Add(32); | ||
+ | series1.Points.Add(28); | ||
+ | series1.Points.Add(44); | ||
+ | |||
+ | // Add data points to the second series | ||
+ | series2.Points.Add(14); | ||
+ | series2.Points.Add(44); | ||
+ | series2.Points.Add(24); | ||
+ | series2.Points.Add(32); | ||
+ | series2.Points.Add(28); | ||
+ | |||
+ | // Add series to the chart | ||
+ | chart1.Series.Add(series1); | ||
+ | chart1.Series.Add(series2); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | == Using WPFToolkit == | ||
Required | Required | ||
Line 10: | Line 99: | ||
xmlns=" | xmlns=" | ||
xmlns: | xmlns: | ||
- | | + | |
- | xmlns: | + | xmlns: |
Title=" | Title=" | ||
< | < | ||
Line 37: | Line 126: | ||
Source: [[http:// | Source: [[http:// | ||
+ | |||
+ | == References == | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// |