Colorbands
Colorbands
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
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
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:
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();
}
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Tried it...still having problem
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
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
Hi,
you should place the code in the OnBeforeDrawSeries event, like in the following code :
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
Pep Jorge
http://support.steema.com
http://support.steema.com
New Question...regarding the above!
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
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
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:
We'll correct occurrences of this error in the documentation.
Regards,
Marc Meumann
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
Regards,
Marc Meumann
Steema Support
Still a problem though
Ok.....but how do I get my rectangle to remain on my chart. It dissappears if I resize, or minimise my chart.
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).
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).
Marjan Slatinek,
http://www.steema.com
http://www.steema.com