Color Grid Colors

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sde
Newbie
Newbie
Posts: 21
Joined: Fri Jun 21, 2013 12:00 am

Color Grid Colors

Post by sde » Sat Apr 09, 2016 8:41 pm

Hello,

I need to provide my users with a color grid in our application. I was looking at the color grid example and still have some questions regarding how to set the colors.

So if I understand correctly, there are a few different ways to set the color in the grid. I say this based on the tchart editor which gives you single, range, and palette. The Range has a "gallery" but when I tried to use that, nothing happened to the colors in the grid. If I went to palette, there were some stock styles which you could use and then adjust the step size. However, if you use a custom palette, the step size does not appear to work. As I played around with the editor and loading a custom palette, I received numerous access violations and often after I would try something, nothing would change after I adjusted anything else. So there seems to be a lot of bugs in this area. That said, I don't really want my users to go through the TChart editor but would prefer to give them controls I've written. So I have the following questions:

1) I'd like to give my users the ability to use different styles when they define a color grid. Can you confirm that the two things I should probably allow them to set are the style and the step size? Which parameters do those correspond to in the Color grid object?

2) I'd also like to allow my users to put in their own color palette, but without having to use the upload feature in the editor. So programmatically, which parameters in the code form the palette where I could set the colors through code?

3) In the custom color palette, I saved one to see how it reads in the colors, and it appears to be the integer version of the HEX color in sequence BGR, not RGB. Why are the colors reversed like that? It is very strange. It took me a long time to figure out that it was using BGR and not RGB.

Thanks!
SDE

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

Re: Color Grid Colors

Post by Yeray » Mon Apr 11, 2016 10:07 am

Hello,
sde wrote: The Range has a "gallery" but when I tried to use that, nothing happened to the colors in the grid
In the ColorGrid example in the Features Demo, if I go to the Range tab, I can change the colors using the gallery. Ie:
ColorGridRangeGallery.png
ColorGridRangeGallery.png (157.98 KiB) Viewed 11527 times
ColorGridRangeGallery1.png
ColorGridRangeGallery1.png (161.85 KiB) Viewed 11507 times
ColorGridRange.png
ColorGridRange.png (178.99 KiB) Viewed 11499 times
sde wrote: However, if you use a custom palette, the step size does not appear to work.
It seems to work for me. Ie, choosing Rainbow custom palette with the default 32 and 15 steps:
Rainbow32.png
Rainbow32.png (148.38 KiB) Viewed 11502 times
Rainbow15.png
Rainbow15.png (144.12 KiB) Viewed 11510 times
sde wrote: As I played around with the editor and loading a custom palette, I received numerous access violations and often after I would try something, nothing would change after I adjusted anything else. So there seems to be a lot of bugs in this area.
Are you using the latest version available, TeeChart Pro v2015.16?
sde wrote:1) I'd like to give my users the ability to use different styles when they define a color grid. Can you confirm that the two things I should probably allow them to set are the style and the step size? Which parameters do those correspond to in the Color grid object?
These are the two basic properties to set when you want to define a custom palette, after setting UseColorRange to false and UsePalette to true. But there are other like PaletteMin&UsePaletteMin you may be interested on allowing.
If you own the sources, I'd suggest you to take a look at the editor, TeeGriEd unit (.pas and .dfm).
sde wrote:2) I'd also like to allow my users to put in their own color palette, but without having to use the upload feature in the editor. So programmatically, which parameters in the code form the palette where I could set the colors through code?
Here it is an example of loading a custom palette on a TSurfaceSeries. The same should apply for a TColorGridSeries:
http://www.teechart.net/support/viewtop ... 749#p69961
sde wrote:3) In the custom color palette, I saved one to see how it reads in the colors, and it appears to be the integer version of the HEX color in sequence BGR, not RGB. Why are the colors reversed like that? It is very strange. It took me a long time to figure out that it was using BGR and not RGB.
Could you please precise where did you find that so I can check why we did it?
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

