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

carlao

54 Posts

Posted - 20 Mar 2005 :  11:16:24  Show Profile  Reply with Quote
I created a multiline chart with scroll that works fine. I also created a multiaxes with multiline that also is ok. But now I need a chart that be multiline and multiaxes with horizontal scroll. I create this chart based on the others one that I mentioned above, but the behavior is not correct. First, only the first line is being scrolled. The others are freeze. How can I scroll all lines and update the y axes also?
Here is the snippet code to scroll the chart.

public void UpdateXScaleAndAxes(int index)
{
int startindex = index;
pTransform[0].SetScaleStartX( (double) startindex);
pTransform[0].SetScaleStopX( (double) (startindex + 100));
XAxis.CalcAutoAxis();
XAxisLab.CalcAutoAxisLabels();
for(int i=0; i < nTraces; i++)
{
((LinearAxis)yAxis[i]).CalcAutoAxis();
((NumericAxisLabels)yAxisLab[i]).CalcAutoAxisLabels();
}
}

Any idea?

Thanks.
Carlos

quinncurtis

1164 Posts

Posted - 20 Mar 2005 :  12:21:32  Show Profile  Reply with Quote
My guess is that since you are only changing the starting and ending values of the first coordinate system, i.e. pTransform[0] in your example:

pTransform[0].SetScaleStartX( (double) startindex);
pTransform[0].SetScaleStopX( (double) (startindex + 100));

that only the line plot associated with that coordinate system is scrolling.

Seems like your code should be doing something like:

for(int i=0; i < nTraces; i++)
{
pTransform[i].SetScaleStartX( (double) startindex);
pTransform[i].SetScaleStopX( (double) (startindex + 100));
}
// These two objects reference pTransform[0]
XAxis.CalcAutoAxis();
XAxisLab.CalcAutoAxisLabels();


If you look at our OHLCFinPlot example again you will see that we change the starting and ending x-values of all coordinate systems in the chart in response to a scrollbar change.

Also, in the future, when you post a problem, such as the AxisTitle topic you posted, please post on the same thread how the problem was resolved in order to aid other programmers with the same problem.

Go to Top of Page

carlao

54 Posts

Posted - 20 Mar 2005 :  14:37:46  Show Profile  Reply with Quote
I think that this is not an easy task. The main problem here is to understand how it works. I took a look at OHLCFinPlot example but could not fix the problem yet. I have 5 lines with 4 Y axis at left and the last one at right. When I run the code below, only the Y axis at right (the last line) stay fixed. The others Y axis are moved with the lines. How to lock the right Y axis to not move the scrolling the lines?

Carlos

{
int startindex = index;
for(int i=0; i < nTraces; i++)
{
pTransform[i].SetScaleStartX( (double) startindex);
pTransform[i].SetScaleStopX( (double) (startindex + 100));
}
XAxis.CalcAutoAxis();
XAxisLab.CalcAutoAxisLabels();
((LinearAxis)yAxis[1]).CalcAutoAxis();
((NumericAxisLabels)yAxisLab[1]).CalcAutoAxisLabels();
((LinearAxis)yAxis[1]).SetAxisIntercept(pTransform[1].GetStartX()-50);
((LinearAxis)yAxis[1]).SetAxisTickDir(ChartObj.AXIS_MAX);

for(int i=2; i < nTraces-1; i++)
{
((LinearAxis)yAxis[i]).CalcAutoAxis();
((NumericAxisLabels)yAxisLab[i]).CalcAutoAxisLabels();
}
((LinearAxis)yAxis[nTraces-1]).SetAxisIntercept(pTransform[nTraces-1].GetStopX());
((LinearAxis)yAxis[nTraces-1]).SetAxisTickDir(ChartObj.AXIS_MAX);

chartVu.UpdateDraw();

}
Go to Top of Page

quinncurtis

1164 Posts

Posted - 20 Mar 2005 :  15:06:22  Show Profile  Reply with Quote
I'm not sure if I understand what you say. Your question was

"How to lock the right Y axis to not move the scrolling the lines? ".

Did you mean to say,

"How do I lock the LEFT Y-Axes to not move with the scrolling lines."


