Help a new user to D3 for simple XY scatter plots.

Aug 23, 2010 at 1:26 PM
Dear D3 Community. I wish to use the D3 plotting libraries to make simple XY scatter plots. I am familiar with c#, but have little experience with the D3 packages, or plotting libraries with c#. Could someone kindly offer me some advice or recommend a document on how to do this? I have looked through the Wiki, Tweets, and discussions, but these are too specific/advanced. I am running MS visual Studio with .NET 4. I have referenced D3 with “using Microsoft.Research.DynamicDataDisplay;” and can created new instances of the class’ the library provides. I can look through the names of these classes, but cannot view detailed meta-data (F12) or figure out what class to use first. Any advice would be appreciated, either here or to my email, dpooley@gmail.com Daniel. P.S is anyone in the community feels that the D3 are too advanced for my needs, any recommendations for simple, FREE, plotting libraries would be appreciated.
Aug 23, 2010 at 9:02 PM

Have you looked at the samples that are part of the DynamicDataDisplay solution?

For example, HelloWorldSample demonstrates a simple line graph and MarkersSample demonstrates marker plots.  There are 10's of sample projects which show most features in D3.

 

Main XAML & code from HelloWorldSample

XAML

<d3:ChartPlotter Name="plotter">
        <d3:Header TextBlock.FontSize="20">
            Very simple chart
        </d3:Header>

        <d3:VerticalAxisTitle>Sine value</d3:VerticalAxisTitle>
        <d3:HorizontalAxisTitle>Sine argument</d3:HorizontalAxisTitle>
    </d3:ChartPlotter>

Code

using Microsoft.Research.DynamicDataDisplay;
using Microsoft.Research.DynamicDataDisplay.DataSources;
using Microsoft.Research.DynamicDataDisplay.PointMarkers;

	public MainWindow()
		{
			InitializeComponent();

			Loaded += new RoutedEventHandler(MainWindow_Loaded);
		}

		void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			// Prepare data in arrays
			const int N = 1000;
			double[] x = new double[N];
			double[] y = new double[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Sin(x[i]);
			}

			// Create data sources:
			var xDataSource = x.AsXDataSource();
			var yDataSource = y.AsYDataSource();

			CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);
			// adding graph to plotter
			plotter.AddLineGraph(compositeDataSource,
				Colors.Goldenrod,
				3,
				"Sine");

			// Force evertyhing plotted to be visible
			plotter.FitToView();
		}

 

Aug 24, 2010 at 8:09 AM
Hello grantz Thank you for your useful information. I am afraid my problem is that I do not know how to view the c# code from the .exe example files provided in the sample folder. IF I could view this code, then my life would be much easier. Could you suggest how I view the c# code? Thank you again Daniel
Aug 24, 2010 at 1:45 PM

download the source code and examples from the link below

http://dynamicdatadisplay.codeplex.com/releases/view/26761

 

thanks

kishore vanapalli

Sep 23, 2013 at 9:43 AM
Hello gratz,

thank you for this code, it helps me too.

Ottilie