The first label display incomplete in x axis.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
sim
Newbie
Newbie
Posts: 19
Joined: Wed Jul 30, 2008 12:00 am

The first label display incomplete in x axis.

Post by sim » Thu Apr 05, 2012 3:06 am

I plot the graph using some points as the first attachment, including x1, y1, y2 axis. But when I remove some points in y1 axis, the graph changed as the second attachment, and first label in x1 axis displayed incomplete. Please help me to resolve it or give me a solution?
Attachments
label_appear.jpg
The labels is complete
label_appear.jpg (186.56 KiB) Viewed 12510 times
label_disappear.jpg
The first label is incomplete
label_disappear.jpg (152.97 KiB) Viewed 12500 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by Sandra » Thu Apr 05, 2012 1:24 pm

Hello sim,

I suggest you try to change your Minimum and Maximum Offset using something as next line of code:

Code: Select all

tChart1.Axes.Bottom.MinimumOffset = 20;
Can you tell us if my suggestion help you to solve the problem?

Thank,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sim
Newbie
Newbie
Posts: 19
Joined: Wed Jul 30, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by sim » Fri Apr 06, 2012 1:40 am

Thanks, i resolved it as you said.
But I have a new question, when I remove the points in y1 axis, the y1 axis title is disappear as the attachment, I want that the y1 title display.
Please help me again, thanks.
Attachments
title_disappear.jpg
title_disappear.jpg (146.87 KiB) Viewed 12445 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by Sandra » Tue Apr 10, 2012 11:41 am

Hello sim,

If you disable the Left axis the title of axis disappears, so it depends if its axis is visible or not. I think you can do something as do in next code, where I have used the GetAxisLabels to add a empty string in the Left Axis labels:

Code: Select all

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

        }

        Steema.TeeChart.Styles.Line Series1, Series2;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            Series1 = new Line(tChart1.Chart);
            Series2 = new Line(tChart1.Chart);

            Series1.Add(1.0, 1.0);
            Series1.Add(1.0e+3, 1.0e+1);
            Series1.Add(1.0e+5, 1.0e+2);
            Series1.Add(1.0e+6, 1.0e+3);
            Series1.Add(1.0e+1, 1.0e+4);
            Series1.Add(1.0e+8, 1.0e+5);
            Series1.Add(1.0e+7, 1.0e+6);

            Series2.Add(-1.0);
            Series2.Add(-1.0e+1);
            Series2.Add(-1.0e+2);
            Series2.Add(-1.0e+3);
            Series2.Add(-1.0e+4);
            Series2.Add(-1.0e+5);
            Series2.Add(-1.0e+6);
            Series2.RefreshSeries();
            Series2.VertAxis = VerticalAxis.Right;
            Series1.VertAxis = VerticalAxis.Left;
            tChart1.Axes.Left.Labels.Exponent = true;
            tChart1.Axes.Right.Labels.Exponent = true;
            //Axis Left
            tChart1.Axes.Left.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Left.Ticks.Visible = false;
            tChart1.Axes.Left.Title.Text = "Axis Y1";
            //Axis Right
            tChart1.Axes.Right.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Right.Title.Text = "Axis Y2";
            tChart1.Axes.Bottom.Labels.Exponent = true;
            //Axis Bottom
            tChart1.Axes.Bottom.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Bottom.Title.Text = "Axis X1";
            tChart1.Axes.Bottom.MinimumOffset = 20;
            tChart1.GetAxisLabel += new GetAxisLabelEventHandler(tChart1_GetAxisLabel);
        }
        void tChart1_GetAxisLabel(object sender, GetAxisLabelEventArgs e)
        {
            if (sender == tChart1.Axes.Left)
            {
                e.LabelText = "";
            }
        }
Can you please, tell us if previous code works as you want?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sim
Newbie
Newbie
Posts: 19
Joined: Wed Jul 30, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by sim » Wed Apr 11, 2012 7:58 am

Sorry, the question have not been resolved yet. Perhaps what i said is not clear.
I want that left axis title display, but the points on left axis is disappear. Please help me, thanks.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by Sandra » Wed Apr 11, 2012 1:27 pm

Hello sim,

