Line next to Y Axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Line next to Y Axis

Post by mikethelad » Mon Mar 18, 2013 9:25 am

Have a line graph with a scale of -100 to 100, but require a line at 0, I have added a line but using value of 0, but this needs to be right next to the 0 on the Y-Axis with no gap, but still maintain the gap on the other lines.
Attachments
graph.JPG
graph.JPG (84.53 KiB) Viewed 15323 times

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

Re: Line next to Y Axis

Post by Sandra » Mon Mar 18, 2013 1:24 pm

Hello mikethelad,

Ok. I have made a simple project where the first line is drawn gap to left axis and second line is drawn on the left axis. To achieve it I have used a extra horizontal axis I have assigned to second line. Please, see next code:

Code: Select all

      Steema.TeeChart.Styles.Line line1, line2;
        Steema.TeeChart.Axis axis1;
        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            line1 = new Line(tChart1.Chart);
            line2 = new Line(tChart1.Chart);
            //Custom Horizontal Axis
            axis1 = new Axis(tChart1.Chart);
            axis1.Horizontal = true;
            tChart1.Axes.Custom.Add(axis1);
            //Populate
            Random rnd = new Random();
            for (int i = 0; i < 10; i  )
            {
                line1.Add(((i   100)*2), rnd.Next(100));
                line2.Add(((i   100)* 2),0);
            }
            //Assign line axis
            line1.HorizAxis = HorizontalAxis.Bottom;
            line2.CustomHorizAxis = axis1;
            // Customize axis.
            tChart1.Axes.Left.SetMinMax(-100, 100);
            tChart1.Axes.Bottom.StartPosition = 1;
            tChart1.Axes.Left.AxisPen.Visible = false;
            tChart1.Axes.Bottom.AxisPen.Visible = false;
            axis1.SetMinMax(line2.XValues.Minimum, line2.XValues.Maximum);
            axis1.Labels.Visible = false;
            axis1.AxisPen.Visible = false;
            
        }
Could you tell us if previous code works in your end? If you have any problems please let me know.

I hope will helps.

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

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Line next to Y Axis

Post by mikethelad » Mon Mar 18, 2013 2:17 pm

Thanks, does not like the following line


tChart1.Axes.Custom.Add(axis1);

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

Re: Line next to Y Axis

Post by Sandra » Mon Mar 18, 2013 3:07 pm

Hello mikethelad,


Sorry, but I don't understand what is the problem because the code works in correct way for me. Would be very grateful if you can tell us the exactly problem you have with line of code tChart1.Axes.Custom.Add(axis1);

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

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Line next to Y Axis

Post by mikethelad » Mon Mar 18, 2013 3:16 pm

See attached screen shot
Attachments
error.JPG
error.JPG (54.83 KiB) Viewed 15227 times

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

Re: Line next to Y Axis

Post by Sandra » Mon Mar 18, 2013 4:33 pm

Hello mikethelad,

Ok. I have attached my test project that works fine in my machine. Please, check if the code works in your end.
TestVisualStudio2010.zip
(11 KiB) Downloaded 489 times
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

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Line next to Y Axis

Post by mikethelad » Mon Mar 18, 2013 4:38 pm

I am using Visual Studio 2008, could that be why?

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

Re: Line next to Y Axis

Post by Sandra » Tue Mar 19, 2013 9:46 am

Hello mikethelad,


Ok. I have attached a project made in VS2008. Please, check if it works in your end.
TestSourceCode.zip
(10.27 KiB) Downloaded 497 times
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

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Line next to Y Axis

Post by mikethelad » Tue Mar 19, 2013 3:48 pm

Ok that work fine, will have to try work out the issue with my app, as mine is a web app

Can the -100, 0 , 100 on the Y Axis scale be made bold?

Can the X Axis be inline with -100 and not below, I have the following code for the scale


WebChart1.Chart.Axes.Left.SetMinMax(-100, 100);

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

Re: Line next to Y Axis

Post by Sandra » Wed Mar 20, 2013 9:19 am

Hello mikethelad,

Thanks for information. Now I see the problem in your code. I have modify my code for you because it works with WebChart, please check if code works in your end:

Code: Select all

 protected void Page_Load(object sender, EventArgs e)
    {
        InitializeChart();
    }

        Steema.TeeChart.Styles.Line line1, line2;
        Steema.TeeChart.Axis axis1;
     
        private void InitializeChart()
        {
            WebChart1.Chart.Aspect.View3D = false;
            line1 = new Line(WebChart1.Chart);
            line2 = new Line(WebChart1.Chart);
            axis1 = new Axis(WebChart1.Chart);

            WebChart1.Chart.Axes.Custom.Add(axis1);
            axis1.Horizontal = true;
            Random rnd = new Random();
            for (int i = 0; i < 10; i  )
            {
                line1.Add(((i   100) * 2), rnd.Next(100));
                line2.Add(((i   100) * 2), 0);
            }
            line1.VertAxis = VerticalAxis.Left;
            line1.HorizAxis = HorizontalAxis.Bottom;
            line2.VertAxis = VerticalAxis.Left;
            line2.CustomHorizAxis = axis1;
            axis1.SetMinMax(line2.XValues.Minimum, line2.XValues.Maximum);
            axis1.Labels.Visible = false;
            WebChart1.Chart.Axes.Left.SetMinMax(-100, 100);
            WebChart1.Chart.Axes.Bottom.StartPosition = 1;
            WebChart1.Chart.Axes.Left.AxisPen.Visible = false;
            WebChart1.Chart.Axes.Bottom.AxisPen.Visible = false;
            axis1.AxisPen.Visible = false;
        }

I hope will be help.

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

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Line next to Y Axis

Post by mikethelad » Wed Mar 20, 2013 9:52 am

Great, works see new sample,

Can the X Axis be inline with -100 and not below?
Attachments
graph1.JPG
graph1.JPG (81.17 KiB) Viewed 15209 times

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

Re: Line next to Y Axis

Post by Sandra » Wed Mar 20, 2013 3:02 pm

Hello mikethelad,

I am afraid I can not reproduce your problem using last version of TeeChartFor.Net, could you tell us which version are you using? On the other hand, a solution for you is change the minimum offset of Left Axis, as do in next line of code:

Code: Select all

WebChart1.Chart.Axes.Left.MinimumOffset = -1;
I hope will helps.

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

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Line next to Y Axis

Post by mikethelad » Wed Mar 20, 2013 3:26 pm

Thanks, had this set for some reason

WebChart1.Chart.Axes.Left.MinimumOffset = 15;

Assume Bold of the 0 ,100 and - 100 on the scale is not possible

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Line next to Y Axis

Post by Narcís » Tue Apr 02, 2013 8:27 am

Hi mikethelad,

Is not possible to customize the font style for specific labels. For that you should use custom axis labels as demoed in the All Features\Welcome\Axes\Custom labels example at the features demo, available at TeeChart's program group.
Best Regards,
Narcís Calvet / 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