Page 1 of 1

Do not paint for Barjoin line

Posted: Fri Sep 28, 2012 6:08 am
by 13047041
Hello all,

I am using Barjoin.

I have a need to not show the Barjoin line when data for that bar/point is null. Corresponding bar comes as blank but the barjoin line joins to the last drawn point. Here are the actual snapshot and the way I want. Please let me know if this is posssible.

Re: Do not paint for Barjoin line

Posted: Fri Sep 28, 2012 2:01 pm
by 10050769
Hello Amit,

I am afraid isn't possible do it directly. I have made a simple code, where I have used SetNull points and three series to achieve as you want:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.BarJoin Series1, Series3;
        Steema.TeeChart.Styles.Bar Series2;
        private void InitializeChart()
        {
            //TChart
            tChart1.Aspect.View3D = false;

            //Series
            Series1 = new Steema.TeeChart.Styles.BarJoin(tChart1.Chart);
            Series2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            Series3 = new Steema.TeeChart.Styles.BarJoin(tChart1.Chart);
            //Add values to Series;
            Random rnd = new Random();
            Series1.FillSampleValues(6);
            Series1.Color = Color.Red;
            Series2.DataSource = Series1;
            Series2.Color = Series1.Color;
            Series3.DataSource = Series1;
            Series3.Color = Series1.Color;
            Series1.Marks.Visible = false;
            Series2.Marks.Visible = false;
            Series3.Marks.Visible = false;
            tChart1.Legend.LegendStyle = LegendStyles.Values;
            tChart1.Draw();
            for (int i = 0; i < 6; i++)
            {
                if (i < 2)
                {
                    Series2.SetNull(i);
                    Series3.SetNull(i);
                }
                else if (i == 2)
                {
                    Series1.SetNull(i);
                    Series3.SetNull(i);
                }
                else if (i > 2)
                {
                    Series1.SetNull(i);
                    Series2.SetNull(i);
                }

                tChart1.Legend.Symbol.OnSymbolDraw += new SymbolDrawEventHandler(Symbol_OnSymbolDraw);
            }

        }

        void Symbol_OnSymbolDraw(object sender, SymbolDrawEventArgs e)
        {
            //Paint null symbols of legend.
            tChart1.Graphics3D.Brush.Color = Color.Red;
            tChart1.Graphics3D.Rectangle(e.Rect);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.ShowEditor();
        }

Can you tell us if previous code works in your end?

I hope will helps.

Thanks,