I have understand you want that the values of axis aren't visible but title yes. So, I made a simple example where appears the title but not the values. Can you tell us which you don't like of my code, so we can try to find a good solution for you?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sim
Newbie
Newbie
Posts: 19
Joined: Wed Jul 30, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by sim » Thu Apr 12, 2012 4:35 am

Hi Sandra,
I want the series disappear on left axis, not values. Please see the red line in the first attachment(left_appear).
After remove the series, the graph will changed as the second attachment(left_disappear), but I want the left axis title display.
Please again, thanks.
Attachments
Left_appear.jpg
Left_appear.jpg (171.36 KiB) Viewed 12414 times
Left_disappear.jpg
Left_disappear.jpg (198.31 KiB) Viewed 12404 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by Sandra » Thu Apr 12, 2012 11:16 am

Hello sim,

Ok. I have modified my previous project to third series disappears when the values of axes not appear. To do it I have used the property transparency of Series.

Code: Select all

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

            //CheckBox
            checkBox1.Checked = true;
          //  checkBox1.CheckedChanged += new EventHandler(checkBox1_CheckedChanged);
            Series1 = new Line(tChart1.Chart);
            Series2 = new Line(tChart1.Chart);
            Series3 = new Line(tChart1.Chart);

            Series1.Add(1.0, 1.0);
            Series1.Add(1.0e+3, 1.0e+1);
            Series1.Add(1.0e+5, 1.0e+2);
            Series1.Add(1.0e+6, 1.0e+3);
            Series1.Add(1.0e+1, 1.0e+4);
            Series1.Add(1.0e+8, 1.0e+5);
            Series1.Add(1.0e+7, 1.0e+6);

            Series2.Add(1.0e+3, 3.0e+1);
            Series2.Add(1.0e+5, 1.0e+2);
            Series2.Add(1.0e+6, 2.0e+3);
            Series2.Add(1.0e+1, 1.0e+4);
            Series2.Add(1.0e+8, 1.0e+5);
            Series2.Add(1.0e+7, 3.0e+6);

            Series3.Add(1.0);
            Series3.Add(3.0e+1);
            Series3.Add(-2.0e+2);
            Series3.Add(3.0e+6);
            Series3.Add(-2.0e+1);
            Series3.Add(-3.0e+2);
          
            Series2.VertAxis = VerticalAxis.Right;
            Series1.VertAxis = VerticalAxis.Right;

            Series3.VertAxis = VerticalAxis.Left;
            
            tChart1.Axes.Left.Labels.Exponent = true;
            tChart1.Axes.Right.Labels.Exponent = true;
            //Axis Left
            tChart1.Axes.Left.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Left.Title.Text = "Axis Y1";
            //Axis Right
            tChart1.Axes.Right.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Right.Title.Text = "Axis Y2";
            tChart1.Axes.Bottom.Labels.Exponent = true;
            //Axis Bottom
            tChart1.Axes.Bottom.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Bottom.Title.Text = "Axis X1";
            tChart1.Axes.Bottom.MinimumOffset = 20;
            tChart1.GetAxisLabel += new GetAxisLabelEventHandler(tChart1_GetAxisLabel);
        }
        void tChart1_GetAxisLabel(object sender, GetAxisLabelEventArgs e)
        {
            if (sender == tChart1.Axes.Left)
            {
                if (!checkBox1.Checked)
                {
                    e.LabelText = "";
                }
            }          
        }

        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.ShowEditor();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (Series3!= null)
            {              
                if (checkBox1.Checked)
                {
                    tChart1.Axes.Left.Ticks.Visible = true;
                    Series3.Transparency = 0;
                    Series3.ShowInLegend = true;
                }
                else
                {
                    tChart1.Axes.Left.Ticks.Visible = false;
                    Series3.Transparency = 100;
                    Series3.ShowInLegend = false;
                }
            }
        }
Can you tell if previous code help you to achieve as you want?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sim
Newbie
Newbie
Posts: 19
Joined: Wed Jul 30, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by sim » Fri Apr 13, 2012 3:25 am

Hi sandra,
Sorry, the issue had not been resolved yet. I can not do it as you said. Because the points which combined the series3 is on the graph yet as you said, I want only series1 and series2 on there.
And I think the issus is not easy to solve.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by Sandra » Fri Apr 13, 2012 11:38 am

