Recent

Author Topic: TA Chart Axes visibility - or just a basic error in logic?  (Read 196 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1324
The Click-Event of my TChartListbox sets the visability of my axes. (see below).
This works fine, mostly.
However in clicking acitve and selecting my series, - I find out, that the percentage axes has disappeared.
My series containing percentage have the German "PROZ" for "Prozent" in it.
And searching for the particle PROZ shall set the visibility of axes.

so:
It works as such, but there is a unknown situation, where it is set to invisible and this setting not undone by the function.
What did I miss?

Code: Pascal  [Select][+][-]
  1. // Sichert die Auswahl der in TAChart zu zeichnenden Serien
  2. procedure TFrame_cot_dis.ChartListbox_COT_DisClick(Sender: TObject);
  3. Var i: integer;
  4. begin  // Event wird ausgelöst, nachdem der User geklickt hat
  5.    for i := 21 to 28 do Chart_COT_Dis.AxisList.Axes[2].Visible :=  // schaltet die Konzentration Achse auf sichtbar
  6.       Chart_COT_Dis.AxisList.Axes[2].Visible and Chart_COT_Dis.Series[i].Active;
  7.  
  8.   // Anzeige der Achsen:
  9.  Chart_COT_Dis.AxisList[0].Visible:=false; // COT
  10.  Chart_COT_Dis.AxisList[2].Visible:=false;  // Konzentration
  11.  Chart_COT_Dis.AxisList[3].Visible:=false;  // Prozent
  12.  Chart_COT_Dis.AxisList[4].Visible:=false; // spot bzw. jetzt nearest
  13.  
  14.  for i := 0 to 21 do // schaltet für alle COT die Achse
  15.   if (Chart_COT_Dis.Series[i].Active)
  16.      then Chart_COT_Dis.AxisList[0].Visible := True;
  17.  
  18.  for i := 0 to Chart_COT_Dis.SeriesCount - 1 do // schaltet für alle "Conc" die Concentration-Achse
  19.   if (Pos('CONC', Chart_COT_Dis.Series[i].Name) > 0) and (Chart_COT_Dis.Series[i].Active) then
  20.     Chart_COT_Dis.AxisList[2].Visible := True;
  21.  
  22.  for i := 0 to Chart_COT_Dis.SeriesCount - 1 do // schaltet für alle "PROZ"-Serien die Achse
  23.   if (Pos('PROZ', Chart_COT_Dis.Series[i].Name) > 0) and (Chart_COT_Dis.Series[i].Active) then
  24.     Chart_COT_Dis.AxisList[3].Visible := True;
  25.  
  26.  // Achse für Candles
  27.  Chart_COT_Dis.AxisList[4].Visible:=SeriesCandles.Active;
  28.  
  29.  // wenn ALLE Achsen unsichtbar sind, zerlegt es das Chart.
  30.  if not Chart_COT_Dis.AxisList[0].Visible and not Chart_COT_Dis.AxisList[2].Visible
  31.     and not Chart_COT_Dis.AxisList[3].Visible and not Chart_COT_Dis.AxisList[4].Visible
  32.     then Chart_COT_Dis.AxisList[2].Visible := True;
  33.  
  34.  //______________ Ende Achsensichtbarkeit
  35.  
  36.  
  37.    ChartListBoxInIniSchreiben;  // Sicherung der Auswahl in ini
  38. end;          
  39.  
  40.  

wp

  • Hero Member
  • *****
  • Posts: 13583
Re: TA Chart Axes visibility - or just a basic error in logic?
« Reply #1 on: May 12, 2026, 08:22:28 pm »
Hmmm, this is a bit too complex for my limited brain... Here is a smaller (tested) sample project containing two line series plotted on the left axis and two area series plotted on the right axis. Using AutoScaleAxisTransformations the two vertical axis ranges are shifted vertically so that they do not overlap. In the ChartListbox, each series can be turned on and off. When all series belonging to the same axis are hidden the axis itself is hidden, too.

Nicole

  • Hero Member
  • *****
  • Posts: 1324
Re: TA Chart Axes visibility - or just a basic error in logic?
« Reply #2 on: May 13, 2026, 02:45:02 pm »
Thanks, I do not doubt, it shall work as such: I have several charts working fine with hits systematic. This is the only one, which causes troubles. And I cannot see why.

My systematic is not too complex, is it?
I set all axes to invisible.
Then I check the series:
If any series is active which includes the snipet "Proz" (for Prozentdarstellung), then the Proz-axes set to visible again.

In my first attempts I "let my charts out of their box". I removed the last left ax and wondered why the chart looked so strange. Now I have a security built-if NOT to remove ALL left axes.

Is this bad style as such?



wp

  • Hero Member
  • *****
  • Posts: 13583
Re: TA Chart Axes visibility - or just a basic error in logic?
« Reply #3 on: May 13, 2026, 07:05:07 pm »
I set all axes to invisible.
Then I check the series:
If any series is active which includes the snipet "Proz" (for Prozentdarstellung), then the Proz-axes set to visible again.
Not sure but it could be that when the axis of a series is turned off that series goes off as well and might no longer be included in the listbox...

Are there several "PROZ" axes?

If there is only one "Proz" axis, I'd just iterate over all series now and count how many series assigned to this axis are active. When the counter is zero, the axis can be hidden, otherwise must be shown.

When there are several "PROZ"-related axes it depends on whether you still want to see those axes for which all the assigned series are hidden. I'd count the number of active series attached to each PROZ axis. And when an axis has no more active series it can be turned off.

Nicole

  • Hero Member
  • *****
  • Posts: 1324
Re: TA Chart Axes visibility - or just a basic error in logic?
« Reply #4 on: May 13, 2026, 08:27:54 pm »
Code: Text  [Select][+][-]
  1. Not sure but it could be that when the axis of a series is turned off that series goes off as well and might no longer be included in the listbox...

No, this works fine. I have Lazarus 4.4, and the listbox does what it shall do finally. btw I found an easy trick to avoid to delete and readding the chartlistbox in times of troubles: Just cut the property in the chart. Set it to none. Then add the property again and the listbox is actual without troubles. However the Listbox is not the problem, works fine (at least at the moment).

Code: Text  [Select][+][-]
  1. If there is only one "Proz" axis, I'd just iterate over all series now and count how many series assigned to this axis are active. When the counter is zero, the axis can be hidden, otherwise must be shown.

There is only one PROZ ax. It scales the percentage values.
I will think about this tomorrow, because I am too tired today: I wonder, if it is a good idea, to set the ax to invisible in the top of my function. In many cases there will be a percentage-series active. May be this is the problem, that I re-set it to visible after having set to invisible before. There is an ax-vakuum between the lines.

Are you sure, you can turn off an axes that easy? Try to turn off the last one at the left side. Not sure, if you will see the same effect, I saw.

So let us write on here, if one of us has a new idea.
Thank you to care for this complex component!!

 

TinyPortal © 2005-2018