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#)
 Problem with StringAxisLabels
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

carlao

54 Posts

Posted - 08 Jul 2006 :  17:35:28  Show Profile  Reply with Quote
I have a chart with multiple Y axis (6) where, from left to right, the first three Y axis are StringAxisLabels (orange, green and red axis). This chart is used in a logger module and each line has its own pTransform object. The problem is that there are sometimes when the chart is loaded (or new values loaded) and the StringAxisLabels shows different label range EVEN when the data range is the same. For example, suppose that the Y string labels is
"a", "b", "c", "d", "e"
Actualy, when I load the chart I can see only "a", "b", "c", "d" or "a", "b", "c" or even "a", "b", "c", "d", "e".
How can I force the StringAxisLabes range to display the entire range in any situation? I tried to use the LABEL_ALL property but could not fix. I also tried to use your logger example but it does not work for me. Maybe because it is not a multiaxis case.


Edited by - carlao on 08 Jul 2006 18:05:24

quinncurtis

1164 Posts

Posted - 09 Jul 2006 :  12:18:07  Show Profile  Reply with Quote
Sorry, we don't really understand your description of the problem.

1. A y-string axis label is placed at each major tick mark, starting at the tick mark staring position, and continuing for the number of labels that your specified in the SetAxisLabels method. Are you absolutely consistent with the number of axis labels that you specify.
When you do not get all of the axis labels that you want, are there too few major tick marks, or are the too few axis labels for the number of major tick marks that you have ?

2. We do not understand the connection between your problem, and the multiple y-axes. Are you saying that each of the three axes that use StringAxisLabels has the exactly same range and tick mark spacing, and that you call the SetAxisLabels method with exactly the same parameters, but the axis labels are displayed differently in each case?

3. Are you saying that if you remove all but one of the offending y-axes the problem goes away ? Or is the problem reproducible with a single y-axis ? If so, then you should create the simplest example program that demonstrates the problem with a single y-axis.

4. Are you saying the the same axis will randomly display a different number of y-axis labels for exactly the same axis range, tick mark spacing, and setup call to SetAxisLabels ?

As you describe it, your problem has nothing to do with data logging, and perhaps not even multiple axes, so there is no reason to restrict yourself to those types of examples in an effort to reproduce the problem. In any event you will probably have to create some sort of simple example that we can run that demonstrates the problem
Go to Top of Page

carlao

54 Posts

Posted - 11 Jul 2006 :  16:36:13  Show Profile  Reply with Quote
Yes, it is not ease to explain what happens when we need see the screen.
Below is a link where you will find a doc with the screenshot of what I am trying to say.
http://www.byteshift.com/problemsmultiaxis.doc

Even so, here is the snippet code that I am using. Because I am using STEP lines and analog lines, then I need take care about them.

public override void SetYaxisLabel()
{
for( int i=0; i < nTraces; i++ )
{
if(2 == i || 3 == i || 4 == i)
{
String [] yAxisStrings=null;
if( 2 == i)
yAxisStrings = new string[]{"1","2","3","4"};
else if( 3 == i)
yAxisStrings = new string[]{"P","R","N","4","3","2","1"};
else if( 4 == i)
yAxisStrings = new string[]{"P","R","N","1","1OD","2","2OD","3","3OD","4","4OD",""};
else
yAxisStrings = new string[]{"","","","","",""};
if(i == 2 || i == 3 || i == 4)
{
YAxis[i].SetAxisTickSpace(1);
YAxis[i].SetAxisMinorTicksPerMajor(1);
}
yStringAxisLab[i] = new StringAxisLabels(YAxis[i]);
yStringAxisLab[i].SetAxisLabels(theFont, 0, ChartObj.AXIS_MIN, ChartObj.LABEL_ALL,
Color.Black, yAxisStrings, yAxisStrings.Length);
chartVu.AddChartObject(yStringAxisLab[i]);
}
else
{
YAxisLab[i] = new NumericAxisLabels(YAxis[i]);
YAxisLab[i].SetTextFont(theFont);
YAxisLab[i].SetAxisLabelsFormat(ChartObj.DECIMALFORMAT);
chartVu.AddChartObject(YAxisLab[i]);
}
}
chartVu.UpdateDraw();
}

I have a logger where I need colect data and show in chart. Then, I need load the dataset with new values. This is the snippet code that I use to load dataset and prepare chart to display.

public override void UpdateDynamicChart()
{
// update anlogic axis
for(int i=0; i < NAnal-1; i++)
{
Dataset[i].SetTimeXData(GetXArray);
Dataset[i].SetYData(((double[])YArray[i]));
pTransform[i].SetTimeScaleStart(GetXArray[0]);
if(i != 2 && i != 3 && i != 4 )
{
pTransform[i].AutoScale(Dataset[i], ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_EXACT);
((LinearAxis)YAxis[i]).CalcAutoAxis();
((NumericAxisLabels)YAxisLab[i]).CalcAutoAxisLabels();
}

if(i == 2 || i == 3 || i == 4)
{
YStringAxisLab[i].CalcAutoAxisLabels();
YAxis[i].SetAxisTickSpace(1);
YAxis[i].SetAxisMinorTicksPerMajor(1);
}
((LinearAxis)YAxis[i]).SetAxisTickDir(ChartObj.AXIS_MIN);
}
}
Go to Top of Page

quinncurtis

1164 Posts