Hello sim,

Ok. I suggest other solution, where I have drawn the title of vertical axes directly in the canvas.

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Line Series1, Series2, Series3;
        Steema.TeeChart.Tools.Annotation ann;
        private void InitializeChart()
        {

            tChart1.Aspect.View3D = false;
            tChart1.Panel.MarginLeft = 10;
          
            //CheckBox
            checkBox1.Checked = true;
            checkBox1.CheckedChanged += new EventHandler(checkBox1_CheckedChanged);
            Series1 = new Line(tChart1.Chart);
            Series2 = new Line(tChart1.Chart);
            Series3 = new Line(tChart1.Chart);

            Series1.Add(1.0, 1.0);
            Series1.Add(1.0e+3, 1.0e+1);
            Series1.Add(1.0e+5, 1.0e+2);
            Series1.Add(1.0e+6, 1.0e+3);
            Series1.Add(1.0e+1, 1.0e+4);
            Series1.Add(1.0e+8, 1.0e+5);
            Series1.Add(1.0e+7, 1.0e+6);


            Series2.Add(1.0e+3, 3.0e+1);
            Series2.Add(1.0e+5, 1.0e+2);
            Series2.Add(1.0e+6, 2.0e+3);
            Series2.Add(1.0e+1, 1.0e+4);
            Series2.Add(1.0e+8, 1.0e+5);
            Series2.Add(1.0e+7, 3.0e+6);

            Series3.Add(1.0);
            Series3.Add(3.0e+1);
            Series3.Add(-2.0e+2);
            Series3.Add(3.0e+6);
            Series3.Add(-2.0e+1);
            Series3.Add(-3.0e+2);

            Series2.VertAxis = VerticalAxis.Right;
            Series1.VertAxis = VerticalAxis.Right;

            Series3.VertAxis = VerticalAxis.Left;
           

            tChart1.Axes.Left.Labels.Exponent = true;
            tChart1.Axes.Right.Labels.Exponent = true;
            //Axis Left
            tChart1.Axes.Left.Labels.ValueFormat = "#.0 x10 E+0";
            //Axis Right
            tChart1.Axes.Right.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Bottom.Labels.Exponent = true;
            //Axis Bottom
            tChart1.Axes.Bottom.Labels.ValueFormat = "#.0 x10 E+0";
            tChart1.Axes.Bottom.Title.Text = "Axis X1";
            tChart1.Axes.Bottom.MinimumOffset = 20;
            tChart1.AfterDraw += new PaintChartEventHandler(tChart1_AfterDraw);
            tChart1.Draw();
            
        }

        void tChart1_AfterDraw(object sender, Graphics3D g)
        {
            string sleft = "Axis Y1";
            string sright = "Axis Y2";
            string sbottom = "Axis X1";
           
            //Title Axis Left
            g.TextAlign = StringAlignment.Far;
            Rectangle rect = tChart1.Chart.ChartRect;
            g.RotateLabel(rect.Left-(tChart1.Axes.Left.MaxLabelsWidth()+20), (rect.Height+ sleft.Length) / 2 ,sleft,90);
            //Title Axis Right
            g.TextAlign = StringAlignment.Near;
            g.RotateLabel( rect.Right+(tChart1.Axes.Right.MaxLabelsWidth()+20), (rect.Height+sright.Length) / 2 , sright, -90);
            //Title Axis Bottom
        }
         private void button1_Click(object sender, EventArgs e)
        {
            tChart1.ShowEditor();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (Series3 != null)
            {
                if (checkBox1.Checked)
                {
                    tChart1.Axes.Left.Visible = true;
                    Series3.Active = true;
                }
                else
                {
                    tChart1.Axes.Left.Visible = false;
                    Series3.Active = false;
                }
            }
        }
Can you tell us if previous code works as you expect?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sim
Newbie
Newbie
Posts: 19
Joined: Wed Jul 30, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by sim » Mon Apr 16, 2012 7:25 am

Hi sandra,
Ok, thank you very much, I achieve as you said.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: The first label display incomplete in x axis.

Post by Sandra » Mon Apr 16, 2012 12:33 pm

Hello sim,

I am glad that your problem are solved :)

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply