Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

zed graph plotting.......

Status
Not open for further replies.

jit_singh_tara

Full Member level 6
Joined
Dec 22, 2006
Messages
325
Helped
9
Reputation
18
Reaction score
4
Trophy points
1,298
Location
Delhi , India
Activity points
4,293
Dear friends,


I am using zed graph to read 3 bytes of data from serial port, the plot the graph using zedgraph......
I am not able to clear the line from (0,0) to the current last location , Please suggest to remove the line , i want the actual x,y plot only.......

My important capturing function is highlighted and is in bold text:






zed graph plotting........JPG


My code is :


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.IO.Ports;
using ZedGraph;





namespace zedgraph3
{
public partial class Form1 : Form
{
// Open the port for communications
byte[] serdata = new byte[10];

double[] x = new double[10000];
double[] y = new double[10000];
//double[] z = new double[10000];

//double[] temp = new double[200];
int i=0 , l=0,m=0,n=0;
int temp1 = 0;
byte data_act = 0,data0=0,data1=0,data2=0;

byte match_flag = 0,attempt = 0;

//SerialPort port = new SerialPort("COM7", 9600, Parity.None, 8, StopBits.One);

int hours, mins, seconds=0;



public Form1()
{
InitializeComponent();

foreach (string s in SerialPort.GetPortNames())
MessageBox.Show(s.ToString());
}


System.IO.Ports.SerialPort port;
static public double voltage;
static public string portname;
static public Parity parity;
static public int BaudRate;
static public StopBits stopbits;
public int databits;


private void Form1_Load(object sender, EventArgs e)
{
portname = "COM7";
parity = Parity.None;
BaudRate = 9600;
stopbits = StopBits.Two;
databits = 8;

port = new System.IO.Ports.SerialPort(portname);
port.Parity = parity;
port.BaudRate = BaudRate;
port.StopBits = stopbits;
port.DataBits = databits;
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
port.Open();
}








void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// read one byte data into bt


port.Read(serdata , 0 ,1);


data_act = serdata[0];






i++;
if (i > 9999)
{ i = 0; }



if ((data_act == '$') && (match_flag == 0))
{ match_flag = 1;}

if ((match_flag == 1) && (data_act != '$'))
{ data1 = data_act; m = data1; match_flag = 2; }

if ((match_flag == 2) && (data_act != '$'))
{
if (attempt == 1)
{
data2 = data_act; n = data2;
temp1 = data1;
temp1 = temp1 << 8;
temp1 = temp1 | data2;
match_flag = 0; attempt = 0;
}
else
{ attempt = 1; }

}






//label4.Text = temp1.ToString() + " counts";



x = Convert.ToDouble(i);
y = Convert.ToDouble(temp1);
// y = Convert.ToDouble(serdata[0]);



zedGraphControl1.GraphPane.CurveList.Clear();

// GraphPane object holds one or more Curve objects (or plots)
GraphPane myPane = zedGraphControl1.GraphPane;


myPane.Title.Text = "Load cell data plotting";
myPane.XAxis.Title.Text = "Time(ms)";
myPane.YAxis.Title.Text = "Weight(gms)";
// myPane.YAxis.Scale.MagAuto = false;


// PointPairList holds the data for plotting, X and Y arrays
PointPairList spl1 = new PointPairList(x, y);











// RollingPointPairList aaa = new RollingPointPairList(i);


// Add curves to myPane object
LineItem myCurve = myPane.AddCurve("ADC", spl1, Color.Red, SymbolType.None);

//myCurve.Line.IsVisible = false;
myCurve.Line.Width = 1.0F;




// LineItem myCurve = myPane.AddCurve("ADC", aaa, Color.Blue, SymbolType.None);
// BarItem mybar = myPane.AddBar("plotting", x , y, Color.Red);






// I add all three functions just to be sure it refeshes the plot.
zedGraphControl1.AxisChange();
//zedGraphControl1.Refresh();
zedGraphControl1.Invalidate();
}



Please suggest how to remove that line .......
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top