TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
stratadat
- Newbie
- Posts: 13
- Joined: Mon Feb 13, 2006 12:00 am
Post
by stratadat » Fri May 04, 2007 9:59 am
For building financial type charts we use custom vertical axes to have both left and right axes and place one chart under another. Everything works as expected.
Our application requires an ability to place a custom line on chart. To accomplish that we use DrawLine tool and the following code:
Code: Select all
DrawLine drawLine = new DrawLine(TeeChart.Chart);
drawLine.EnableDraw = false;
DrawLineItem item = new DrawLineItem(drawLine);
double startX = TeeChart.Axes.Bottom.Minimum + 10;
double startY = TeeChart.Axes.Left.Minimum + 10;
double endX = TeeChart.Axes.Bottom.Maximum - 10;
double endY = TeeChart.Axes.Left.Maximum - 10;
item.StartPos.X = startX;
item.StartPos.Y = startY;
item.EndPos.X = endX;
item.EndPos.Y = endY;
drawLine.Invalidate();
As a result sometimes line does not show up at all, sometimes it shows up but does not allow to resize.
Sometimes lines are now shown, but when chart is saved and opened from file lines are shown.
Please advise.
-
Narcís
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Fri May 04, 2007 10:24 am
Hi stratadat,
The line may not be drawn because your chart hasn't been painted yet and thus axes minimum and maximum properties don't have valid values yet.
It works fine for me here using the code below. You'll notice that before drawing the line I make a Bitmap call to force the chart being internally painted and make properties having valid values.
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
candle1.FillSampleValues();
Steema.TeeChart.Tools.DrawLine drawLine = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
drawLine.EnableDraw = false;
Steema.TeeChart.Tools.DrawLineItem item = new Steema.TeeChart.Tools.DrawLineItem(drawLine);
Bitmap bmp = tChart1.Bitmap;
double startX = tChart1.Axes.Bottom.Minimum + 10;
double startY = tChart1.Axes.Left.Minimum + 10;
double endX = tChart1.Axes.Bottom.Maximum - 10;
double endY = tChart1.Axes.Left.Maximum - 10;
item.StartPos.X = startX;
item.StartPos.Y = startY;
item.EndPos.X = endX;
item.EndPos.Y = endY;
drawLine.Invalidate();
}
-
stratadat
- Newbie
- Posts: 13
- Joined: Mon Feb 13, 2006 12:00 am
Post
by stratadat » Fri May 04, 2007 11:36 am
Sorry, you code does not work for me as well. We have found strange thing while debugging - when line is not displayed the values of StartHandle and EndHandle properties of DrawLineItem is System.NullReferenceException
-
Narcís
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Fri May 04, 2007 11:38 am
Hi stratadat,
Could you please send us a simple example project we can run "as-is" to reproduce your problem here?
You can either post your files at news://
www.steema.net/steema.public.attachments newsgroup or at our
upload page.
Thanks in advance.