DrawLine color different than the value specified

TeeChart for ActiveX, COM and ASP
Post Reply
tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

DrawLine color different than the value specified

Post by tirby » Mon May 06, 2013 10:35 pm

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!
Last edited by tirby on Mon May 13, 2013 2:50 pm, edited 1 time in total.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: DrawLine color different than the value specified

Post by Sandra » Wed May 08, 2013 1:47 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: DrawLine color different than the value specified

Post by tirby » Wed May 08, 2013 7:54 pm

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.
Attachments
CTest5.Zip
(34.42 KiB) Downloaded 983 times

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

Re: DrawLine color different than the value specified

Post by Yeray » Wed May 15, 2013 1:29 pm

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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: DrawLine color different than the value specified

Post by tirby » Wed May 15, 2013 5:54 pm

Thanks Yeray!

Any idea on when the next release may be?

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

Re: DrawLine color different than the value specified

Post by Yeray » Thu May 16, 2013 7:13 am

Hi,

We are working on it. If we don't find major problems I hope we can publish it very soon.
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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: DrawLine color different than the value specified

Post by tirby » Fri May 24, 2013 1:55 pm

I have discovered that if I XOR the desired color with VBWhite, the colors are correct!

It's a quick fix, but it works!

Post Reply