Display label in front of bar graph
I have a prob where my "mark" that comes with TChart hide behind the bar...I added the marks and it draws itself behind the bars. Any way to bring it in front? i hope anyone can help me.开发者_开发知识库.thanks
I don't know what class is your graph bar instantiated of, but I know TLabel is a TGraphicControl descendant. Controls descending from TGraphicControl do not have any window handle; therefore, their parent is responsible for draw them on its own canvas.
When you drop a label on your form, the form is the parent of your label, and will draw the label on its own canvas. If you drop a windowed control (Controls derived from TWinControl class, e.g. TButton or TProgressBar), they handle their own drawing on top of the parent canvas. That means, descendants of TGraphicControl will be always drawn behind descendants of TWinControl class with the same parent window.
The simplest solution for you is to use TStaticText which provides the same functionality as TLabel, but is a TWinControl descendant.
There might be other solutions for you too, for example: you can drop a panel on your form, and add the label to the panel, then bring the panel to front, to show it above the graph bar. When you add the label to the panel, its parent would be set to that panel control, and the panel will be responsible for drawing the label; or you set the graph bar as the parent of your label; or deriving a new graph bar class, and handling its Paint method to draw the text directly on its canvas.
Ok, now I see what's wrong. You have three bar series, but the third is drawing over the marks from the second. After filling your 3 bar series try :
barseries2.marks.visible:=False;
barseries2.marks.visible:=True;
This should repaint the marks (not tested though).
精彩评论