Hi all,
I got a Chart1 with a ListChartSource1 on my form. A timer is maintaining the data in ListChartSource1. The timer gets 1 value each second and adds it to ListChartSource1, and delete the first data of ListChartSource1, which means ListChartSource1 always has same amount of data(600 data for 10 min for example).
What I want to is to show the time on x axis by certain interval (30 secs for example), for if I show all of the labels on x axis, there will be some overlap. And if I set Chart1.Marks.OverlapPolicy to opHideNeighbour, it will show the time randomly. I want the time label show each 30 secs (for example, show the time at 08:15:00, 08:15:30, 08:16:00 ... don't show 08:15:03, 08:15:14...).
What I tried is:
1. set TChart.Marks.Source as ListChartSource1
2. Set Chart.BottomAxis.marks.style as smsLabel
2. Set Chart.BottomAxis.marks.OverlapPolicy as opIgnore
3. add value to ListChartSource1 like:
var
sec:integer;
TimeStr:string; //format as "hh:mm:ss"
begin
TimeStr:=GetTimeAsStr(rec.time); //my own function, not lizarus function
sec:=SecondOf(rec.time);
if sec mod 30 <> 0 then TimeStr:='';
ListChartSource1.Add(rec.time,rec.value,TimeStr,myColor);
while ListChartSource1.Count>600 do ListChartSource1.Delete(0);
end;
I hope data with timestamp which is not 0 or 30 sec show empty label on x axis and others can show the time. But what I got is: some of the label can be shown correctly, but not all of them. 1 second later(new data comes), these labels disappeared and some other lables shows.
How to solve this problem? Thanks!