Over a million developers have joined DZone.

How To: Plot Graphs in WPF

DZone's Guide to

How To: Plot Graphs in WPF

· Database Zone ·
Free Resource

Download the Altoros NoSQL Performance Benchmark 2018. Compare top NoSQL solutions – Couchbase Server v5.5, MongoDB v3.6, and DataStax Enterprise v6 (Cassandra).

Plotting a graph from a set of test-related data is a common software-development task. In my experience, the most common approach is to import data into an Excel spreadsheet, then produce the graph manually using the Excel built-in graphing features. This works well in most situations, but if the underlying data changes frequently, creating graphs by hand can quickly become tedious.
You can automate the process using Windows Presentation Foundation (WPF) technology.

Preparing the Project for Graph Plotting 
Launch Visual Studio and create a new C# project using the WPF Application template. Although you can programmatically generate graphs using WPF primitives, I suggest using the convenient Dynamic Data Display (D3) library developed by a Microsoft Research lab.

You can download the library for free from the CodePlex open source hosting site at codeplex.com/dynamicdatadisplay. You should save a copy of this library in the root directory of your project, then add a reference to the DLL in your project by right-clicking on the project name, select the Add Reference option and point to the DLL file in your root directory.

Next you need to double-click on the file Window1.xaml to load the UI definitions for the project. You should add a reference to the graphic library DLL as follows:

Title="Window1" WindowState="Normal" Height="500" Width="800" Background="Wheat">

After that, you can add the key plotting object:

<d3:ChartPlotter Name="plotter" Margin="10,10,20,10">
    <d3:HorizontalDateTimeAxis Name="dateAxis"/>
    <d3:VerticalIntegerAxis Name="countAxis"/>

  <d3:Header FontFamily="Arial" Content="Bug Information"/>
  <d3:VerticalAxisTitle FontFamily="Arial" Content="Count"/>
  <d3:HorizontalAxisTitle FontFamily="Arial" Content="Date"/>

Download the whitepaper, Moving From Relational to NoSQL: How to Get Started. We’ll take you step by step through your first NoSQL project.

dotnet ,how-to ,microsoft ,tools ,visual studio ,data access ,net ,graphing

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}