Forum > TAChart

[Solved] Using TColorRec colors for bar series

(1/4) > >>

artem101:
How to set SeriesColor using color names from System.UITypes unit? For example:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---BarSeries.SeriesColor := TColorRec.GreenYellow;
Color looks not as expected:
(https://i.ibb.co/vqvnBYz/2022-07-26-100854.png)

Seems there is another RGB bytes order.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---WriteLn(IntToHex(clBlue, 8));WriteLn(IntToHex(TColorRec.Blue, 8));
--- Quote ---00FF0000
000000FF
--- End quote ---

How to convert this correctly?

winni:
Hi!

00FF0000 is the internal format of fpc for Blue - Intel Format

000000FF is the official representation from W3 for Blue - Motorola Format.

If you want to convert the second to the first you have to swap the TColor (32 bit DWord)

Winni

dje:
Id say the Lazarus System.UITypes (TColorRec) colors are incorrect.

They don't match the Delphi constants.
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.UITypes.TColorRec

So, The documentation is also incorrect:
https://wiki.freepascal.org/Colors#Table_of_standard_colors

EG:
Delphi defines Darkblue = TColor($8B0000);
Lazarus defines DarkBlue = TColor($00008B);

winni:
Hi!

Besides incorrect documentation and the weird hunt for Delphi compatibility:

The solution for artem101 is:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ColorToPaint := swap (TColorRec.Blue);
Winni

rvk:

--- Quote from: derek.john.evans on July 26, 2022, 11:01:07 am ---So, The documentation is also incorrect:
https://wiki.freepascal.org/Colors#Table_of_standard_colors

--- End quote ---
Actually, they also don't state they are Delphi compatible.

Only the first 20 are Delphi compatible:

--- Quote ---About 20 predefined color constants are provided, which are Delphi-compatible:
--- End quote ---

For the other colors it states:

--- Quote ---In FPC 3.2.0+ defines some other constants for w3c colors in System.Uitypes:
--- End quote ---

So technically the documentation is correct.
It's just not Delphi compatible for the other colors (I'm not sure what the reason is behind this).

Navigation

[0] Message Index

[#] Next page

Go to full version