Canvas.Brush.Color in OnLegendDrawSymbol

TeeChart for ActiveX, COM and ASP
Post Reply
thatnerdyguy
Newbie
Newbie
Posts: 14
Joined: Thu May 18, 2006 12:00 am

Canvas.Brush.Color in OnLegendDrawSymbol

Post by thatnerdyguy » Wed Jun 06, 2007 7:47 pm

If I use the following code, it appears that the Canvas.Brush.Color is not getting picked up, when it draws the brush pattern, black is the fore color used instead of the color I want:

Code: Select all

Private Sub Form_Load()
    TChart1.AddSeries scArea
    TChart1.Series(0).FillSampleValues (10)
    TChart1.Legend.Visible = True
End Sub


Private Sub TChart1_OnLegendDrawSymbol(ByVal Series As Long, ByVal ValueIndex As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
    TChart1.Canvas.Pen.Color = RGB(0, 0, 255)
    TChart1.Canvas.Pen.Style = psSolid
    
    'Can't do this, it fails
    'TChart1.Canvas.Brush.ClearImage
    
    TChart1.Canvas.Brush.Color = RGB(255, 0, 0)
    TChart1.Canvas.Brush.Style = bsCrossSmall
    
    TChart1.Canvas.BackColor = RGB(0, 255, 0)
    TChart1.Canvas.BackMode = cbmOpaque
    
    TChart1.Canvas.Rectangle Left, Top, Right, Bottom
End Sub
If I use a "regular" Brush.Style like bsHorizontal, bsCross, bsVertical, etc.. it seems fine. Only when I use one of the styles above bsDiagCross does it not work.

My standard way of fixing this is a strategically placed Brush.ClearImage() call, but when called on the canvas brush here, it fails/crashes.

Note that I am doing this in the first place because it appears the standard drawing code for the legend inverts the foreground and background colors for the brushes. For example, running below:

Code: Select all

Private Sub Form_Load()
    TChart1.AddSeries scArea
    TChart1.Series(0).FillSampleValues (10)
    TChart1.Legend.Visible = True
    
    TChart1.Series(0).asArea.AreaChartBrush.Color = RGB(255, 0, 0)
    TChart1.Series(0).asArea.AreaChartBrush.Style = bsDiagSmall
    TChart1.Series(0).asArea.AreaColor = RGB(0, 255, 0)
End Sub
You can see that in the actual chart, red is the background, and green is the foreground. In the legend, the symbol is drawn with green as the background, and red as the foreground.

So, I guess if either one of these issues is fixed, it will help me.

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 07, 2007 2:28 pm

Hi thatnerdyguy,

Thanks for reporting.

I've added the issue to our defect list (TA05012245) to be fixed for future releases. I guess it is very similar or even related to the issue you reported here.
Best Regards,
Narcís Calvet / 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

thatnerdyguy
Newbie
Newbie
Posts: 14
Joined: Thu May 18, 2006 12:00 am

Post by thatnerdyguy » Thu Jun 07, 2007 2:40 pm

Ok, great!

Do you have any sort of idea in what type of time frame these fixes would be released in? A month? 6 months? next major release?

Thanks.

thatnerdyguy
Newbie
Newbie
Posts: 14
Joined: Thu May 18, 2006 12:00 am

Post by thatnerdyguy » Thu Jun 21, 2007 7:19 pm

*bump*

I just need to know if this fix will be released in the next month or so. We are going to feature freeze pretty soon, so I need to know if I need to workaround this or just wait for the fix.

Thanks.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jun 22, 2007 4:49 pm

Hi,

which TeeChart Pro version are you using ?
This problem was fixed in the latest TeeChart Pro v7.014 ( available on our web site at the private customers download page ).
Would you be so kind to download it and check if still happening with that version ?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jun 22, 2007 5:16 pm

Hi,

sorry, now I know what you mean, I can see the problem here. It's as designed, as this (bsCrossSmall) and brush styles different of (bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross) are not a standard brush styles they cannot change its pen color. These brush styles are loaded as images into the IBrush.

In case you want to have the same brush style but with different pen color, you will have to use a custom image and load it by using the following code :

tchart1.Canvas.Brush.LoadImage "customBrush.bmp"

thatnerdyguy
Newbie
Newbie
Posts: 14
Joined: Thu May 18, 2006 12:00 am

Post by thatnerdyguy » Fri Jun 22, 2007 5:26 pm

Ok, thanks!

Post Reply