Page 1 of 1

Legend series outline

Posted: Tue Feb 17, 2009 1:53 pm
by 13048624
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

Posted: Tue Feb 17, 2009 4:44 pm
by yeray
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);
            }
        } 
    }