Page 1 of 1

two line chart issues

Posted: Wed May 13, 2009 10:05 am
by 9092401
Hi
I have two issues with a line chart.
1. when I want to work with a 2D chart with it seems that the Legend symbols has a problem . If I set the Default pen to false so that I can have a different border around the symbols. then the symbol is only a line with the color of the Pen I defined and with the width of the Pen. If I remove the line DefaultPen = false then I get the symbols properly only I dont have a border around the symbols.
tChart1.Aspect.View3D = false;
tChart1.Legend.Symbol.DefaultPen = false;
tChart1.Legend.Symbol.Pen.Color = Color.DarkGray;
see image
Image

2. If I have a 2D Chart with thick lines (LinePen.Width = 5) and then I change the Aspec.View3d = true I notice the LinePen.Width is used as a Border around the lines and it doesnt look nice and only when I change the LinePen.Width to 0 does it look nice.
In the image
Image
You can see the effect. the Yellow line looks good after I changed the LinePen.Width back to 1.

Please help
Thanks.

Posted: Wed May 13, 2009 2:30 pm
by yeray
Hi qcrnd,

1. Here I'm not sure to understand you. Would you like a legend symbol like the one is shown for line series in 3D, a square with a wide border? Note that this is applied to 3D line series because they show 2 parts, the line itself and the border (that could be more o less wide)

2. Yes, if you modify LinePen.Width, the changes are visible both for 2D and 3D. If you want different LinePen.Width when you change from 2D to 3D, you'll have to control it manually. For example, when you set your chart as 3D:

Code: Select all

tChart1.Aspect.View3D = true;
for (int i = 0; i < tChart1.Series.Count; i++)
{
    ((Line)tChart1.Series[i]).LinePen.Width = 1;
}

Posted: Sun May 17, 2009 6:06 am
by 9092401
Hi
1. Here I'm not sure to understand you. Would you like a legend symbol like the one is shown for line series in 3D, a square with a wide border? Note that this is applied to 3D line series because they show 2 parts, the line itself and the border (that could be more o less wide)
I am begining to think that I dont quite understand the Line Properties.
I would like to define a 2D line chart.
1.I want the lines to have width 4 pixels with a specific color
2. I want the borders around the line to be White and be of 1 pixel width
3. I want the legend symbols to be square box with a Gray border filled with the line color. (For some reason in 2D the symbol box is just a line and not a box , when I uncheck the symbol Default border.)

When changing to 3D I want the colors to remain only the aspect should be 3D.

I used LinePen to define the width but I think I should have used LineHeight , However I tried changing the line Height property but it doesnt have any effect. I also noticed Outline can affect the line width.

In short , I am not sure what I should do exactly
Please help me through ALL the properties I need to set . to get 1 -3 and have it work well in 3D as well.

Thanks.

Posted: Mon May 18, 2009 12:34 pm
by yeray
Hi qcrnd,

I think that now I understand the problem. Let me explain you some issues:

2D lines
- Only the LinePen is drawn by default and it's drawn using the series color.
- If you want to see a border you have to set OuterLine visible.

3D lines
- It is drawn a plane and a border line by default. The plane is drawn with the series color and the border line is the LinePen (black by default).
- If you have OuterLine visible, you'll see two border lines.

Knowing this, if you want to change from 2D to 3D and see something similar you'll have to copy some properties because the LinePen in 2D will be the border in 3D and the OuterLine in 2D will disappear in 3D.

The only problem I see is that the OuterLine seems to grow as LinePen grows.

I the other hand, note that the legend symbol changes automatically from 2D to 3D because, by default, lines have no border in 2D but in 3D. So to avoid this I'm afraid that you should draw your custom symbols directly to the legend. Here there is an example of everything:

Code: Select all

        int FirstItemTopLegend;

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

            tChart1.Aspect.View3D = false;
            tChart1.Walls.Back.Gradient.Visible = false;
            tChart1.Walls.Back.Color = Color.Black;

            for (int i = 0; i < 4; i++)
            {
                new Line(tChart1.Chart);
                tChart1.Series[i].FillSampleValues(5);
                ((Line)tChart1.Series[i]).LinePen.Width = 4;
                ((Line)tChart1.Series[i]).OutLine.Visible = true;
                ((Line)tChart1.Series[i]).OutLine.Color = Color.White;
                ((Line)tChart1.Series[i]).OutLine.Width = 0;
            }

            tChart1.GetLegendRect += new Steema.TeeChart.GetLegendRectEventHandler(tChart1_GetLegendRect);
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            int SymbolTop, SymbolLeft, SymbolBottom, SymbolRight;
            int SymbolsTopMargin = 3;
            int SymbolsLeftMargin = 5;
            int SymbolsSize = 10;
            int SymbolsSeparation = 14;


            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                SymbolLeft = tChart1.Legend.Left + SymbolsLeftMargin;
                SymbolRight = tChart1.Legend.Left + SymbolsLeftMargin + SymbolsSize;
                SymbolTop = FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsTopMargin;
                SymbolBottom = FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsSize + SymbolsTopMargin;
                tChart1.Graphics3D.Brush.Color = tChart1.Series[i].Color;
                tChart1.Graphics3D.Pen.Color = Color.Gray;
                tChart1.Graphics3D.Rectangle(tChart1.Legend.Left + SymbolsLeftMargin,
                                            FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsTopMargin,
                                            tChart1.Legend.Left + SymbolsLeftMargin + SymbolsSize,
                                            FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsSize + SymbolsTopMargin);
            }
        }

        void tChart1_GetLegendRect(object sender, Steema.TeeChart.GetLegendRectEventArgs e)
        {
            FirstItemTopLegend = e.Rectangle.Top; 
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            tChart1.Aspect.View3D = checkBox1.Checked;
            
            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                ((Line)tChart1.Series[i]).OutLine.Visible = !tChart1.Aspect.View3D;

                if (tChart1.Aspect.View3D)
                {
                    ((Line)tChart1.Series[i]).LinePen.Width = 1;
                    ((Line)tChart1.Series[i]).LinePen.Color = Color.White;
                }
                else
                {
                    ((Line)tChart1.Series[i]).LinePen.Width = 4;
                    ((Line)tChart1.Series[i]).LinePen.Color = tChart1.Series[i].Color;
                }
            }
        }