Posted - 11 Jul 2006 :  17:20:57  Show Profile  Reply with Quote
It is very clear from your document that you have either scaled the two left-most transforms (and associated y-axes) incorrectly, or you have set the major tick mark spacing incorrectly for the given scale. You are going to have set these explicitly because our auto-scale and auto-axis routines have no idea of what you are trying to do.


The leftmost y-scale should be 0-10 in order to display your 11 y-axis labels. This assumes that your major tick mark spacing is always 1. In the graph where it doesn't work it is clearly scaled to 0-6, With a major tick mark spacing of 1. If you intended for the y-scale to be 0-6, then you must change the major tick mark spacing to 0.6, so that you will still have 11 tick marks.

This is what we said in the original post. It is up to you to create a y-axis that has exactly the number of major tick marks that you have string labels for. If your y-scale is determined by our auto-scale methods, then you must calculate the major tick mark spacing based as

(yaxis.AxisMax - yaxis.AxisMin)/( number_string_labels - 1)

and set it explicity using the yaxis.AxisTickSpace property.

The other axis is wrong for a similar reason.

Your problem has nothing to do with multiple axes and we changed the thread title to StringAxisLabels to better reflect the topic. If you still cannot solve the problem you must create a simple example program that uses a single y-axis the reproduces the problem. We can't understand what is going on in your program segments.

Go to Top of Page

carlao

54 Posts

Posted - 13 Jul 2006 :  09:43:31  Show Profile  Reply with Quote
Following your comments I inserted this snippet code in my UpdateXScaleAndAxis method..

double axisTickSpace = (YAxis[i].GetAxisMax() - YAxis[i].GetAxisMin()) / (YStringAxisLab[i].GetAxisLabelsStrings().Length-1); YAxis[i].SetAxisTickSpace(axisTickSpace);
YAxis[i].SetAxisMinorTicksPerMajor(1);
YAxis[i].SetAxisTickOrigin(0);

Now the Y axis is working. But now I have another problem. All the 3 STEP lines are drawing from the middle to top and part of these lines are not visible because they are out of the chart in the upper side. I tried to use SetFillBaseValue(0) but no success. Any idea?
Go to Top of Page

quinncurtis

1164 Posts

Posted - 13 Jul 2006 :  10:52:38  Show Profile  Reply with Quote
Sounds like the .Net anti-aliasing of lines has a bug in some cases for thin vertical lines, where the lines are partially out of the clipping window. Make the line thickness of the stepped plot lines 2 using the plot lines ChartAttribute and see if the problem goes away.

double linethickness = 2;
ChartAttribute attrib = new ChartAttribute(Color.Red, linethickness , DashStyle.Solid)

SimpleLinePlot plot1 = new SimpleLinePlot(transform, dataset, attrib);


Go to Top of Page

carlao

54 Posts

Posted - 13 Jul 2006 :  21:25:05  Show Profile  Reply with Quote
To fix the problem with STEP lines I had to call the plot method inside my UpdateXScaleAndAxis method in this way
thePlot[i].SetStepMode(ChartObj.STEP_START);
Now the Y axes and STEP lines and analogic lines are all working correctly. Thanks!!
Go to Top of Page

carlao

54 Posts

Posted - 15 Jul 2006 :  00:26:13  Show Profile  Reply with Quote
No way.
Today when I started the program again I figured that the STEP lines are wrong again in the same way as before. The lines start from the middle chart to top side. It seems that the draw engine does not know about the Y labels tick calculation that I do manualy.
Please take a look in my doc at the same link
http://www.byteshift.com/problemsmultiaxis.zip

tkanks.
Go to Top of Page

carlao

54 Posts

Posted - 18 Jul 2006 :  18:45:46  Show Profile  Reply with Quote
Any idea to fix this problem?
Thanks.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 22 Jul 2006 :  12:25:16  Show Profile  Reply with Quote
We looked at your document and we are still not sure we understand your problem. Are you complaining that that the tops of the step lines are not showing ?

THE TOPS OF THE STEPPED LINES ARE BEING CLIPPED, BECAUSE YOU ARE TRYING TO PLOT HORIZONTAL VALUES THAT LIE EXACTLY ON THE EDGE OF THE PLOTTING AREA. THE PLOTTING AREA CLIPS THE DATA PLOTS.

If, after the many scaling operations that go on internal to the software, numerical rounding causes your plotted data to be infinitesimally larger than the the upper limit of the scale, the upper edge of the plot will go missing. This only applies to stepped lines, that go horizontal at a clipping edge. You will never be able to see the effect with un-stepped lines because it will only involve a single pixel.

Solution - You must scale the y-scale of the transform to have a minimum and maximum that are less than (but not equal to) and greater than (but not equal to) the range of your data. You must add and subtract a fudge factor from the y-scale of the transform if you insist on plotting data values as stepped lines at the exact edge of the plotting area.

If the range of your data is 0-6, scale your y-scale for -0.01 to 6.01. All of the axis routines will stay the same. The graph will look exactly the same, only the top edge of the plots should unclip. If you are relying on our .AutoScale methods to set the scale, then you fudge the scale after the .AutoScale call.

CartesianCoordinates pTransform1 = new CartesianCoordinates( ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE);
pTransform1.AutoScale(Dataset3, ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR);
pTransform1.ScaleStartY -= 0.01;
pTransform1.ScaleStopY += 0.01;


Or, your can adjust your data, subtracting a small fudge factor from the highest value, and adding a small fudge factor to the smallest value.

Also use a line thickness of at least 2.
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