Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Can this be done? Dynamic CG Plot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

soundar

32 Posts

Posted - 23 Jul 2008 :  21:18:09  Show Profile  Reply with Quote
I want to use the real-Time graph to plot the change in center of gravity of an object dynamically. The graph will look like the RTXYPlot( Lissajuos figures) example with one difference. I want the latest point alone to be shown with a big round marker and all the previous points (in time) with just a point. (Just like a swarm of bees following the queen bee which is shown bigger!)

Can this be done?

quinncurtis

1164 Posts

Posted - 24 Jul 2008 :  09:52:20  Show Profile  Reply with Quote
You can add a SimpleScatterPlot with only one data point to the RTXYPlot, highlighting the last point.

Dim lineplot1 As New SimpleLinePlot(pTransform1, Nothing, attrib1)
lineplot1.SetFastClipMode(ChartObj.FASTCLIP_X)
rtPlot1 = New RTSimpleSingleValuePlot(pTransform1, lineplot1, inputChannel1)
chartVu.AddChartObject(rtPlot1)
Dim lineplot2 As New SimpleLinePlot(pTransform1, Nothing, attrib2)
lineplot2.SetFastClipMode(ChartObj.FASTCLIP_X)
rtPlot2 = New RTSimpleSingleValuePlot(pTransform1, lineplot2, inputChannel2)
chartVu.AddChartObject(rtPlot2)

' ADD THE FOLLOWING CODE to RTXYPLOT.InitializeGraph1

Dim scatterattrib As New ChartAttribute(Color.Green, 1, DashStyle.Solid, Color.Green)
scatterattrib.SymbolSize = 16
Dim xvalues As Double() = {0}
Dim yvalues As Double() = {0}

'scatterdataset defined global to the class as
'Dim scattterdataset As SimpleDataset = Nothing
'So that it can be accessed in update routine

scatterdataset = New SimpleDataset("Scatterdata", xvalues, yvalues)
Dim scatterplot As SimpleScatterPlot = New SimpleScatterPlot(pTransform1, scatterdataset, ChartObj.CIRCLE, scatterattrib)
chartVu.AddChartObject(scatterplot)


Then just update the single value of the scatter plot dataset with the most recent value, each time you update the display.

For i As Integer = 0 To 4
    r = CDbl(counter)
   
    x = 8 * Math.Cos(r / 8)
    inputChannelValue1 = 5 * Math.Sin((r + timejitter1) / 17)
    inputChannel1.SetCurrentValue(x, inputChannelValue1)
   
    x = 5 * Math.Cos((r + 3) / 5)
    inputChannelValue2 = 8 * Math.Sin((r + timejitter2) / 12)
    inputChannel2.SetCurrentValue(x, inputChannelValue2)
    counter += 1
Next

' ADD THE FOLLOWING CODE to InitializeData

' Update of scatter plot value
If scatterdataset IsNot Nothing Then
    scatterdataset.SetDataPoint(0, New Point2D(x, inputChannelValue2))
End If


Or for C# programmers

SimpleLinePlot lineplot1 =  new SimpleLinePlot(pTransform1, null, attrib1);
lineplot1.SetFastClipMode( ChartObj.FASTCLIP_X);
rtPlot1 = new RTSimpleSingleValuePlot(pTransform1,lineplot1, inputChannel1);
chartVu.AddChartObject(rtPlot1);			

SimpleLinePlot lineplot2 =  new SimpleLinePlot(pTransform1, null, attrib2);
lineplot2.SetFastClipMode( ChartObj.FASTCLIP_X);
rtPlot2 = new RTSimpleSingleValuePlot(pTransform1,lineplot2, inputChannel2);
chartVu.AddChartObject(rtPlot2);	

// ADD THE FOLLOWING CODE to RTXYPLOT.InitializeGraph1

ChartAttribute  scatterattrib = new ChartAttribute(Color.Green, 1, DashStyle.Solid, Color.Green);
scatterattrib.SymbolSize = 16;
double [] xvalues = {0};
double [] yvalues = {0};

// scatterdataset defined global to the class as
// SimpleDataset scatterdataset = null;
// So that it can be accessed in update routine

scatterdataset = new SimpleDataset("Scatterdata", xvalues, yvalues);
SimpleScatterPlot scatterplot = new SimpleScatterPlot(pTransform1, scatterdataset, ChartObj.CIRCLE, scatterattrib);
chartVu.AddChartObject(scatterplot);



Then just update the single value of the scatter plot dataset with the most recent value, each time you update the display.

for (int i=0; i < 5; i++)
{
	r = (double) counter;
	x = 8 * Math.Cos(r/8);
	inputChannelValue1 = 5.0 * Math.Sin((r+timejitter1)/17);
	inputChannel1.SetCurrentValue(x,inputChannelValue1);
	x = 5 * Math.Cos((r+3)/5.0);
	inputChannelValue2 = 8.0 * Math.Sin((r + timejitter2)/12);
	inputChannel2.SetCurrentValue(x,inputChannelValue2);
	counter++;
}

// ADD THE FOLLOWING CODE to InitializeData

// Update of scatter plot value
if (scatterdataset != null)
{
  scatterdataset.SetDataPoint(0, new Point2D(x,inputChannelValue2));
}
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07