Page 1 of 1
Colorbands
Posted: Tue Oct 05, 2004 7:26 am
by 8123652
Hi
I want to add a colorband to fill my chart. I am able to set it to the max of the left axis, and it draws the band.
My Question: How do I give it bottom axis date values to stop the band from being drawn. ie if my x axis is from the 1/1/2000 to the 1/12/2000, I only want the band to draw from the 1/1/2000 to the 1/6/2000(thus half the chart will have the colorband)
Or a another way: How do I draw vertical colorbands ie 2 x values for start and end?
thx
NewbieSIM
Posted: Tue Oct 05, 2004 2:15 pm
by Marjan
Hi.
This feature is not supported by color band. It can be connected only to single axis i.e. you can only specify start and end position for x or y values, but not for both at the same time. In case you need to control both directions, then the best solution is to manually draw rectangle directly on chart. You could use the following code:
Code: Select all
private void tChart1_BeforeDrawSeries(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.Brush.Visible = true;
g.Brush.Color = Color.Red;
int l = tChart1.Axes.Bottom.CalcPosValue(DateTime.Parse("01/01/2000").ToOADate());
int r = tChart1.Axes.Bottom.CalcPosValue(DateTime.Parse("12/01/2000").ToOADate());
int b = tChart1.Axes.Left.CalcPosValue(50.0);
int t = tChart1.Axes.Left.CalcPosValue(100.0);
g.ClipRectangle(tChart1.Chart.ChartRect);
g.Rectangle(l,t,r,b);
g.UnClip();
}
Tried it...still having problem
Posted: Wed Oct 06, 2004 12:22 pm
by 8123652
This is my button click event...It fails at the point in (Bold) getting a Null Ref ex. Even if I comment out the clipping parts and only leave g.Rectangle(l, t, r, b) it still gives the ex.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim g As Steema.TeeChart.Drawing.Graphics3D
g = TChart1.Graphics3D
g.Brush.Visible = True
g.Brush.Color = Color.Yellow
Dim l As Integer = TChart1.Axes.Bottom.CalcPosValue(3)
Dim r As Integer = TChart1.Axes.Bottom.CalcPosValue(5)
Dim b As Integer = TChart1.Axes.Left.CalcPosValue(TChart1.Axes.Left.Minimum)
Dim t As Integer = TChart1.Axes.Left.CalcPosValue(TChart1.Axes.Left.Maximum)
g.ClipRectangle(TChart1.Chart.ChartRect)
g.Rectangle(l, t, r, b)
g.UnClip()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
Posted: Thu Oct 07, 2004 9:25 am
by Pep
Hi,
you should place the code in the OnBeforeDrawSeries event, like in the following code :
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
buttonclicked = True
TChart1.Refresh()
End Sub
Private Sub TChart1_BeforeDrawAxes(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.BeforeDrawAxes
If buttonclicked Then
Try
g = TChart1.Graphics3D
g.Brush.Visible = True
g.Brush.Color = Color.Yellow
Dim l As Integer = TChart1.Axes.Bottom.CalcPosValue(3)
Dim r As Integer = TChart1.Axes.Bottom.CalcPosValue(5)
Dim b As Integer = TChart1.Axes.Left.CalcPosValue(TChart1.Axes.Left.Minimum)
Dim t As Integer = TChart1.Axes.Left.CalcPosValue(TChart1.Axes.Left.Maximum)
g.ClipRectangle(TChart1.Chart.ChartRect)
g.Rectangle(l, t, r, b)
g.UnClip()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End If
End Sub
Posted: Thu Oct 07, 2004 10:57 am
by 8123652
Thanx !!!!!!!
New Question...regarding the above!
Posted: Mon Oct 11, 2004 8:46 am
by 8123652
Hi there...
From the help:If you do not place calls to Canvas draw code in one of the Chart events, custom drawing will not be saved to the Canvas permanently thus causing any addition to be lost when an application is minimised or another Window placed over it.
Steema.TeeChart.Canvas.Graphics3D
I have downloaded the latest TeeChart for .NET but can't find the "Canvas" Namespace. Now the rectangles I'm drawing are not being saved to my chart.
Thanx
NewbieSIM
Posted: Mon Oct 11, 2004 9:31 am
by Marc
Hello NewbieSIM
That's a typographical error in the helpfile, it confuses a naming convention used in a different version of TeeChart. Thanks for pointing it out to us. The term Canvas in loose terms applies to the area of the Chart panel upon which the Chart is plotted or to which custom output may be sent, it is not a namespace name as you found in the documentation.
It should read:
Code: Select all
Steema.TeeChart.Drawing.Graphics3D
We'll correct occurrences of this error in the documentation.
Regards,
Marc Meumann
Still a problem though
Posted: Tue Oct 12, 2004 1:39 pm
by 8123652
Ok.....but how do I get my rectangle to remain on my chart. It dissappears if I resize, or minimise my chart.
Posted: Tue Oct 12, 2004 2:18 pm
by Marjan
Hi.
Place it in one of the Chart events, preferably chart AfterDraw event. This event also has a Steema.TeeChart.Drawing.Graphics3D g parameter which you must use as a reference for Graphics3D (see the example).