Example 34: XYZ scatter chart (C#)
This sampe code will plot
a bunch of points in 3D space using X/Y/Z
coordinates.
You can change X/Y/Z angles also (this
sample will rotate the charts over Y-Axis).
Steps:
1. Create a new Windows
application project (C#)
2. Add Super 2d/3d Graph
Library to the toolbox pallete and drag it
to Form1.
3. Copy and paste de
following code:
Form Code
using
System;
using
System.Drawing;
using
System.Windows.Forms;
using
Super2d3dGraphLibrary;
namespace
Tutorial33_XYZScatter
{
public
partial
class
Form1 :
Form
{
public Form1()
{
InitializeComponent();
}
private
void
Form1_Load(object
sender,
EventArgs
e)
{
int
x,y,z,k;
SeriesFactory
sf =
new
SeriesFactory();
for
(x = -10;x<=10;x+=2) {
for
(y = -10;y<=10;y+=2) {
for
(z = -10;z<=10;z+=2) {
sf.AddPoint(x, y,
z);
}
}
}
sf.NewSerie();
Random
rnd =
new
Random();
for
(k=0;k<=5;k++) {
x = rnd.Next(20)
- 10;
y = rnd.Next(20)
- 10;
z = rnd.Next(20)
- 10;
sf.AddPoint(x, y, z);
}
graph.LicenseeIdentifier =
"PROF";
graph.Style =
STYLE2D3D.STYLE3D_XYZ_SCATTER;
graph.WallsBackStyle =
STYLEWALLBACKGROUND.STYLEWALLBACKGROUND_TRANSPARENT;
graph.WallStyle =
STYLEWALLS.STYLEWALLS_BOXED;
graph.ShowDataTable =
false;
graph.ShowValues =
false;
graph.ShowXAxis =
true;
graph.ShowYAxis =
true;
graph.XAxisDividersCount = 2;
graph.YAxisDividersCount = 2;
graph.ZAxisDividersCount = 2;
graph.ShowDividersX =
true;
graph.ShowDividersZ =
true;
graph.ShowLegend =
false;
graph.YAxisAngle = (float)
Math.PI
/ 4;
graph.MarginLeft = 50;
graph.MarginRight = 50;
graph.SeriesColor =
new
Color[2]
{
Color.LightGreen,
Color.Red
};
graph.PointSize = 6;
graph.Series = sf.Series;
graph.RefreshChart();
timer1.Enabled
=
true;
}
private
void
timer1_Tick(object
sender,
EventArgs
e)
{
graph.YAxisAngle += 0.01F;
graph.RefreshChart();
}
}
}
Result:

|