Colorbands

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
NewbieSIM
Newbie
Newbie
Posts: 13
Joined: Thu Jan 29, 2004 5:00 am

Colorbands

Post by NewbieSIM » Tue Oct 05, 2004 7:26 am

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

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Oct 05, 2004 2:15 pm

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();
    }
Marjan Slatinek,
http://www.steema.com

NewbieSIM
Newbie
Newbie
Posts: 13
Joined: Thu Jan 29, 2004 5:00 am

Tried it...still having problem

Post by NewbieSIM » Wed Oct 06, 2004 12:22 pm

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

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Oct 07, 2004 9:25 am

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

NewbieSIM
Newbie
Newbie
Posts: 13
Joined: Thu Jan 29, 2004 5:00 am

Post by NewbieSIM » Thu Oct 07, 2004 10:57 am

:D Thanx !!!!!!!

NewbieSIM
Newbie
Newbie
Posts: 13
Joined: Thu Jan 29, 2004 5:00 am

New Question...regarding the above!

Post by NewbieSIM » Mon Oct 11, 2004 8:46 am

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

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Mon Oct 11, 2004 9:31 am

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
Steema Support

NewbieSIM
Newbie
Newbie
Posts: 13
Joined: Thu Jan 29, 2004 5:00 am

Still a problem though

Post by NewbieSIM » Tue Oct 12, 2004 1:39 pm

Ok.....but how do I get my rectangle to remain on my chart. It dissappears if I resize, or minimise my chart.

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Oct 12, 2004 2:18 pm

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).
Marjan Slatinek,
http://www.steema.com

Post Reply