This project is read-only.
System.Windows.Forms.DataVisualization.Charting.Chart and Microsoft Research D3 Chart


There are at least two valid options for charting in WPF: the WinForms Chart (hosted in WPF) and the more native Microsoft Research D3 Chart.

In the Demo App, I show an example of displaying an animated chart using the WinForms System.Windows.Forms.DataVisualization.Charting.Chart class.

Note that it is important to dispose the WinForms host control when using this approach; otherwise, you may encounter a memory leak?

In the WPF Composites Contrib project, I also show an example of using Microsoft Research's Dynamic Data Display chart. See source here:

Here is the code snippet from the Contrib project:

    public class VoltagePointCollection : RingArray<VoltagePoint>
        private const int TOTAL_POINTS = 300;

        public VoltagePointCollection()
            : base(TOTAL_POINTS) 

    public class VoltagePoint
        public DateTime Date { get; set; }

        public double Voltage { get; set; }

        public VoltagePoint(double voltage, DateTime date)
            this.Date = date;
            this.Voltage = voltage;

  ChartPlotter crp = new ChartPlotter();
            IPlotterElement horizAxis = new Microsoft.Research.DynamicDataDisplay.HorizontalAxisTitle() { Background = Brushes.AliceBlue, BorderBrush = Brushes.DarkBlue };
            VoltagePointCollection vpc = new VoltagePointCollection();
            vpc.Add(new VoltagePoint(1.0D, DateTime.Now.AddDays(1)));
            vpc.Add(new VoltagePoint(2.0D, DateTime.Now.AddDays(2)));
            vpc.Add(new VoltagePoint(7.0D, DateTime.Now.AddDays(3)));
            vpc.Add(new VoltagePoint(10.0D, DateTime.Now.AddDays(4)));

            var ds = new EnumerableDataSource<VoltagePoint>(vpc);
            ds.SetXMapping(x => (double)(x.Date.Day));
            ds.SetYMapping(y => y.Voltage);
            crp.AddLineGraph(ds, Colors.Green, 2, "Volts"); // to use this method you need to add manually "using Microsoft.Research.DynamicDataDisplay;"

            //Add to an IParent, in this case a UserControl
                  .AddLabel<UserControl>(0, 0, "I am a Chart", Brushes.LightGreen)
                  .AddExisting(0, 2, crp)
                  .EndComposite<UserControl, UserControlArgs>(null);     

Last edited Jun 2, 2014 at 6:09 AM by stagathome0069, version 5


No comments yet.