Example 51: XYZ random 3d lines
This sampe code will plot
a serie of random lines (continuous line or
individual/fragmented lines).
Steps:
1. Create a new Windows
application project (C#) and name it
Tutorial51_Random3dLines.
Name it Tutorial51_Random3dLines.
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.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Super2d3dGraphLibrary;
namespace
Tutorial51_Random3dLines
{
public
partial
class
Form1 :
Form
{
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(object
sender,
EventArgs
e)
{
// Initial setup
super2d3dGraph1.Style =
STYLE2D3D.STYLE3D_XYZ_LINE;
super2d3dGraph1.Title =
"Random 3D lines sample";
super2d3dGraph1.ShowValues =
false;
super2d3dGraph1.ShowLegend =
false;
super2d3dGraph1.ShowDataTable =
false;
// Assign random data
SeriesFactory
sf =
new
SeriesFactory();
Random
rnd =
new
Random();
for (int
k = 0; k < 20; k++)
{
float
x0 = rnd.Next(100);
float
y0 = rnd.Next(100);
float
z0 = rnd.Next(100);
float
x1 = rnd.Next(100);
float
y1 = rnd.Next(100);
float
z1 = rnd.Next(100);
sf.AddLine(x0, y0, z0, x1, y1, z1);
// to make discontinued lines, remove the
followint comment
//sf.NewSerie();
}
sf.ApplyTo(super2d3dGraph1);
super2d3dGraph1.SetAllSeriesLineStyle(new
Pen(Color.Black,
2));
// Axis config
super2d3dGraph1.ShowDividersX =
true;
super2d3dGraph1.ShowXAxis =
true;
super2d3dGraph1.YAxisNumericFormat =
"0";
super2d3dGraph1.XAxisNumericFormat =
"0";
super2d3dGraph1.ZAxisNumericFormat =
"0";
// Refresh
super2d3dGraph1.RefreshChart();
}
}
}
Result:

|