Page 1 of 1

Canvas.Brush.Color in OnLegendDrawSymbol

Posted: Wed Jun 06, 2007 7:47 pm
by 9531332
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.

Posted: Thu Jun 07, 2007 2:28 pm
by narcis
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.

Posted: Thu Jun 07, 2007 2:40 pm
by 9531332
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.

Posted: Thu Jun 21, 2007 7:19 pm
by 9531332
*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.

Posted: Fri Jun 22, 2007 4:49 pm
by Pep
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 ?

Posted: Fri Jun 22, 2007 5:16 pm
by Pep
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"

Posted: Fri Jun 22, 2007 5:26 pm
by 9531332
Ok, thanks!