Display hh:mm:ss in marks

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Display hh:mm:ss in marks

Post by Calou » Thu Mar 05, 2009 9:44 am

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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Mar 05, 2009 10:38 am

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:

Code: Select all

Series1.Marks.Style := smsLabel;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Post by Calou » Thu Mar 05, 2009 11:02 am

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

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Post by Calou » Thu Mar 05, 2009 11:06 am

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));

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Mar 05, 2009 3:36 pm

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Post by Calou » Thu Mar 05, 2009 5:19 pm

i have used ongetmarktext and it works good

Thank you for help

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Post by Calou » Fri Mar 06, 2009 3:42 pm

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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Mar 06, 2009 4:15 pm

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Post by Calou » Fri Mar 06, 2009 4:47 pm

It works good

Thank you

Post Reply