Recent

Author Topic: Hint on axis marks  (Read 537 times)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 293
Hint on axis marks
« on: December 16, 2025, 12:43:32 pm »
I’m working with charts that display long string labels on both the Y and bottom axes. To keep things readable, I truncate the labels before adding to the axis source. However, I’d like to show a hint when the user hovers over an axis mark, displaying the full original label.

Is there is something like this available in TAChart, or has anyone implemented a similar feature?

Any suggestions or example code would be greatly appreciated.

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: Hint on axis marks
« Reply #1 on: December 16, 2025, 01:35:13 pm »
There is a TChartAxisClickTool which basically could be extended to show also hint texts. But this requires some work since the tool was not designed with having this use-case in mind.

Nicole

  • Hero Member
  • *****
  • Posts: 1303
Re: Hint on axis marks
« Reply #2 on: December 18, 2025, 06:42:56 pm »
for one thing, you can twist them by
 Chart / AsixList / Marks / LabelFont / Orientation = 450 => 45 degrees

the other thing is:
double click your chart and add tools, e.g. the hinttool.

here is a code snippet, I kept.
If you have troubles with it, there are some more:

Code: Pascal  [Select][+][-]
  1. // Mouse-over shows the items within a Memo
  2. procedure TFrame_Zeichne.AusgabeHint(ATool: TDataPointHintTool; const APoint: TPoint; var AHint: String);
  3. var ser: TOpenHighLowCloseSeries;
  4.     punkt: Integer;
  5.     o, h, l, c: double;
  6.     d: double;
  7.     dat: TDate;
  8.  
  9. begin
  10.   Memo_AusgabeKerze.Clear; // die Ausgabe soll immer nur eine Kerze zeigen
  11.   AHint := '';
  12.  
  13.   if ATool.Series is TOpenHighLowCloseSeries then
  14.   begin
  15.     ser := TOpenHighLowCloseSeries(ATool.Series);
  16.       punkt := ATool.PointIndex;
  17.       With Ser do begin
  18.         O:=YValues[punkt, YIndexOpen];
  19.         H:=YValues[punkt, YIndexHigh];
  20.         L:=YValues[punkt, YIndexLow];
  21.         C:=YValues[punkt, YIndexClose];
  22.         dat:=ser.GetXValue(punkt);
  23.                 end;
  24.     Memo_AusgabeKerze.Clear;
  25.     Memo_AusgabeKerze.Lines.Add('open=' + FloatToStrF(O,ffFixed,4,4));
  26.     Memo_AusgabeKerze.Lines.Add('high=' + FloatToStrF(H,ffFixed,4,4));
  27.     Memo_AusgabeKerze.Lines.Add('low=' + FloatToStrF(L,ffFixed,4,4));
  28.     Memo_AusgabeKerze.Lines.Add('close=' + FloatToStrF(C,ffFixed,4,4));
  29.     d:=H - L;
  30.     Memo_AusgabeKerze.Lines.Add('range=' + FloatToStrF(d,ffFixed,4,4));
  31.     Memo_AusgabeKerze.Lines.Add(DateToStr(dat)); // Datum an letzte Stelle, weil das immer hochscrollt, will das nicht recherchieren warum
  32.  
  33.     Series_BigCKontr.Clear;                // USD hier nicht, weil 2 mal DB dazu nötig
  34.     Series_BigCKontr.AddXOHLC(dat, o, h, l, c);  // erzeugt große Kerze
  35.   end;
  36. end;                      
« Last Edit: December 19, 2025, 05:39:34 pm by Nicole »

paweld

  • Hero Member
  • *****
  • Posts: 1561
Re: Hint on axis marks
« Reply #3 on: December 18, 2025, 06:54:41 pm »
@Nicole: Please place the source code in [code] tags: https://wiki.freepascal.org/Forum#Use_code_tags
« Last Edit: December 18, 2025, 06:59:21 pm by paweld »
Best regards / Pozdrawiam
paweld

Nicole

  • Hero Member
  • *****
  • Posts: 1303
Re: Hint on axis marks
« Reply #4 on: December 18, 2025, 07:50:20 pm »
oups, sorry, I forgot it for this time.
thank you for the hint.

paweld

  • Hero Member
  • *****
  • Posts: 1561
Re: Hint on axis marks
« Reply #5 on: December 18, 2025, 08:13:07 pm »
Quote from: Nicole
oups, sorry, I forgot it for this time.
No worries - you can edit your posts: on the right side of the post header, there is a "Modify" link (see screenshot).
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018