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#)
 Axis Scaling for data calibration
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Malb

2 Posts

Posted - 08 Jan 2007 :  21:05:57  Show Profile  Reply with Quote
I am trying to scale an axis where I am plotting raw data values and wish to draw the axis scale using a different number range. In all methods I have tried the axis is always drawn according to the values contained in the dataset. For example, the data in the X array ranges from 0 to 4095 and I wish to label the axis from 100.0 to 200.0 but plot all the values across the whole range. Methods I have tried plot just the values between 100 and 200, or, all the data and the axis only gets drawn between 100 and 200 on a small section of the axis. The only way I have found is to plot a dataless axis as well as this one and turn off axis plotting on this one, bu this is not a good general solution as I want a reproduceable method. I cannot find an example which specifically performs this type of scaling. Its a simple, very basic thing and I may have missed it.

On the CartesianCoordinates object I have tried:
pTransform.SetScaleStartX(100.0);
pTransform.SetScaleStopX(200.0);
pTransform.SetXScale(100.0, 200.0);
pTransform.SetPhysPlotScale(,);
pTransform.SetPhysScale(100,-10,200,10);
pTransform.SetWorldScale(100,-10,200,10);
pTransform.SetCoordinateBounds(100,-10,200,10);

And on the CartesianCoordinates object I have tried:
xAxis.SetAxisLimits(200,400);
xAxis.SetAxisMax(400);
xAxis.SetAxisMin(200);

quinncurtis

1164 Posts

Posted - 09 Jan 2007 :  09:00:11  Show Profile  Reply with Quote
Actually, we have several examples of exactly what you describe: see FormControlsExamples.LinePlotScrollBar (for numeric data) and FinancialExamples.OHLCChart for time/date date), both which demonstrate how to pan a graph window across a large dataset.


All you need to do is call the SetScaleStartX and SetScaleStopX methods, as you show.

Your example values

pTransform.SetScaleStartX(100.0);
pTransform.SetScaleStopX(200.0);

are in fact exactly the same values used in the FormControlsExamples.LinePlotScrollBar example.

It is useful to change the x-scale range AFTER you auto-scale the CartesianCoordinates object using the dataset(s). That way you keep the auto-scaled y-scale range, while explicitly setting the x-scale range.

Assuming that you set the minimum and maximum range of the CartesianCoordinates object BEFORE you create the LinearAxis object, the LinearAxis object will auto-scale to fit the adjusted range of the CartesianCoordinate object.

If you change the scale of the CartesianCoordinates object AFTER you create the related Axis object, in response to a scroll bar event for example, you must call the Axis objects CalcAutoAxis to have the axis synchronize to the scale. That is what the UpdateXScaleAndAxes method of the FormControlExamples.LinePlotScrollBar example does.

public void UpdateXScaleAndAxes(int index)
{
	int startindex = index;
	pTransform1.SetScaleStartX( (double) startindex);
	pTransform1.SetScaleStopX( (double) (startindex + 100));
	xAxis.CalcAutoAxis();
	yAxis.CalcAutoAxis();
	xAxisLab.CalcAutoAxisLabels();
	yAxisLab.CalcAutoAxisLabels();
	this.UpdateDraw();
}


Go to Top of Page

Malb

2 Posts

Posted - 10 Jan 2007 :  02:01:40  Show Profile  Reply with Quote
No, these examples do not operate as I require. Both these examples plot a section of their overall range and the axis labels reflect the actual dataset values within the data array for the axis. So for instance, in LinePlotScrollBar the data is generated thus:
for (i=0; i < numPoints; i++)
{
x1[i] = (double)(i+1) ;

And the Axis displays values representing the values in the data array, ie 200 - 400 if displaying the 200th to 400th point.

I am trying to scale an axis where I am plotting raw data values and wish to draw the axis scale using a different number range. So for those same values, the 200th to 400th point I want the ais to read, say, 4.5 widgets to 8.5 widgets - a differnt linear range - real world values as opposed to raw datapoint values. I need to be able to do this for a subset of the range of data, or for the complete dataset, so, say we have 10000 points I want to plot points 0 - 9999, which in the case above would have the values 0 to 9999, but label the axis 0.00 widgets to 25.00 widgets.

Thanks.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 10 Jan 2007 :  08:54:40  Show Profile  Reply with Quote
If you want the actual data values plotted in one coordinate system, but the axis labels displayed in another, then you need to use TWO coordinate systems. Just create two CartesianCoordinates objects, each with the scale that you want, and plot your data (SimpleLinePlot) in one, but reference the other when creating your axes. While we do not have any examples that do exactly what you want, we have several examples that use multiple coordinate systems overlapping the same plotting area. See FAQ #2 in the FAQ chapter of the QCChart2D manual, or here: http://www.quinn-curtis.com/QCChart2DFAQs.htm. Also see the section "Multiple Coordinate Systems in the Same Chart" in Chapter 5 of the manual, and the example program MultipleAxes.

Thre first coordinate system auto-scales on the actual data (that is what most all of our examples do). You can then manually set the range of interest, 200 to 400 in your case.

CartesianCoordinates pTransform1 = new CartesianCoordinates( ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE);
pTransform1.AutoScale(Dataset2, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR);
pTransform1.SetScaleStartX(200.0);
pTransform1.SetScaleStopX(400.0);


The second coordinate system uses the y-value range of the first, but define its own unique x-scale range.

CartesianCoordinates pTransform2 = 
      new CartesianCoordinates( ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE);
pTransform2.SetCoordinateBounds(4.5, pTransform1.GetScaleStartY(),
      8.5, GetScaleStopY());
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