Page 1 of 1
Line next to Y Axis
Posted: Mon Mar 18, 2013 9:25 am
by 15662902
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.
Re: Line next to Y Axis
Posted: Mon Mar 18, 2013 1:24 pm
by 10050769
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,
Re: Line next to Y Axis
Posted: Mon Mar 18, 2013 2:17 pm
by 15662902
Thanks, does not like the following line
tChart1.Axes.Custom.Add(axis1);
Re: Line next to Y Axis
Posted: Mon Mar 18, 2013 3:07 pm
by 10050769
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,
Re: Line next to Y Axis
Posted: Mon Mar 18, 2013 3:16 pm
by 15662902
See attached screen shot
Re: Line next to Y Axis
Posted: Mon Mar 18, 2013 4:33 pm
by 10050769
Hello mikethelad,
Ok. I have attached my test project that works fine in my machine. Please, check if the code works in your end.
Thanks,
Re: Line next to Y Axis
Posted: Mon Mar 18, 2013 4:38 pm
by 15662902
I am using Visual Studio 2008, could that be why?
Re: Line next to Y Axis
Posted: Tue Mar 19, 2013 9:46 am
by 10050769
Hello mikethelad,
Ok. I have attached a project made in VS2008. Please, check if it works in your end.
Thanks,
Re: Line next to Y Axis
Posted: Tue Mar 19, 2013 3:48 pm
by 15662902
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);
Re: Line next to Y Axis
Posted: Wed Mar 20, 2013 9:19 am
by 10050769
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,
Re: Line next to Y Axis
Posted: Wed Mar 20, 2013 9:52 am
by 15662902
Great, works see new sample,
Can the X Axis be inline with -100 and not below?
Re: Line next to Y Axis
Posted: Wed Mar 20, 2013 3:02 pm
by 10050769
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,
Re: Line next to Y Axis
Posted: Wed Mar 20, 2013 3:26 pm
by 15662902
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
Re: Line next to Y Axis
Posted: Tue Apr 02, 2013 8:27 am
by narcis
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.