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#)
 SimpleLinePlot - Lag when ploting 2 datapoints
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ghinojosa

14 Posts

Posted - 27 Dec 2006 :  19:06:52  Show Profile  Reply with Quote
I'm using the SimpleLinePlot and I noticed that when ploting only 2 datapoints the X axis displays a lag. For instance, for the case p1(x=0,y=21 and p2(x=1,y=14) the graph shows a line that goes from (0,21) to (2,14), which means that the second Y value is being ploted over X=2 instead of X=1. I check (debug) the SimpleLinePlot obj initialization and I'm using 2 double[] arrays with the same length (x[] and y[])

Also, I would like to know how can I display a mark on each datapoint eg. showing a diamond in (0,21), (1,14), etc.

quinncurtis

1164 Posts

Posted - 28 Dec 2006 :  09:29:58  Show Profile  Reply with Quote
What you describe doesn't sound right. We created a simple example program that uses the data you describe and it plots the data correctly. Modify your example to use this code and describe the results.

A SimpleLineMarkerPlot displays a symbol at each data point. See the manual and the example program ScatterPlots.LabeledDatapoints

		
private void InitializeChart()
{
	ChartView chartVu  = this;
	Font theFont;
	int  numPoints = 2;
	double []x1 = new double[numPoints];
	double []y1 = new double[numPoints];
	x1[0] = 0;
	x1[1] = 1;
	y1[0] = 21;
	y1[1] = 14;


	theFont = new Font("Microsoft Sans Serif", 10,  FontStyle.Bold);
	SimpleDataset Dataset1 = new SimpleDataset("First",x1,y1);

	CartesianCoordinates pTransform1 = new CartesianCoordinates( ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE);
	pTransform1.AutoScale(Dataset1, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR);

	pTransform1.SetGraphBorderDiagonal(0.15, .15, .90, 0.725) ;

	Background background = new Background( pTransform1, ChartObj.PLOT_BACKGROUND, Color.White);
	chartVu.AddChartObject(background);

	LinearAxis xAxis = new LinearAxis(pTransform1, ChartObj.X_AXIS);
	chartVu.AddChartObject(xAxis);

	LinearAxis yAxis = new LinearAxis(pTransform1, ChartObj.Y_AXIS);
	chartVu.AddChartObject(yAxis);

	NumericAxisLabels xAxisLab = new NumericAxisLabels(xAxis);
	xAxisLab.SetTextFont(theFont);
	chartVu.AddChartObject(xAxisLab);

	NumericAxisLabels yAxisLab = new NumericAxisLabels(yAxis);
	yAxisLab.SetTextFont(theFont);
	chartVu.AddChartObject(yAxisLab);

	chartAttribute attrib1 = new ChartAttribute (Color.Green, 3,DashStyle.Solid);
	SimpleLinePlot thePlot1 = new SimpleLinePlot(pTransform1, Dataset1, attrib1);
	chartVu.AddChartObject(thePlot1);


}
Go to Top of Page

ghinojosa

14 Posts

Posted - 28 Dec 2006 :  10:46:55  Show Profile  Reply with Quote
This works great, and is pretty much what I've been coding. The difference is that I'm using StringAxisLabels for the xAxis, so instead of having these three lines:

NumericAxisLabels xAxisLab = new NumericAxisLabels(xAxis);
xAxisLab.SetTextFont(theFont);
chartVu.AddChartObject(xAxisLab);

I have:

StringAxisLabels xAxisLab = new StringAxisLabels(xAxis);
xAxisLab.SetAxisLabelsStrings(xValues, xValues.Length);
xAxisLab.SetTextFont(theFont);
chartVu.AddChartObject(xAxisLab);

where xValues is a string array of length = 2.

And still doesn't work. I guess this has something to do with the major tick marks of the LinearAxis (xAxis), but I haven't figured it out yet. Probably the first element of the string array is being drawn on x=0.0, but the second on x=0.5 instead of x=1.0. Any ideas?
Go to Top of Page

quinncurtis

1164 Posts

Posted - 28 Dec 2006 :  11:10:54  Show Profile  Reply with Quote
You are correct; your string labels are incorrect for the tick marks you are labeling. The major tick mark you are labeling with the string "1" is actually at x=0.5 . If you just want major tick marks, appropriate for your string labels, at an interval of 1.0, create your x-axis using:

LinearAxis xAxis = new LinearAxis(pTransform1, ChartObj.X_AXIS);
xAxis.AxisTickSpace = 1;
xAxis.AxisMinorTicksPerMajor = 1;
chartVu.AddChartObject(xAxis);

Go to Top of Page

ghinojosa

14 Posts

Posted - 28 Dec 2006 :  12:19:20  Show Profile  Reply with Quote
awesome! this is what I wanted in first place. Thank you.
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