Page 1 of 1
Display hh:mm:ss in marks
Posted: Thu Mar 05, 2009 9:44 am
by 10050873
Hello,
In a pie i want to display values in the format hh:mm:ss (it could be for examples 124:18:12)
What is the best way to do that?
Regards
Posted: Thu Mar 05, 2009 10:38 am
by yeray
Hi Calou,
You could add the values to the pie with the time as its label. For example:
Code: Select all
var myTimeString: string;
//...
myTimeString:= '21:06:20';
Series1.Add(StrToDateTime(myTimeString),myTimeString);
And to ensure that the points' labels will be shown at series' marks:
Posted: Thu Mar 05, 2009 11:02 am
by 10050873
I have tried it but in the legend myTimeString appears.
My data are like it
10:00:50 name1
485:57:20 name2
965:10:12 name3
...
in the marks i want the first column and in the legend the second column
How could i do that?
Many thanks for help
Regards
Posted: Thu Mar 05, 2009 11:06 am
by 10050873
In order to be more precise
Here is the code that convert the data in date time (hh:mm:ss)
Code: Select all
dt:=FloatToDateTime(frmMain.IBCQryRd.FieldByName('DUREE').AsFloat);
test:=FormatFloat('00',HoursBetween(dt,0))+':'+FormatFloat('00',MinuteOf(dt))+':'+FormatFloat('00',SecondOf(dt));
Posted: Thu Mar 05, 2009 3:36 pm
by yeray
Hi Calou,
I'm not sure to understand how are you adding your values to the series but anyway, you should have a double as value and a string as label for each point added point.
Then, to show the label as mark and the value at the legend:
Code: Select all
Series1.Marks.Style := smsLabel;
Chart1.Legend.TextStyle := ltsValue;
And reverse:
Code: Select all
Series1.Marks.Style := smsValue;
Chart1.Legend.TextStyle := ltsPlain;
Posted: Thu Mar 05, 2009 5:19 pm
by 10050873
i have used ongetmarktext and it works good
Thank you for help
Posted: Fri Mar 06, 2009 3:42 pm
by 10050873
Hello,
To solve my problem i have used OnGetMarkText
However i want to use TMarksTipTool and now the hint is always the marks value and i would like to have the legend value
In my example i would like to hint TEST
http://www.cijoint.fr/cjlink.php?file=c ... 1oWlI6.jpg
Here is the code of the event :
Code: Select all
procedure TfrmMain.Series1GetMarkText(Sender: TChartSeries; ValueIndex: Integer;
var MarkText: string);
begin
MarkText:=FormatFloat('00',HoursBetween(Sender.YValue[ValueIndex],0))+':'
+FormatFloat('00',MinuteOf(Sender.YValue[ValueIndex]))+':'+FormatFloat('00',SecondOf(Sender.YValue[ValueIndex]));
end;
thank you for help
Posted: Fri Mar 06, 2009 4:15 pm
by yeray
Hi Calou,
There is also a OnGetMarkText from Mark Tips Tool that you still could use. Could be something like that:
Code: Select all
procedure TForm1.ChartTool1GetText(Sender: TMarksTipTool;
var Text: String);
var i: Integer;
tmpText: string;
begin
for i:=0 to Series1.Count-1 do
begin
tmpText := FormatFloat('00',HoursBetween(Sender.Series.YValue[ValueIndex],0))+':'
+FormatFloat('00',MinuteOf(Sender.Series.YValue[ValueIndex]))+':'+FormatFloat('00',SecondOf(Sender.Series.YValue[ValueIndex]));
if (tmpText = Text) then
begin
Text := Series1.Labels.Labels[i];
break;
end;
end;
end;
Posted: Fri Mar 06, 2009 4:47 pm
by 10050873
It works good
Thank you