1

I'm trying to create bar chart with stacked series. Every bar consists form two parts. Main part has normal color and black border, "over limit" part has brighter color and red border. There is no problem to configure this behavior in IDE (Delphi XE3). Configured behavior starts to be bad when I have too small "over limit" bars. If this bar is 1px high, red border disappears and only 1px brush color line renders. I need to render border color line. So I'm trying to change color of this bar.

Here is part of my code:

Series1.AddY((RamTotal-RamAvailable-memover) / mb, titlemem);
if memover > 0 then
  Series2.AddY(memover / mb, titlememover);
if (memover > 0) and (Series2.CalcBarBounds(0).Height <= 2) then
  Series2.ValueColor[0] := FSmallOverColor;

Problem is with CalcBarBounds function. It returns correct value only after chart was already shown. For the first time it returns 0. This results to apply border color to every "over limit" bar regardless it's height when showing for the first time. When I press reload button which clears all series and calls the same code as before, everything looks fine. It doesn't work if I call reload from code. Calling refresh, repaint or whatever doesn't help. Trying to change color on AfterDraw event doesn't work either.

There is only one value for every series. I have TeeChart Standard v2012.06.120613 32bit.

1 Answers1

1

Problem is with CalcBarBounds function. It returns correct value only after chart was already shown. For the first time it returns 0. This results to apply border color to every "over limit" bar regardless it's height when showing for the first time. When I press reload button which clears all series and calls the same code as before, everything looks fine. It doesn't work if I call reload from code.

You probably have to force a chart repaint before calling CalcBarBounds. Some internal values aren't initialized or don't have valid values until the chart completes the first paint.

Calling refresh, repaint or whatever doesn't help

Have you tried calling Draw function?

Yeray
  • 5,009
  • 1
  • 13
  • 25
  • This isn't an answer. It's a request for information, and should be posted as a comment instead. Anything posted in the "Your Answer" text area should do just that - provide an answer to the question. You should either expand on this to explain and make it a statement so that it reads like an answer, or move it to a comment on the original question instead. The [faq] has information on the difference between the two. :-) – Ken White Apr 05 '13 at 20:53
  • I wrote it as an answer because it could be the key to resolve the main problem. I agree it could be better argued but I prioritized the time over the quality. I guess it will be the creator who should say if it was enough to solve the problem or not. Anyway, I'll try to improve it. – Yeray Apr 08 '13 at 08:19