Assign different Color to GridLine for Axis in Line Graph

TeeChart for ActiveX, COM and ASP
Post Reply
CS
Newbie
Newbie
Posts: 22
Joined: Sat Jun 08, 2002 4:00 am

Assign different Color to GridLine for Axis in Line Graph

Post by CS » Mon Jun 21, 2010 6:21 am

Hi,

I have requirement in which I need to give different colors to Grid Lines in Left Axis.


Can you help me on this ?

Thanks,
CS
Attachments
Color.JPG
Color.JPG (22.66 KiB) Viewed 3949 times

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Assign different Color to GridLine for Axis in Line Graph

Post by Yeray » Mon Jun 21, 2010 9:36 am

Hi CS,

I'd recommend you to hide the grid lines and use ColorLine tools to draw each line in the color you want. For example:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  
  TChart1.AddSeries scFastLine
  TChart1.Series(0).FillSampleValues
  
  TChart1.Axis.Left.GridPen.Visible = False
  TChart1.Environment.InternalRepaint
    
  Dim i As Integer
  For i = 0 To TChart1.Axis.Left.Labels.Count - 1
    TChart1.Tools.Add tcColorLine
    With TChart1.Tools.Items(i).asColorLine
      .Axis = TChart1.Axis.Left
      .Value = TChart1.Axis.Left.Labels.Item(i).Value
      .Pen.Color = RGB(Rnd * 254, Rnd * 254, Rnd * 254)
    End With
  Next i
End Sub
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply