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