You must specify a new, adjusted, axis intercept for each y-axis. Your code specifies a new intercept for yAxis[1] and yAxis[nTraces-1], but no others.

((LinearAxis)yAxis[1]).SetAxisIntercept(pTransform[1].GetStartX()-50);
.
.
.
((LinearAxis)yAxis[nTraces-1]).SetAxisIntercept(pTransform[nTraces-1].GetStopX());
Go to Top of Page

carlao

54 Posts

Posted - 21 Mar 2005 :  21:15:24  Show Profile  Reply with Quote
After many try and fail I could arrive in the code below

public void UpdateXScaleAndAxes(int index)
{
int startindex = index;
for(int i=0; i < nTraces; i++)
{
pTransform[i].SetScaleStartX( (double) startindex);
pTransform[i].SetScaleStopX( (double) (startindex + 100));
}
XAxis.CalcAutoAxis();
XAxisLab.CalcAutoAxisLabels();
((LinearAxis)yAxis[0]).CalcAutoAxis();
((NumericAxisLabels)yAxisLab[0]).CalcAutoAxisLabels();
((LinearAxis)yAxis[0]).SetAxisIntercept(pTransform[0].GetStartX());
((LinearAxis)yAxis[0]).SetAxisTickDir(ChartObj.AXIS_MIN);
for(int i=1; i < nTraces-1; i++)
{
((LinearAxis)yAxis[i]).CalcAutoAxis();
((NumericAxisLabels)yAxisLab[i]).CalcAutoAxisLabels();
((LinearAxis)yAxis[i]).SetAxisIntercept(pTransform[0].GetStartX()-i*16.7);
((LinearAxis)yAxis[i]).SetAxisTickDir(ChartObj.AXIS_MIN);
}
((LinearAxis)yAxis[nTraces-1]).SetAxisIntercept(pTransform[nTraces-1].GetStopX());
((LinearAxis)yAxis[nTraces-1]).SetAxisTickDir(ChartObj.AXIS_MAX);

chartVu.UpdateDraw();
}

But I have a little problem yet. See that I am using the value 16.7 to separate y axis from each other. The problem is that this value is not exactly the same used by the code to construct the chart. That way, when I execute the code above for the first time the Y axis are moved a little bit. Maybe one pixel or two but it is visible. How can I use the same value used by the code to separate each Y axis when the chart is constructed?
Thanks.

carlao
Go to Top of Page

quinncurtis

1164 Posts

Posted - 21 Mar 2005 :  22:46:05  Show Profile  Reply with Quote
There is always going to be rounding error, which can go either way on pixel boundaries, so a shift of one pixel may be unavoidable. Your second loop goes one count too far.

public void UpdateXScaleAndAxes(int index)
{
int startindex = index;
for(int i=0; i < nTraces; i++)
{
pTransform[i].SetScaleStartX( (double) startindex);
pTransform[i].SetScaleStopX( (double) (startindex + 100));
}

XAxis.CalcAutoAxis();
XAxisLab.CalcAutoAxisLabels();
((LinearAxis)yAxis[0]).CalcAutoAxis();
((NumericAxisLabels)yAxisLab[0]).CalcAutoAxisLabels();
((LinearAxis)yAxis[0]).SetAxisIntercept(pTransform[0].GetStartX());
((LinearAxis)yAxis[0]).SetAxisTickDir(ChartObj.AXIS_MIN);

// for(int i=1; i < nTraces-1; i++) // replace with below
for for(int i=1; i < nTraces-2; i++)
{
((LinearAxis)yAxis[i]).CalcAutoAxis();
((NumericAxisLabels)yAxisLab[i]).CalcAutoAxisLabels();
((LinearAxis)yAxis[i]).SetAxisIntercept( pTransform[0].GetStartX()-i*16.7);
((LinearAxis)yAxis[i]).SetAxisTickDir(ChartObj.AXIS_MIN);
}

((LinearAxis)yAxis[nTraces-1]).SetAxisIntercept(pTransform[nTraces-1].GetStopX());
((LinearAxis)yAxis[nTraces-1]).SetAxisTickDir(ChartObj.AXIS_MAX);

chartVu.UpdateDraw();
}

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