This project is read-only.

Retrieving data points currently in view

Jun 6, 2010 at 3:09 AM

Hi D3 team,

The Dynamic Data Display control is great. I've had a lot of success using it in various applications over the last couple of years. Thanks for your hard work!

I was wondering if you could give me some guidance about the best way to retrieve the data points that are currently being displayed. For example, I would like to make a control that will anable the user to click a button and calculate the mean, standard deviation, and other statistics for all of the data points that are currently being displayed in the plotter. So if the user changes the plotter to display different points, and then clicks the button, they will see an updated set of statistics for the new set of points that are being displayed.

I appreciate your help!

Jun 10, 2010 at 9:00 PM

You would be calculating the mean, standard deviation, and other statistics on the data set you provide to the chart. For example, from the IntensityChart nightlies, here is some code that generates the data set used as the source for the plot:

private void Window1_Loaded(object sender, RoutedEventArgs e)
	data = BuildSampleData(imageSize);

	NaiveColorMap map = new NaiveColorMap { Data = data, Palette = UniformLinearPalettes.BlackAndWhitePalette };
	var bmp = map.BuildImage();
	image.Source = bmp;

private double[,] BuildSampleData(int size)
	double[,] data = new double[size, size];

	for (int ix = 0; ix < size; ix++)
		for (int iy = 0; iy < size; iy++)
			double value = Math.Sin(0.05 * ix + 0.07 * iy);
			data[ix, iy] = value;

	return data;

"data" is what you would perform your calculations on, not something from the plotter. The plotter uses interpolation and there could be an infinite set of points displayed depending on the precision you specify.




Jun 11, 2010 at 4:02 AM

Thanks for the response. I don't think that would quite have the effect that I am looking for, since it relies on a generating the data every time, based on some kind of arbitrary input. I'm looking to compute the characteristics of the visible portion of a static set of data (measured points from real world sensors.) Here's my solution that gets the job done, but perhaps has room for some kind of efficiency improvements:

List<double> x_points = new List<double>();
List<double> y_points = new List<double>();
for (int index = 0; index < this._x_data.Length; index++)
  if (this._x_data[index] >= this._plotter.VisibleRect.X1 &&
  this._x_data[index] <= this._plotter.VisibleRect.X2 &&
  this._y_data[index] >= this._plotter.VisibleRect.Y1 &&
  this._y_data[index] <= this._plotter.VisibleRect.Y2)
// compute statistics on x_points and y_points

_plotter is of type GenericChartPlotter<double, double>.

Also, its not quite clear when to call this. I'd like the stats to update whenever the points that are displayed in the plotter viewport changes, but the Viewport.SizeChanged event doesn't always seem to fire.

In any case, I have a working solution, but any recommendations about optimizing it are welcome. :)