Transparent series and legend colors

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Transparent series and legend colors

Post by TestAlways » Mon Sep 24, 2007 5:59 pm

When a series has it's Transparent value set, the color of the series may altered, but the color in the legend uses the non-transparent color.

For example, see

http://www.TRAKCentral.com/files/BatchG ... xample.jpg

where the two green colors are the same color--but the shortfall has Transparency value is set to 60--but the legend doesn't communicate this.

Is there a way the legend will show the color shown in the graph?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Sep 25, 2007 8:06 am

Hi TestAlways,

I've been able to reproduce the issue here and added it to our defect list to be enhanced for future releases.

In the meantime, the only alternative I can think of is manually setting legend symbols as shown at the All Features\Miscellaneous\Legend\Symbol OnDraw example in the features demo, available at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Post by TestAlways » Mon Oct 08, 2007 3:32 pm

narcis wrote:In the meantime, the only alternative I can think of is manually setting legend symbols as shown at the All Features\Miscellaneous\Legend\Symbol OnDraw example in the features demo, available at TeeChart's program group.
I don't know where to find that--I've searched my Steema directory ("TeeChart 80 for Delphi 7") an there is no "Miscellaneous" directory.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 08, 2007 3:39 pm

Hi TestAlways,

I'd like to apologise if I wasn't specific enough on my explanation. I meant that the example should be found at the new features demo, which can be found at TeeChart's program group (Start menu -> All Programs -> Steema TeeChart v8.01 for Delphi 7). This demo is only included with the specific binary installer for each IDE. So if you are a sourcecode customer I strongly recommend you to first install using the binary installer to obtain all documentations, examples, tutorials, etc. Later install source code.

Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Post by TestAlways » Mon Oct 08, 2007 4:14 pm

Below is my attempt, which is not working. I checked, and the first

Code: Select all

if...then
block is run, but it draws the legend as if it was solid, not transparent.

What do I need to change?

Thanks

Code: Select all

procedure TdmBPPrinting.GapChartLegendDraw(Sender: TObject;  Series:TChartSeries; ValueIndex:Integer; R:TRect);
var
  lCanvas: TCanvas3D;
  lBlend: TTeeBlend;
  lAreaSeries: TAreaSeries;
  lChart: TCustomAxisPanel;
begin
  Assert(Series is TAreaSeries);

  lAreaSeries := TAreaSeries(Series);
  lChart := Series.ParentChart;
  lCanvas := lChart.Canvas;
  lCanvas.Brush.Color := Series.Color;

  if lAreaSeries.Transparency > 0 then
  begin
    lBlend := lCanvas.BeginBlending(r, lAreaSeries.Transparency);
    try
      lCanvas.FillRect(R); // <<--- Draws solid color, not transparency color
    finally
      lCanvas.EndBlending(lBlend);
    end;
  end
  else
    lChart.Canvas.FillRect(R);
end;

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Oct 09, 2007 8:37 am

Hi TestAlways,

This is most likely because you need to set Canvas' color before doing the custom drawing, something like this:

Code: Select all

procedure TForm1.LegendDraw(Sender: TObject; Series: TChartSeries;
  ValueIndex: Integer; R: TRect);
var
  lBlend: TTeeBlend;
begin
  Chart1.Canvas.Brush.Color := Series1.Color;

  if Series1.Transparency > 0 then
  begin
    lBlend := Chart1.Canvas.BeginBlending(R, Series1.Transparency);
    try
      Chart1.Canvas.Rectangle(R);
    finally
      Chart1.Canvas.EndBlending(lBlend);
    end;
  end
  else
    Chart1.Canvas.Rectangle(R);
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Post by TestAlways » Tue Oct 09, 2007 2:57 pm

This is most likely because you need to set Canvas' color before doing the custom drawing
Looking at my code snippet, I did:

Code: Select all

Canvas.Brush.Color := Series.Color; 
The only effective difference in our code is:

Code: Select all

Chart1.Canvas.Rectangle(R); //yours 
and

Code: Select all

lCanvas.FillRect(R);  //mine
Changing my code to .Rectangle() fixed the issue.

Thank you.

Post Reply