Page 1 of 1

Transparent series and legend colors

Posted: Mon Sep 24, 2007 5:59 pm
by 10546565
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?

Posted: Tue Sep 25, 2007 8:06 am
by narcis
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.

Posted: Mon Oct 08, 2007 3:32 pm
by 10546565
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.

Posted: Mon Oct 08, 2007 3:39 pm
by narcis
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!

Posted: Mon Oct 08, 2007 4:14 pm
by 10546565
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;

Posted: Tue Oct 09, 2007 8:37 am
by narcis
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;

Posted: Tue Oct 09, 2007 2:57 pm
by 10546565
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.