sde
Newbie
Newbie
Posts: 21
Joined: Fri Jun 21, 2013 12:00 am

Re: Color Grid Colors

Post by sde » Mon Apr 11, 2016 9:56 pm

Hmmmm. Yes, I am using the latest v2015.16. And today it is working for me also with no access violations. I must have broken it last week with some combination of clicks which then prevented everything else from working correctly afterwards.

Yes, if you enter less than the number of default steps, it does work fine. But once you go above the number of default steps on any custom style it just repeats the last color. This is in contrast to the built in palettestyles (such as psPale) where if you change the step size, it actually adds and subtracts colors in the palette.

Thank you for the example code that worked great!

Regarding the BGR vs RGB colors, I got the BGR values by just hitting that save button next to the custom palette combo box. However, using your example code, I noticed the result of RGB(x, y, z) provides an integer BGR color. So then I thought this might be a windows thing. I found this page: https://msdn.microsoft.com/en-us/librar ... x#rgbcolor. So I guess you are using the BGR color model?

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

Re: Color Grid Colors

Post by Yeray » Tue Apr 12, 2016 12:21 pm

Hello,
sde wrote: Yes, if you enter less than the number of default steps, it does work fine. But once you go above the number of default steps on any custom style it just repeats the last color. This is in contrast to the built in palettestyles (such as psPale) where if you change the step size, it actually adds and subtracts colors in the palette.
The default palettes are created dynamically only considering the number of steps.
When you modify the PaletteSteps, the CreateDefaultPalette method is called; this method recreates the palette considering the PaletteSteps and the PaletteMin. When using the built in palettes it recreates the whole array of colors and also the array of UpToValues. However, in a custom palette we can't do that because we don't know if there's a relation between the sequence of colors; so we add the colors from the starting the Palette.
Then, if you increment the number of steps in a custom palette one by one, you'll be always adding the first color (ie with the Ranbow palette). However, if you jump from 32 to 40, ie, you'll be re-adding the first 8 colors in a row.
sde wrote: Regarding the BGR vs RGB colors, I got the BGR values by just hitting that save button next to the custom palette combo box. However, using your example code, I noticed the result of RGB(x, y, z) provides an integer BGR color. So then I thought this might be a windows thing. I found this page: https://msdn.microsoft.com/en-us/librar ... x#rgbcolor. So I guess you are using the BGR color model?
TeeChart uses TColor class to manipulate the colors and the save button in the TeeGriEd editor converts the TColors to string through IntToStr function.
I also see the RBG function in Windows.pas:

Code: Select all

function RGB(r, g, b: Byte): COLORREF;
begin
  Result := (r or (g shl 8) or (b shl 16));
end;
http://docwiki.embarcadero.com/RADStudi ... in_the_VCL
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

sde
Newbie
Newbie
Posts: 21
Joined: Fri Jun 21, 2013 12:00 am

Re: Color Grid Colors

Post by sde » Tue Apr 12, 2016 3:29 pm

Thank you for your explanation. That makes sense.

So I was able to recreate my access violation situation. So as soon as you adjust the Legend Every value (Series --> Grid 3D --> Palette --> Steps --> Legend Every speed edit) in the TChart Editor, you get an access violation after which nothing else works or you get more access violations. I also received an access violation when I tried to set TColorGrid(Series1).LegendEvery in my code. Can you please see if you can duplicate?

Thanks for all of your help!

SDE

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

Re: Color Grid Colors

Post by Yeray » Wed Apr 13, 2016 9:00 am

Hello,
sde wrote:So as soon as you adjust the Legend Every value (Series --> Grid 3D --> Palette --> Steps --> Legend Every speed edit) in the TChart Editor, you get an access violation after which nothing else works or you get more access violations.
I've been able to reproduce the problem so I've created a ticket on the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1506

Feel free to add your mail to the CC list to be automatically notified when an update arrives.
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

Post Reply