Drawing Horizontal Line on Chart
-
- Newbie
- Posts: 11
- Joined: Tue Nov 02, 2010 12:00 am
Drawing Horizontal Line on Chart
I have a chart whose Left axis represents a percentage from 0% to 100%. I need to draw a horizontal line across the entire chart at the 35% coordinate. I understand how to draw a horizontal line in the AfterDraw event. How do I determine where the 35% line should be located?
Re: Drawing Horizontal Line on Chart
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 |
-
- Newbie
- Posts: 11
- Joined: Tue Nov 02, 2010 12:00 am
Re: Drawing Horizontal Line on Chart
No, that does not help. I have 2D chart. I need to know how to determine the vertical coordinate for the 35% mark on the left axis of the chart. I can then draw the line I need using this code in the AfterDraw event:
Code: Select all
int pt35 = ???
Point s = new Point(_chart.Axes.Left.Position, pt35);
Point e = new Point(_chart.Axes.Right.Position, pt35);
g.MoveTo(s);
g.LineTo(e, 0);
Re: Drawing Horizontal Line on Chart
Hello tcorrigan5,
You can do something as next code:
Could you tell us if previous code works as you want?
I hope will helps.
Thanks,
You can do something as next code:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
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.FillSampleValues();
line2.FillSampleValues();
Steema.TeeChart.Axis axis = new Steema.TeeChart.Axis(tChart1.Chart);
tChart1.Axes.Custom.Add(axis);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.Pen.Color = Color.Red;
int value =tChart1.Axes.Left.CalcYPosValue(tChart1.Axes.Left.IAxisSize * 35 / 100);
g.Line(tChart1.Axes.Bottom.IStartPos, value, tChart1.Axes.Bottom.IEndPos, value);
}
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 |
-
- Newbie
- Posts: 11
- Joined: Tue Nov 02, 2010 12:00 am
Re: Drawing Horizontal Line on Chart
No, your code doesn't work but this does:
i.e., you don't need the IAxisSize factor in the calculation.
Code: Select all
int value = _chart.Axes.Left.CalcYPosValue(0.35);
g.Line(_chart.Axes.Bottom.IStartPos, value, _chart.Axes.Bottom.IEndPos, value);
Re: Drawing Horizontal Line on Chart
Hello tcorrigan5,
You need IAxisSize value for calculate value that corresponds 35% of axes size, because you have to sum it to StartPosition of Axes for get the correct position of line that you want draw. You can do it as in next code:
I hope will helps.
Thanks
You need IAxisSize value for calculate value that corresponds 35% of axes size, because you have to sum it to StartPosition of Axes for get the correct position of line that you want draw. You can do it as in next code:
Code: Select all
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.FillSampleValues();
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.Pen.Color = Color.Red;
int pos = tChart1.Axes.Left.IStartPos + (tChart1.Axes.Left.IAxisSize * 35) / 100;
g.Line(tChart1.Axes.Bottom.IStartPos, pos, tChart1.Axes.Bottom.IEndPos, pos);
}
}
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 |