Hi,
It seems that the lines drawn by the drawline tool do some XOR operation so the color of the line depends on what's drawn below the line.
This can be seen in the following simple example, where the line is drawn in red or blue depending on the gradient in the back wall:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.Walls.Back.Brush.Gradient.StartColor = vbBlack
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues
Dim dline As Integer
dline = TChart1.Tools.Add(tcDrawLine)
With TChart1.Tools.Items(dline).asDrawLine
.EnableDraw = False
.EnableSelect = False
.Pen.Color = vbRed
.AddLine 0, TChart1.Series(0).YValues.Minimum, 24, TChart1.Series(0).YValues.Maximum
End With
End Sub
i've added it to the defect list to be revised for future releases (TV52016572).
In the meanwhile, I only see two options:
- Disable the gradient:
Code: Select all
TChart1.Walls.Back.Gradient.Visible = False
TChart1.Walls.Back.Color = vbWhite
- Manually draw the lines at the OnAfterDraw event. In your example, you can disable the drawline tools:
Code: Select all
Sub DoTChartMouseUp(Shift As Integer, X As Long, Y As Long, EventSelectMode As Integer)
'...
TChart1.Tools(dline).Active = False
End Sub
And then draw the lines manually:
Code: Select all
Private Sub TChart1_OnAfterDraw()
Dim i, StartX, StartY, EndX, EndY As Integer
For i = 0 To TChart1.Tools.Count - 1
If TChart1.Tools.Items(i).ToolType = tcDrawLine Then
With TChart1.Tools.Items(i).asDrawLine
TChart1.Canvas.Pen.Color = .Pen.Color
StartX = TChart1.axis.Bottom.CalcXPosValue(.Lines.Items(0).StartPos.X)
StartY = TChart1.axis.Left.CalcYPosValue(.Lines.Items(0).StartPos.Y)
EndX = TChart1.axis.Bottom.CalcXPosValue(.Lines.Items(0).EndPos.X)
EndY = TChart1.axis.Left.CalcYPosValue(.Lines.Items(0).EndPos.Y)
TChart1.Canvas.DrawLine StartX, StartY, EndX, EndY
End With
End If
Next i
End Sub