Map 0 from Axes.Left to 0 from Axes.Right
Map 0 from Axes.Left to 0 from Axes.Right
I have chart with dollar amount on left axes and non dollar value on right axis. If both sides have just positive values it working fine. In my case left axis has negative and positive values, but right axis has just positive. And 0 from right axis did not line up with 0 on left axis. How can I fix it? Line up 0 from both axis.
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hello Neelman,
You could do a similar code that next example that works fine here with last version of TeeChart .Net:
Could you please say us if previous lines of code works as you want? If it in not a good solution for you, please you could modify the code because we can reproduce exactly, your problem here and we can try to make a solution for you.
I hope will helps.
Thanks,
You could do a similar code that next example that works fine here with last version of TeeChart .Net:
Code: Select all
private Steema.TeeChart.Styles.Line line1;
private void InitializeChart()
{
Random rnd = new Random();
tChart1.Aspect.View3D = false;
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
line1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Both;
}
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 |
Instructions - How to post in this forum |
Re: Map 0 from Axes.Left to 0 from Axes.Right
I have TeeChart version 3.5.3700.30575 and this example did not work. Problem still exists: 0 from left Axis did not line up with 0 from right axis in case if left value below 0.
Please advise.
Thnaks.
Please advise.
Thnaks.
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hello Neelam,
I have made other code using SetMinMax() property that allow align correctly Right and Left axes values. I think that use similar code as next for solves your problem.
Could you please, tell us if previous code works as you want?
I hope will helps.
Thanks,
I have made other code using SetMinMax() property that allow align correctly Right and Left axes values. I think that use similar code as next for solves your problem.
Code: Select all
private Steema.TeeChart.Styles.Line line1, line2;
private void InitializeChart()
{
double MinValue, MaxValue;
tChart1.Aspect.View3D = false;
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
line2.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
for (int i = 0; i < 10; i++)
{
if (i < 5)
{
line1.Add(i * 2, -5 + i);
}
else if (i == 5)
{
line1.Add(i * 2, 0);
}
else
{
line1.Add(i * 2, i - 5);
}
line2.Add(i, i);
}
MinValue= Math.Min(line1.MinYValue(), line2.MinYValue());
MaxValue = Math.Max(line1.MaxYValue(), line2.MaxYValue());
tChart1.Axes.Left.SetMinMax(MinValue, MaxValue);
tChart1.Axes.Right.SetMinMax(MinValue,MaxValue);
}
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 |
Instructions - How to post in this forum |
Re: Map 0 from Axes.Left to 0 from Axes.Right
This example is different from my objective. Left and Right axes have different scales. I cannot set same scale for left and right axis. In my case left axis has one scale (dollar amount) and right axis has another scale (non dollar numbers). If left and right axes have positive values it’s aligning correctly, because its starts from 0(Min=0). But if left axis has negative value (Min<0 for example= -1980) and right axis has just positive number (Min=0) it aligns -1980 on left side to 0 on right side. I need to adjust right axis scale to line up 0 from left axis to 0 on right axis.
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hi Neelam,
We'll study it and we'll be back to you here asap.
We'll study it and we'll be back to you here asap.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hello Neelam,
I have made a simple example using property of axes, EndPosition, and I think that you can use it in your application for solve your problem with axes.
Could you please say us if previous code works as you want?
I hope will helps.
Thanks,
I have made a simple example using property of axes, EndPosition, and I think that you can use it in your application for solve your problem with axes.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Line lineSeries1;
private Steema.TeeChart.Styles.Line line1, line2;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
line2.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
for (int i = 0; i < 10; i++)
{
if (i < 5)
{
line1.Add(i * 2, -5 + i);
}
else if (i == 5)
{
line1.Add(i * 2, 0);
}
else
{
line1.Add(i * 2, i - 5);
}
line2.Add(i, i);
}
double MinValue, MaxValue;
MinValue = Math.Min(line1.MinYValue(), line2.MinYValue());
MaxValue = Math.Max(line1.MaxYValue(), line2.MaxYValue());
tChart1.Axes.Left.SetMinMax(MinValue, MaxValue);
tChart1.Axes.Right.SetMinMax(line2.MinYValue(), line2.MaxYValue());
tChart1.Draw();
int zeroPos = tChart1.Axes.Left.CalcPosValue(0.0);
int axisSize = tChart1.Axes.Left.IAxisSize;
tChart1.Axes.Right.StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
tChart1.Axes.Right.EndPosition = zeroPos - 34;
}
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 |
Instructions - How to post in this forum |
Re: Map 0 from Axes.Left to 0 from Axes.Right
Can you explain from last line of code 'tChart1.Axes.Right.EndPosition = zeroPos - 34; ' what is 34? What is comes from?
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hello Neelman,
Can you please, say us if our solution works fine for you?
I hope will helps.
Thanks,
Value 34 is a value that I calculate, because axes right position, exactly matches with position 0 of left axis as there are a difference some pixels when you draw axis right that start to zeroPos. If you prefer you can calculate it value using next lines of code:Can you explain from last line of code 'tChart1.Axes.Right.EndPosition = zeroPos - 34; ' what is 34?
Code: Select all
int axisSize = (int)(tChart1.Axes.Right.IAxisSize / tChart1.Axes.Right.MaxYValue);
tChart1.Axes.Right.StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
tChart1.Axes.Right.EndPosition = zeroPos - (axisSize+8);
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 |
Instructions - How to post in this forum |
Re: Map 0 from Axes.Left to 0 from Axes.Right
Still not working as expected. In line "tChart1.Axes.Right.EndPosition = zeroPos - (axisSize+8);" what is meanning for 8?
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hello Nelman,
We don't sure that you want do exactly. Could you please send us a simple code, so we can try to find a good solution for you?
Thanks,
We don't sure that you want do exactly. Could you please send us a simple 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 |
Instructions - How to post in this forum |
Re: Map 0 from Axes.Left to 0 from Axes.Right
Below is a simple code to reproduce this issue. Create project, add chart control and name it tcCurve.Sandra wrote:Hello Nelman,
We don't sure that you want do exactly. Could you please send us a simple code, so we can try to find a good solution for you?
Thanks,
Run project and on chart you will see issue.
Thanks.
Code: Select all
Private Sub LoadChart()
Dim arBarSeriesA As New Steema.TeeChart.Styles.Bar
Dim arBarSeriesB As New Steema.TeeChart.Styles.Bar
Dim arBarSeriesA1 As New Steema.TeeChart.Styles.Bar
Dim arBarSeriesB1 As New Steema.TeeChart.Styles.Bar
tcCurve.Axes.Left.Grid.Visible = True
tcCurve.Axes.Left.Grid.Style = Drawing2D.DashStyle.Solid
arBarSeriesA.Labels.Add(Format(3000, "$##,##0.00"))
arBarSeriesA.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right
arBarSeriesA.Add(3000)
arBarSeriesA.ShowInLegend = True
arBarSeriesA.BarWidthPercent = 120
arBarSeriesA.Marks.Angle = 90
arBarSeriesA.OffsetPercent = -30
tcCurve.Series.Add(arBarSeriesA)
arBarSeriesA1.Labels.Add(Format(2560, "$##,##0.00"))
arBarSeriesA1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right
arBarSeriesA1.Add(2560)
arBarSeriesA1.ShowInLegend = True
arBarSeriesA1.BarWidthPercent = 120
arBarSeriesA1.Marks.Angle = 90
arBarSeriesA1.OffsetPercent = -30
tcCurve.Series.Add(arBarSeriesA1)
arBarSeriesB.Labels.Add(-1000)
arBarSeriesB.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left
arBarSeriesB.Add(-1000)
arBarSeriesB.ShowInLegend = True
arBarSeriesB.BarWidthPercent = 120
arBarSeriesB.Marks.Angle = 90
arBarSeriesB.OffsetPercent = -30
tcCurve.Series.Add(arBarSeriesB)
arBarSeriesB1.Labels.Add(1500)
arBarSeriesB1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left
arBarSeriesB1.Add(1500)
arBarSeriesB1.ShowInLegend = True
arBarSeriesB1.BarWidthPercent = 120
arBarSeriesB1.Marks.Angle = 90
arBarSeriesB1.OffsetPercent = -30
tcCurve.Series.Add(arBarSeriesB1)
tcCurve.Refresh()
End Sub
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hi Neelam,
Can you please try running the example Sandra posted? I think it already does what you are asking for. You can convert them from C# to VB using any of those free on-line conversors:
http://www.carlosag.net/Tools/CodeTranslator/
http://authors.aspalliance.com/aldotnet ... slate.aspx
http://www.developerfusion.com/tools/co ... arp-to-vb/
http://converter.telerik.com/
If Sandra example don't fit your needs please net us know which is the exact problem you have with it.
Thanks in advance.
Can you please try running the example Sandra posted? I think it already does what you are asking for. You can convert them from C# to VB using any of those free on-line conversors:
http://www.carlosag.net/Tools/CodeTranslator/
http://authors.aspalliance.com/aldotnet ... slate.aspx
http://www.developerfusion.com/tools/co ... arp-to-vb/
http://converter.telerik.com/
If Sandra example don't fit your needs please net us know which is the exact problem you have with it.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Map 0 from Axes.Left to 0 from Axes.Right
Did you try Sandra's example on my issue? It simple does not work for my case. I do not care about language (VB.net or C#).
Did you run my code? Did you see issue?
Thanks.
Did you run my code? Did you see issue?
Thanks.
Re: Map 0 from Axes.Left to 0 from Axes.Right
Hello Neelam
I have modified your code, adding part of my code where I calculate value and position of axes (Right, Left). Please, check if next code works for you.
If previous code doesn’t work for you, could you please, modify or explain what is your exactly problem? Because we can try help you.
I hope will helps.
Thanks,
I have modified your code, adding part of my code where I calculate value and position of axes (Right, Left). Please, check if next code works for you.
Code: Select all
public Form1()
{
InitializeComponent();
LoadChart();
}
private void LoadChart()
{
Steema.TeeChart.Styles.Bar arBarSeriesA = new Steema.TeeChart.Styles.Bar();
Steema.TeeChart.Styles.Bar arBarSeriesB = new Steema.TeeChart.Styles.Bar();
Steema.TeeChart.Styles.Bar arBarSeriesA1 = new Steema.TeeChart.Styles.Bar();
Steema.TeeChart.Styles.Bar arBarSeriesB1 = new Steema.TeeChart.Styles.Bar();
tChart1.Axes.Left.Grid.Visible = true;
tChart1.Axes.Left.Grid.Style = System.Drawing.Drawing2D.DashStyle.Solid;
arBarSeriesA.Labels.Add("$##,##0.00");
arBarSeriesA.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
arBarSeriesA.Add(3000);
arBarSeriesA.ShowInLegend = true;
arBarSeriesA.BarWidthPercent = 120;
arBarSeriesA.Marks.Angle = 90;
arBarSeriesA.OffsetPercent = -30;
tChart1.Series.Add(arBarSeriesA);
arBarSeriesA1.Labels.Add("$##,##0.00");
arBarSeriesA1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
arBarSeriesA1.Add(2560);
arBarSeriesA1.ShowInLegend = true;
arBarSeriesA1.BarWidthPercent = 120;
arBarSeriesA1.Marks.Angle = 90;
arBarSeriesA1.OffsetPercent = -30;
tChart1.Series.Add(arBarSeriesA1);
arBarSeriesB.Labels.Add(-1000);
arBarSeriesB.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
arBarSeriesB.Add(-1000);
arBarSeriesB.ShowInLegend = true;
arBarSeriesB.BarWidthPercent = 120;
arBarSeriesB.Marks.Angle = 90;
arBarSeriesB.OffsetPercent = -30;
tChart1.Series.Add(arBarSeriesB);
arBarSeriesB1.Labels.Add(1500);
arBarSeriesB1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
arBarSeriesB1.Add(1500);
arBarSeriesB1.ShowInLegend = true;
arBarSeriesB1.BarWidthPercent = 120;
arBarSeriesB1.Marks.Angle = 90;
arBarSeriesB1.OffsetPercent = -30;
tChart1.Series.Add(arBarSeriesB1);
double MinValue, MaxValue;
MinValue = Math.Min(Math.Min(arBarSeriesA.MinYValue(), arBarSeriesA1.MinYValue()), Math.Min(arBarSeriesB.MinYValue(), arBarSeriesB1.MinYValue()));
MaxValue = Math.Max(Math.Max(arBarSeriesB.MaxYValue(), arBarSeriesB1.MaxYValue()), Math.Max(arBarSeriesA.MaxYValue(), arBarSeriesA1.MaxYValue()));
tChart1.Axes.Left.SetMinMax(MinValue, MaxValue);
tChart1.Axes.Right.SetMinMax(Math.Min(arBarSeriesA.MinYValue(), arBarSeriesA1.MinYValue()), Math.Max(arBarSeriesA.MaxYValue(), arBarSeriesA1.MaxYValue()));
tChart1.Draw();
int zeroPos = tChart1.Axes.Left.CalcPosValue(0.0);
int axisSize = tChart1.Axes.Left.IAxisSize;
tChart1.Axes.Right.StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
tChart1.Axes.Right.EndPosition = zeroPos - 38;
}
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 |
Instructions - How to post in this forum |