Legend series outline

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Bernhard Hard
Newbie
Newbie
Posts: 9
Joined: Fri Mar 14, 2008 12:00 am

Legend series outline

Post by Bernhard Hard » Tue Feb 17, 2009 1:53 pm

Hi Support Team!

We're using several Line Series with a different colored outline in our chart. Is it possible to have the outline also visible in the legend?

Thanks,
Chris

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

Post by Yeray » Tue Feb 17, 2009 4:44 pm

Hi Chris,

Yes, you should use legend's event OnSymbolDraw. The problem is that this event was implemented thinking in one series with different symbols for each point, not for multiple series.

That's why we propose you this workaround example. In the meanwhile, I've added this to the wish list to be enhanced in further releases (TF02013873).

Code: Select all

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            InitializeChart();
        }

        Steema.TeeChart.Styles.Line line1;
        Steema.TeeChart.Styles.Line line2;
        Steema.TeeChart.Styles.Line line3;

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;

            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line3 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

            line1.FillSampleValues(25);
            line2.FillSampleValues(25);
            line3.FillSampleValues(25);

            line1.OutLine.Visible = true;
            line2.OutLine.Visible = true;
            line3.OutLine.Visible = true;

            line1.OutLine.Color = Color.Black;
            line2.OutLine.Color = Color.Brown;
            line3.OutLine.Color = Color.Plum;

            line1.OutLine.Width = 3;
            line2.OutLine.Width = 3;
            line3.OutLine.Width = 3;

            tChart1.Legend.Symbol.DefaultPen = false;
            tChart1.Legend.Symbol.OnSymbolDraw += new Steema.TeeChart.SymbolDrawEventHandler(Symbol_OnSymbolDraw);

            tChart1.BeforeDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_BeforeDraw);
        }

        void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            tChart1.Legend.Symbol.Pen.Assign(line1.OutLine);
        }

        void Symbol_OnSymbolDraw(object sender, Steema.TeeChart.SymbolDrawEventArgs e)
        {
            int tmpIndex = tChart1.Series.IndexOf(e.Series);
            if (tmpIndex < tChart1.Series.Count - 1)
            {
                tChart1.Legend.Symbol.Pen.Assign(((Steema.TeeChart.Styles.Line)tChart1[tmpIndex + 1]).OutLine);
            }
        } 
    }
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