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#)
 Shift dataset content?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

carlao

54 Posts

Posted - 08 Oct 2005 :  10:57:25  Show Profile  Reply with Quote
Hi all,
Using the code below, I can shift a chart from left to right and vice-versa. The shift chart is like a window over the dataset where I can see the entire dataset content. It works fine. But the problem that I have faced is how to add more points at the start and at the end of the dataset.
I was looking the ScrollingMixedPlots and DataLogger examples but they doesnt have what I need. I saw that dataset class has an AddDataPoint but there is a problem.
Suppose that the chart is moving to right and shows the last dataset window and now I need to add more point at the end. Maybe I could use AddDataPoint to add more points but if I continue adding more points continuously, my dataset will turn to be very big. Should be good if I could fill my dataset with new data. I need also do the same when the window is at the start of the dataset, that is, add more data in a way that the chart could continue to shift to the left. I tried to fill the entire dataset with new data when the chart is at the start or at the end of dataset but the displayed chart is crazy. Same axis disapear, others change its position, scale and so on.
Any idea?
Tks.

public new void UpdateXScaleAndAxes(DateTime date, int nAnalogic, double delta, int index, bool needShift)
{
int startindex = index;
double offset=0;
ChartCalendar startdate = new ChartCalendar(date);
ChartCalendar stopdate = new ChartCalendar();

// set xstart date
ChartCalendar.SetTOD(startdate, date.Hour, date.Minute, date.Second);
// set xstop date
stopdate = (ChartCalendar) startdate.Clone();
offset = SetStopDate(stopdate, index, nAnalogic, delta, needShift);

PTransform[0].SetTimeScaleStart(startdate);
PTransform[0].SetTimeScaleStop(stopdate);

XAxis.CalcAutoAxis();
XAxisLab.CalcAutoAxisLabels();
// show time as HH:mm
XAxisLab.SetAxisLabelsFormat(ChartObj.TIMEDATEFORMAT_24HM);
XAxisLab.SetAxisLabelsEnds(ChartObj.LABEL_MIN);
((LinearAxis)YAxis[0]).CalcAutoAxis();
((NumericAxisLabels)YAxisLab[0]).CalcAutoAxisLabels();
((LinearAxis)YAxis[0]).SetAxisIntercept(PTransform[0].ScaleMinX);
((LinearAxis)YAxis[0]).SetAxisTickDir(ChartObj.AXIS_MIN);

chartVu.UpdateDraw();
}

quinncurtis

1164 Posts

Posted - 10 Oct 2005 :  08:28:06  Show Profile  Reply with Quote
Sorry, we don't really understand what you want to do, or your code example. The one thing that we follow is that you are concerned about continuously adding points to a dataset, making it very large. You can delete points from the front of the data set using the datsets DeleteDataPoint method. Just call

dataset.DeleteDataPoint(0);

repeatedly. Each time it is called it will remove the oldest element of the dataset.
Go to Top of Page

carlao

54 Posts

Posted - 10 Oct 2005 :  20:02:42  Show Profile  Reply with Quote
In short, I need add point at the end of dataset and at the start of dataset depending on the direction to where the chart is shifting. As you said, it seems that to add at the end I can use AddDataPoint and DeletePoint(n). But how about adding at the start of dataset? It seems that your library doen't have a method to do this, right?
Tks.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 10 Oct 2005 :  20:18:24  Show Profile  Reply with Quote
That's what the datasets InsertDataPoint method is for.

int insertpoint = 0;
dataset.InsertDataPoint(newXValue, newYValue, insertpoint );

Of course if you are using the SimpleLinePlot, the newXValue must have a value that is proper when compared to its neighbors, otherwise the line plot will zig back and forth along the x-axis.
Go to Top of Page

carlao

54 Posts

Posted - 11 Oct 2005 :  16:21:53  Show Profile  Reply with Quote
You are right, the line plot is zigging back and forth along the x-axis that has a bad appearance. I created a new dataset but when chart shift along x-axis I get zig behavior. Also, the chart is a multiple y-axis and when the new dataset is assumed, some of the y-axis became like out of focus. I was thinking to recreate a new chart using something like InitializeChart method, each time a new dataset is assumed. I don't see this as a good approach but I dont see another solution. Any idea?
Tks.
Go to Top of Page

quinncurtis

1164 Posts

Posted - 11 Oct 2005 :  17:34:49  Show Profile  Reply with Quote
We don't know why you are inserting new data points that are out of sequence with adjacent points. It sounds like some sort of basic flaw in the logic of your program.

Once you add new data points, you can sort the data points in the dataset by the x-value of each data point using the dataset SortByX method.

dataset.SortByX(true);

That wil get rid of the zigzag, but will probably not resolve any multiple axis problems that you have. Your best choice is probably just rebuild the graph from scratch.

If you are able to describe exactly how you want the graph to behave (which we do not understand based on your previous descriptions) you can contract us to write that part of the code for you. You would need to write a very detailed specification that we can base a quote on.
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