Jump to content
Software FX Community

XYZ Scatter


Recommended Posts

I'm looking for just a simple XYZ scatter example.  I see plenty of examples for contour but I'm looking for just a simple xyz scatter.  When I attemp to create one myself I get an error stating that "The current chart gallery settings is inconsistent with the number of series in your data.  Some gallery types require a specific number of series."

ScatterXYZ x = new ScatterXYZ();

chart1.View3D.IsEnabled = true;

chart1.AllSeries.GalleryAttributes = x;

//if i remove everything below then i get exactly what i want with the default data.

//i just want to send my own xyz values and get a simple xyz scatter plot


chart1.Series.Add(new SeriesAttributes());

chart1.Series[0].ItemsSource = GetData();

Link to comment
Share on other sites

ScatterXYZ needs 2 series. The first series should have X and Y values while the second series Y data will be used as the Z values, e.g.

List<XYZData> xyzData = new List<XYZData>();

xyzData.Add(new XYZData(1,1,2));



chart1.Series.Add(new SeriesAttributes() { BindingPath = "Y", BindingPathX = "X" });

chart1.Series.Add(new SeriesAttributes() { BindingPath = "Z" });

chart1.ItemsSource = xyzData;

Note that we are assigning the data on a per-chart basis as you will probably have your XYZ information in a single list. In the sample I am assuming the XYZData class has 3 numeric properties called X, Y and Z. Although you could pass the data on a per series basis you will still need to "combine" X and Y in a single list so it is not possible to pass 3 double arrays.

If you need multiple sets of XYZ scatters, i.e. you have 2 lists of XYZ data you need to pass then you would do something like this


chart1.Series.Add(new SeriesAttributes() { BindingPath = "Y", BindingPathX = "X", ItemsSource=xyzData1 });

chart1.Series.Add(new SeriesAttributes() { BindingPath = "Z", ItemsSource=xyzData1 });

chart1.Series.Add(new SeriesAttributes() { BindingPath = "Y", BindingPathX = "X", ItemsSource=xyzData2 });

chart1.Series.Add(new SeriesAttributes() { BindingPath = "Z", ItemsSource=xyzData2 });


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...