Hi, after a couple of days of trying to get this I resort to asking. I have searched the forum and read the developer guide ad infinitum.
Hi,
You are correct that there are demos, which I looked at. However I don't think they really address the question. The thing that I missed was the Range.StartDate which in my case is 16/02/2016 21:00:02 so I assume that if I use the RangeFrom as 0 it sets this point as this Date/Time. Then depending on the value of XAxis->UnitType it adds a day(utDay) or a minute (uTMinute) to that DateTime to get the date/time for sample 1 etc. Your example is very simplistic in that it adds one day at a time and you have a complete data set. In my case the samples can occur at asynchronous times, but all registered by the correct DateTime stamp. Also some samples may be missing. Using the theory that I have arrived at above, AdvCharts cannot cope with my data. Is this so? Otherwise it has to associate each record, in your example 0 to 30 with the real TDateTime and it does not seem to do that in my case. Sorry if i am missing something but I can't see it
Thanks Peter, I have been trying the AddXY points, was trying to make some sense of the format for it from the demo of XY time. The developer manual just states that it is overloaded, all sorts of combinations seem to compile and give weird results. The Delphi code in the demo is
The AddSingleXYPoint can also be used for gantt charts, therefore 2 timestamp parameters can be used. For a ctXYLine, you can use the following overload, only using the Y-value and the first timestamp parameter:
Peter, taking all that into account, could you please explain why my code will not work. I am setting the UnitType to uTDay and the RangeTo as 3, so that should give me a range of 3 days from my start date? I am using the ChartType ctXYLine.
Hi,
Thanks Peter, it works but I really can't see any difference to mine except the casting on the final parameter in the AddSingleXYPoint function. But I will chase it through and see where my error is.
Peter, I am going to give up for the night now, getting late. Your example works, If I change your for(cnt=0 loop to pick up my data as follows;
Hi,
My timeSample has resolution down to seconds as well, where you are only using to hours, but I would not have thought that was an issue. Thanks
Hi,
So can I clear this up. If I have to put in any missing points, which is a hassle since I would have to really go through my whole data set looking for missing points. What if the points are not falling completely synchronously. Ie, what if my time values are 10:15:00, 10:20:00, 10:22:00, 10:30:00 etc, is it going to cope with that, because I really will be using the AddXYPoint data with that irregularity. I suspect that is where the issue is? When I started out here I was expecting that the X axis was composed of TDateTime values but it really is a value representing the sample number and I think that is where my understanding is conflicting with TMS reality?
The values for the ctXYLine chart type can be added with different intervals. You should be able to add the values you mention without any issue, yet when having a point that doesn't not have a valid value or datetime, adding that point will result in a line drawn, therefore in your loop, you only need to make sure you are adding valid points, and add an undefined point for the invalid points. The DB chart currently doesn't support XY charts. This behavior would need to be manually implemented by using a first.. next statement and fetching the data from the database.
An undefined point is a point that is added through the AddSingleXYPoint overload, but with a True flag passed as a parameter to one of the overloads. Included is a sample that demonstrates. When running the sample you will notice a hole that is formed by undefined points. The undefined points are now simulated, but the check that is now if (cnt > 10 && cnt < 20) { should be replaced with a check if the points coming from the grid are valid, for example, if the timestamp in the grid is not an empty string. Additionally, you can see the timestamp that is being passed is randomly increased with a range from 1 to 10 hours. You only need to make sure that the next point that is added does not have a timestamp in the past (before the previous point).
Pieter Scheldeman2016-02-26 12:21:26
Thanks Peter, I will go through your example tomorrow. Late here. I have my code working. Problem was you had your start date as 26/2/2016 which I did not notice, the start dates in my table are 16//2/2016 which explains why the values were not showing as they were off the range.
Peter, when I add a cross hair to the project you provided at 11:03 am yesterday on this issue, using the code
I have found the answer to the last question. It involves the XScaleOffset factor. There is no mention of what this is in the developers manual. There is a brief mention that it was added as a new feature in the history. What does it do? By implementing the line p->XScaleOffset = false; i correct the problem but what am I actually doing. Is the offset settable somewhere?
The offset is not settable, the XScale starts at point 0 which is already offset by the widh of the series rectangle divided by the amount of visible points. When XScaleOffset is set to False, the first point starts at 0 pixels, instead of the XScale in pixels.