Extra legend tool

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Extra legend tool

Post by stsl » Mon Apr 06, 2009 11:26 am

Hi,

How is it possible to add a custom symbol in an Extra legend tool ?
I use LegendStyle := lsGroups and i would like to draw a colored square between the check box and the text of the group name.
I didn't find when the Symbol.OnDraw event is fired.

Best regards

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

Post by Yeray » Mon Apr 06, 2009 2:20 pm

Hi stsl,

Yes, I'm afraid that there is no event for customizing the ExtraLegendTool symbol. But you always can draw custom rectangles directly to the canvas at OnAfterDraw event or where you are customizing your tool.
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

stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Post by stsl » Mon Apr 06, 2009 2:30 pm

Are you sure that it's only on the extra legend tool ?
With the normal legend, it's not possible to have symbols when we use lsGroups.
I don't know why i purchased TeeChart because i have to draw myself everything.


Regards

stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Post by stsl » Mon Apr 06, 2009 2:52 pm

Your are wrong, it's also possible to add rectangle in an extralegend but only when we are in lsSeries mode.
Please, this behaviour is very important for me and (and very urgent) and i have no time to find a workaround for this bug (for me, it's a bug,
and when i use TeeChart, i spend 60% of my time to bypass bugs and strange things).

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

Post by Yeray » Mon Apr 06, 2009 3:36 pm

Hi stsl,

Excuse me if I haven't been enough clear. I meant that the event OnDraw for symbol legend only seems to work for the normal legend, not for this tool. And I've added it to the wish list to be fixed asap (TV52014060).

So, for the normal legend it would be easy to draw the custom symbols with this event (you can see the demo at All Features/Miscellaneous/Legend/Symbol OnDraw).

Note that for a legend where each item represents a point (with a concrete color) or a series (with a concrete color) it's easy to determine the symbol to draw. But having a group of series, there is not a clear unique solution (or we haven't determined yet) on which symbol has to be drawn.
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

stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Post by stsl » Mon Apr 06, 2009 4:37 pm

I have to use an extra legend tool and not a normal legend (see my different post about the legend and the solution that you suggested for me in the past).

Note :
I know that you can't determine wich color we have to use for a group but i know that i would like to see in my legend (not a color in my case...)

I am afraid about your "ASAP" criteria. I am waiting a patch for a very important bug since 2005.

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

Post by Yeray » Tue Apr 07, 2009 8:21 am

Hi stsl,
stsl wrote:I am waiting a patch for a very important bug since 2005.
Could you please tell us the number of the bug or the forum thread where this bug was discussed and we'll see its state?

We understand that, in the customer side, some of you have important problems that demand immediate intervention, but without any doubt, you'll understand that we also have to value other aspects such as the number of customers affected, if there is a workaround or not, the percentage of the component that is affected, the relation cost/benefit of the implementation,...
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

stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Post by stsl » Tue Apr 07, 2009 11:04 am

Summary of my post, about a very critical bug (null values are different than 0 values) :

Posted: 02 Nov 2005 18:35 Post subject: Functions, period range and data leak

and your response

Posted: 07 Apr 2008 10:13 Post subject: Reply with quote
Hi stsl,

I've added the feature request to the wish list (TV52012945) to be reviewed and, if possible, enhanced in further releases. This may be quite a sensible issue as implementing it as you request may break existing clients code.

Also notice that we don't provide support for changes to the source code but you are free to implement the necessary customizations to fit your needs.
_________________
Best Regards
Yeray Alonso


Best regards

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

Post by Yeray » Tue Apr 07, 2009 11:49 am

Hi stsl,

Please, see my answer in the according forum thread.
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

stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Post by stsl » Thu Apr 30, 2009 8:05 am

When did you plan to fix this bug ? I hope in the 8.05 release.....

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

Post by Narcís » Thu Apr 30, 2009 10:27 am

Hi stsl,

Here's an update on the status of the issues discussed on this thread:

TV52014060: I've checked this already works fine here using something as the code below. Can you please check if this works fine for you?

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues();
  ChartTool1.Legend.Symbol.OnDraw:=LegendDraw;
end;

procedure TForm1.LegendDraw(Sender: TObject; Series:TChartSeries;
                            ValueIndex:Integer; R:TRect);