Posted: Mon May 18, 2009 1:17 pm
by 9092401
Hi Yeray
Thanks for the detailed explaination . I understand now much better.
Two questions.
1. Can you please explain again why there is a difference in 2D and 3D symbols and why I must do a custom draw
2. The Outline doesnt seem to be 1 pixel. it has a minimum of about 2 -3 pixels and it cant grow thinner. I tried 0 I tried 1 but it doesnt help. The line is too thick.

Thanks.

Posted: Mon May 18, 2009 2:27 pm
by yeray
Hi qcrnd,

1. By default lines in 2D look like a simple line without any border (Only LinePen is drawn) so the legend symbol should be a simple line.
By default lines in 3D look like a plane with a border so the legend should be a square where the border and the plane could be represented.

2. Excuse me, I was testing it with v4 where OutLine width seems not to work perfectly. It seems to start counting at LinePen width so the borders will always be wider than the line. i've added it to the wish list to be revised for future releases (TF02014158).
With v3, in 2D it seems that OutLine is the line inside and LinePen are the lines outside (border) but it seems that they work as expected. So in v3 it seems to work fine:

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        int FirstItemTopLegend;

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

            tChart1.Aspect.View3D = false;
            tChart1.Walls.Back.Gradient.Visible = false;
            tChart1.Walls.Back.Color = Color.Black;

            for (int i = 0; i < 4; i++)
            {
                new Line(tChart1.Chart);
                tChart1.Series[i].FillSampleValues(5);
                ((Line)tChart1.Series[i]).LinePen.Width = 1;
                ((Line)tChart1.Series[i]).OutLine.Visible = true;
                ((Line)tChart1.Series[i]).OutLine.Color = Color.White;
                ((Line)tChart1.Series[i]).OutLine.Width = 4;
            }

            tChart1.GetLegendRect += new Steema.TeeChart.GetLegendRectEventHandler(tChart1_GetLegendRect);
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            int SymbolTop, SymbolLeft, SymbolBottom, SymbolRight;
            int SymbolsTopMargin = 3;
            int SymbolsLeftMargin = 5;
            int SymbolsSize = 10;
            int SymbolsSeparation = 14;


            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                SymbolLeft = tChart1.Legend.Left + SymbolsLeftMargin;
                SymbolRight = tChart1.Legend.Left + SymbolsLeftMargin + SymbolsSize;
                SymbolTop = FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsTopMargin;
                SymbolBottom = FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsSize + SymbolsTopMargin;
                tChart1.Graphics3D.Brush.Color = tChart1.Series[i].Color;
                tChart1.Graphics3D.Pen.Color = Color.Gray;
                tChart1.Graphics3D.Rectangle(tChart1.Legend.Left + SymbolsLeftMargin,
                                            FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsTopMargin,
                                            tChart1.Legend.Left + SymbolsLeftMargin + SymbolsSize,
                                            FirstItemTopLegend + (i * SymbolsSeparation) + SymbolsSize + SymbolsTopMargin);
            }
        }

        void tChart1_GetLegendRect(object sender, Steema.TeeChart.GetLegendRectEventArgs e)
        {
            FirstItemTopLegend = e.Rectangle.Top;
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            tChart1.Aspect.View3D = checkBox1.Checked;
           
            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                ((Line)tChart1.Series[i]).OutLine.Visible = !tChart1.Aspect.View3D;

                if (tChart1.Aspect.View3D)
                {
                    ((Line)tChart1.Series[i]).LinePen.Width = 1;
                    ((Line)tChart1.Series[i]).LinePen.Color = Color.White;
                }
                else
                {
                    ((Line)tChart1.Series[i]).LinePen.Width = 1;
                    ((Line)tChart1.Series[i]).LinePen.Color = tChart1.Series[i].Color;
                    ((Line)tChart1.Series[i]).OutLine.Width = 4;
                }
            }
        }

Posted: Tue May 19, 2009 12:24 pm
by 9092401
Hi Yeray
IN Version=3.5.3330.21113 it is just like you said with v4.
The Outline seems to depend on the LInePen. If I increase the Width of the LinePen , The outline automatically because wider as well.
This should be fixed because currently I wont be able to work with such a thick outline.
Is there any workaround for this
Thanks.

Posted: Wed May 20, 2009 11:05 am
by yeray
Hi qcrnd,

Could you please try it with the latest maintenance release available?