Tutorial 51: XYZ random 3d lines
« on: February 05, 2016, 01:33:19 AM »
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 Crossing Charts Library to the toolbox palette and drag it to Form1.
3. Copy and paste de following code:

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrossingChartsLibrary;
namespace Tutorial51_Random3dLines
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
      // Initial setup
      CrossingCharts1.Style = STYLE2D3D.STYLE3D_XYZ_LINE;
      CrossingCharts1.Title = "Random 3D lines sample";
      CrossingCharts1.ShowValues = false;
      CrossingCharts1.ShowLegend = false;
      CrossingCharts1.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(CrossingCharts1);
      CrossingCharts1.SetAllSeriesLineStyle(new Pen(Color.Black, 2));
      // Axis config
      CrossingCharts1.ShowDividersX = true;
      CrossingCharts1.ShowXAxis = true;
      CrossingCharts1.YAxisNumericFormat = "0";
      CrossingCharts1.XAxisNumericFormat = "0";
      CrossingCharts1.ZAxisNumericFormat = "0";
      // Refresh
      CrossingCharts1.RefreshChart();
    }
  }
}

Results:

« Last Edit: February 16, 2016, 11:22:28 AM by CrossingCharts »