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 not drawn in correct position
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

emcc

15 Posts

Posted - 02 Apr 2008 :  07:44:26  Show Profile  Reply with Quote
I have a problem trying to draw an x-axis in a plot with an exact scale, specifically 40.4 to 60.0. I set the LinearScale for the plot to have these limits, and use CalcAutoAxis(40.4, 60.0). The problem is that this results in AxisTickOrigin calculated as 40.0, which is not within the axis limits. When the axis is drawn, it starts at 40.0 instead of 40.4. A line plot on the same chart then appears displaced relative to the axis.
The only way I can fix this is to manually set the AxisTickOrigin to the next major tick. It appears CalcAutoAxis is not nor working correctly or is this the way it is supposed to work?

quinncurtis

1164 Posts

Posted - 02 Apr 2008 :  09:39:48  Show Profile  Reply with Quote
It may be that you need to increase the decimal precision of the tick mark labels in order to see the exact tick mark values.

NumericAxisLabels yAxisLab = new NumericAxisLabels(yAxis);
yAxisLab.AxisLabelsDecimalPos = 2;
chartVu.AddChartObject(yAxisLab);


Also, we are not sure what you want. Do you want MAJOR tick marks to start at 40.4. Our own test show that when the scale is from 40.4 to 60, and you call CalcAutoAxis(40.4, 60), you end up with the start of the scale, and a starting major tick mark at 40.4.
Go to Top of Page

emcc

15 Posts

Posted - 02 Apr 2008 :  16:45:50  Show Profile  Reply with Quote
Yes, setting the AxisLabelsDecimalPos to 2 shows that the axis is actually being drawn correctly. But I didn't want extra precision in the labels. I was expecting CalcAutoAxis to come with sensible ticks marks. In this case the first major tick should have been at 45.
If I look at the code in debug, after CalcAutoAxis is called, the tickorigin is set to 40, which is incorrect isnt it? If I then set the tickorigin to the next major tick using
double xMinorTick = xAxis.AxisTickSpace;
double xMajorTick = xMinorTick * xAxis.AxisMinorTicksPerMajor;
xAxis.SetAxisTickOrigin(Math.Ceiling(xyScale.ScaleMinX / xMajorTick) * xMajorTick);
the axis appears as I had expected. Why doesn't CalcAutoAxis do this automatically? Or is something else I need to do instead of using the above code.
Note: the scenario is that the axis has been drawn initially, and the user then selects new axis limits in a dialog to zoom in on part of the chart, and I want the axis range to be exact.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 02 Apr 2008 :  18:57:55  Show Profile  Reply with Quote
You are right, there seems to be something wrong with the tick mark origin calculation if you use AUTOAXIS_EXACT, and the low end of the range is barely above a logical tick mark position. Normally the calculation is similar to what you show, except that the special case describe above is trapped and handled by separate code, hence the difference between having a lower range of 40.4 and 41.01. We will have to check to see what condition the special case is supposed to trap. It's easy enough to remove the trap. If you want we can send you a modifed DLL if you don't have the source and you can test it.
Go to Top of Page

emcc

15 Posts

Posted - 02 Apr 2008 :  22:22:58  Show Profile  Reply with Quote
Yes the modified DLL would be be very useful if it fixes this problem, since I have several places in my program where I zoom in and set an exact axis range.
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