var Flag : TBitmap;
begin
  Flag:=TBitmap.Create;  // create flag bitmap
  try
    Dec(R.Top,3);
    Inc(R.Bottom,3);

    if ValueIndex mod 2 = 0 then
      Flag.LoadFromFile('C:\temp\TeeCopy.bmp')
    else
      Flag.LoadFromFile('C:\temp\TeeDepth.bmp');

    with Chart1.Canvas do
    begin
      StretchDraw(R,Flag);  // draw image to legend

      // draw border
      if Chart1.Legend.Symbol.Pen.Visible then
      begin
        Brush.Style:=bsClear;
        AssignVisiblePen(Chart1.Legend.Symbol.Pen);
        Rectangle(R,0);
      end;
    end;

  finally
    Flag.Free;  // destroy bitmap
  end;
end;
TV52012945: We don't consider this being a bug but a feature request, which is very specific. In my opinion Yeray suggested you several options to achieve what you request using existing TeeChart features. Given all those circumstances it's most unlikely that it's implemented in v8. We don't have an estimate date for this being implemented either.
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

stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Post by stsl » Thu Apr 30, 2009 10:57 am

TV52014060 :
Did you use LegendStyle := lsGroups ?


TV52012945 :
For me it's a bug because the function generates wrong values in the graph (0 instead null values).

Best regards

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

Post by Narcís » Thu Apr 30, 2009 11:38 am

Hi stsl,
V52014060 :
Did you use LegendStyle := lsGroups ?
Ok, the problem here is that series groups don't have symbol. So if you want to use symbols there you could use dummy series for that purpose, for example:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  Chart1.Legend.Visible:=false;
  Series1.FillSampleValues();
  ChartTool1.Legend.Symbol.OnDraw:=LegendDraw;

  for i:=0 to Chart1.SeriesCount -1 do
    Chart1[i].ShowInLegend:=false;

  for j:=0 to Chart1.SeriesGroups.Count-1 do
  begin
    Chart1.AddSeries(TChartSeries.Create(self));
    Chart1[Chart1.SeriesCount-1].ShowInLegend:=true;
    Chart1[Chart1.SeriesCount-1].Title:=Chart1.SeriesGroups[j].Name;
  end;

  ChartTool1.Series:=Chart1[Chart1.SeriesCount-1];
  ChartTool1.Legend.LegendStyle:=lsSeries;
end;

procedure TForm1.LegendDraw(Sender: TObject; Series:TChartSeries;
                            ValueIndex:Integer; R:TRect);
var Flag : TBitmap;
begin
  Flag:=TBitmap.Create;  // create flag bitmap
  try
    Dec(R.Top,3);
    Inc(R.Bottom,3);

    Flag.LoadFromFile('C:\root\TeeChartVCL\Sources8\TeeCopy.bmp');
{    if ValueIndex mod 2 = 0 then
      Flag.LoadFromFile('C:\root\TeeChartVCL\Sources8\TeeCopy.bmp')
    else
      Flag.LoadFromFile('C:\root\TeeChartVCL\Sources8\TeeDepth.bmp');
}
    with Chart1.Canvas do
    begin
      StretchDraw(R,Flag);  // draw image to legend

      // draw border
      if Chart1.Legend.Symbol.Pen.Visible then
      begin
        Brush.Style:=bsClear;
        AssignVisiblePen(Chart1.Legend.Symbol.Pen);
        Rectangle(R,0);
      end;
    end;

  finally
    Flag.Free;  // destroy bitmap
  end;
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

stsl
Newbie
Newbie
Posts: 45
Joined: Thu Jun 21, 2007 12:00 am

Post by stsl » Thu Apr 30, 2009 12:23 pm

But i need a normal legend with series (not the dummies) and an extra legend with groups (dummies) and check box to disable one or more groups of other series. Is-it possible to do that ? I think that with dummies series it will be complicated.

Why did you disable the OnDrawLegend event when we have lsGroups ? There is no logical reason...

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

Post by Narcís » Thu Apr 30, 2009 1:47 pm

Hi stsl,
But i need a normal legend with series (not the dummies) and an extra legend with groups (dummies) and check box to disable one or more groups of other series. Is-it possible to do that ? I think that with dummies series it will be complicated.
Yes, I'm afraid this would be complicated.
Why did you disable the OnDrawLegend event when we have lsGroups ? There is no logical reason...
In my opinion the reason it is pretty simple, since series groups don't have symbols for the legend they can't fire the OnDraw event. This is already on the wish-list to be considered for inclusion in future releases.
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

Post Reply