Page 1 of 1

Assign different Color to GridLine for Axis in Line Graph

Posted: Mon Jun 21, 2010 6:21 am
by 6924564
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

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

Posted: Mon Jun 21, 2010 9:36 am
by yeray
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