Page 1 of 1

DrawLine color different than the value specified

Posted: Mon May 06, 2013 10:35 pm
by 13052810
Hello,

I'm trying to figure out why the color of the DrawLine is not the color that I have selected.
I did try a small test project, and there it seems to be working correctly, however in my project it does not.
Obviously, in my project, I have set something that has caused this, but I can't seem to locate the culprit.

General usage:

Code: Select all

dline = TChart1.Tools.Add(tcDrawLine)

other code
other code

With TChart1.Tools.Items(dline).asDrawLine
        .Pen.Color = vbRed
        .EnableDraw = False
        .EnableSelect = False
        .AddLine grfXStart, grfYStart, grfXEnd, grfYEnd
End With
With this code, the line is Cyan colored.
One clue may be that if I set the color to vbBlack, the line will be white,
if I set the color to vbWhite, the line will be black.

What settings can cause this to happen that I might have inadvertantly changed?

Thanks!

Re: DrawLine color different than the value specified

Posted: Wed May 08, 2013 1:47 pm
by 10050769
Hello tirby,

I can't reproduce your problem, so the colors of DrawLine tool, change correctly using latest version of TeeChartForActivex (v2012.0.0.9 ) and the code you attached. I would be very grateful if you can send us your project, because can help you to find a solution for your problem

Thanks,

Re: DrawLine color different than the value specified

Posted: Wed May 08, 2013 7:54 pm
by 13052810
Thanks Sandra,

Here is a project that demonstrates the issue.
1. Select a color in the listbox at the lower left corner of the screen.
This will/should make both the Rectangle and the DrawLine the same color selected.

2. Click on the trace (at any point). this will place a Rectangle and Drawline from the trace to the Retangle.
Note the DrawLine will be a different color.

3. I noticed that if you click on the trace such that the DrawLine is directly over the trace, it's color is correct.

Re: DrawLine color different than the value specified

Posted: Wed May 15, 2013 1:29 pm
by yeray
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

Re: DrawLine color different than the value specified

Posted: Wed May 15, 2013 5:54 pm
by 13052810
Thanks Yeray!

Any idea on when the next release may be?

Re: DrawLine color different than the value specified

Posted: Thu May 16, 2013 7:13 am
by yeray
Hi,

We are working on it. If we don't find major problems I hope we can publish it very soon.

Re: DrawLine color different than the value specified

Posted: Fri May 24, 2013 1:55 pm
by 13052810
I have discovered that if I XOR the desired color with VBWhite, the colors are correct!

It's a quick fix, but it works!