How to make legend symbol use the area's color

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
YingHui
Newbie
Newbie
Posts: 7
Joined: Wed Sep 10, 2014 12:00 am

How to make legend symbol use the area's color

Post by YingHui » Thu Sep 25, 2014 1:42 am

Hello:

I use the area to draw severl bar with different color each and I would like to make the color of symbol on the legend to be same with that related bar. However I only find the border of the symbol border is same with each bar, would you please let me know how I can fill the symbo with related bar area?
Thanks.

Attachment is the picture for your reference.

Ying-Hui
Attachments
Channel Level.jpg
Channel Level.jpg (39.59 KiB) Viewed 5443 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: How to make legend symbol use the area's color

Post by Christopher » Thu Sep 25, 2014 8:01 am

Hello Ying-Hui,
YingHui wrote: I use the area to draw severl bar with different color each and I would like to make the color of symbol on the legend to be same with that related bar. However I only find the border of the symbol border is same with each bar, would you please let me know how I can fill the symbo with related bar area?
Unfortunately this is a defect which I have added to our database with id=934. Fortunately there's an easy runtime workaround, which is to derive a new class from Area and override the method which is causing the problem, e.g.

Code: Select all

  public class MyArea : Area
  {
    public MyArea(Chart c) : base(c) { }

    protected override void PrepareLegendCanvas(Graphics3D g, int valueIndex, ref Color backColor, ref ChartBrush aBrush)
    {
       //leave empty
    }
  }

......

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      MyArea area = new MyArea(tChart1.Chart);

      area.Add(1, 5, Color.Red);
      area.Add(2, 1, Color.Blue);
      area.Add(3, 4, Color.Yellow);
      area.Add(4, 2, Color.Green);

      area.Stairs = true;
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

YingHui
Newbie
Newbie
Posts: 7
Joined: Wed Sep 10, 2014 12:00 am

Re: How to make legend symbol use the area's color

Post by YingHui » Thu Sep 25, 2014 9:21 am

Hello Chris:
Thanks for your reply. I will try the solution you provide. :)

Ying-HUi

Post Reply