Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Bug in Box.Highlight
posted

I've run into what appears to be a bug in the Box.Highlight() method. I'm trying to draw a chart that shows the change in a value (either positive or negative) between two time periods. The chart is a horizontal BarChart. If the value of the change is positive, the bar should be to the right of a central point and be colored green. If the value of the change is negative, the bar should be to the left of a central point and be colored red.

What appears to be happening is if the value being charted is very close to zero (either negative or positive) the Rectangle being drawn by Box.Highlight() is created with a negative width (because Box.Highlight tries to 'deflate' the rectangle by two pixels.) GDI+ seems unable to draw a rectangle with a negative width (and frankly, how could it?) Because nothing gets drawn, the wrong color shows through on the bars.

If you increase the size of the Form at runtime you will eventually increase the size of the chart so that the rectangle's width is no longer negative. At that point the highlight rectangle is drawn with the correct colors.

I've worked around it by implement my own simple version of Box.Highlight() that eliminates the two pixel 'deflation.'

WinChartBugDemo.zip
Parents
No Data
Reply Children
No Data