TAChart: Margins.Bottom=0 hides first axis label lazarus / 55-TAChart ---------------------------------------------------------------------- wp · 2012-06-05 19:07 The attached screen shot shows a simple bar chart. The upper image was created with the default settings of TChart. It shows a little gap between the bottom of the bars and the x axis. This is due to the default value of TChart.Margins.Bottom = 4. I think the diagrams looks better when the bars start directly at the axis. Therefore, I set TChart.Margins.Bottom = 0 (center image). Now, as intended, the bars do begin at the x axis, but the first mark label of the vertical axis ("0") has disappeared. Even when forcing the vertical axis to start at 0 (Chart.Extent.UseYMin = true) the "0" label does not show up. The minimum setting of Margins.Bottom to show the "0" is 1, but now there's a tiny gap again (bottom image). Is there a way to get the first mark label back and keep Margins.Bottom at 0? ---------------------------------------------------------------------- Ask · 2012-06-07 13:42 Try r37565. Note that the problem was caused by the code which tried to make sure that minor axis marks do not overlap major ones. So if you have a code using minor marks, please test that it still works correctly. ---------------------------------------------------------------------- wp · 2012-06-07 15:03 There's one little issue: the minor grid is drawn over the axis - see attached screenshot. Can't you reverse the order of drawing? Grid first, then axes? ---------------------------------------------------------------------- Ask · 2012-06-07 22:42 This is major grid. You can add minor grid by using "Minors" property of an axis. Axis drawing order is determined by ZPosition and a position in the axis collection, so you can change it by rearranging axises. At least in my tests, turning bottom axis line overrides left axis grid, so the effect you see is only achieved by hiding the axis line. Edit: See "Bar" page of labels demo since r37575 ---------------------------------------------------------------------- wp · 2012-06-08 14:43 QuoteThis is major grid Of course - sorry for the confusion. QuoteAt least in my tests, turning bottom axis line overrides left axis grid, so the effect you see is only achieved by hiding the axis line. See "Bar" page of labels demo since r37575 No, this demo shows the effect as well. You don't see it because you paint the black grid onto the black grid line. Just set the color of the LeftAxis.Grid to clWhite or some other bright color, and you will get a dotted axis line. ---------------------------------------------------------------------- Ask · 2012-06-08 20:56 Ah, of course, I mixed it up -- it is the other way around. So you can get the bottom axis to override left one by rearranging them in the object inspector. As for your request about additionally prioritizing axis lines over grid lines -- this should be thought about carefully. What priority should axis marks have in relation to both of the above? See recently implemented "Position" page in the axis demo for an especially relevant example. ---------------------------------------------------------------------- wp · 2012-06-08 21:23 I understand now. But this trick does not help when both left and bottom margins are zero... I think, however, that this is a rare case, so far I have only seen a need for a zero margin in case of the bar charts. Therefore, no reason to change anything from my point of view. ---------------------------------------------------------------------- wp · 2012-06-09 12:26 Sorry - this is not working any more. I have two Lazarus versions on my Win7 system, the first one is installed from a snapshot, maybe one or two weeks old, the other one is compiled from current trunk. The snapshot version shows the correct behavior, the trunk does not. Today I updated the snapshot version with the recent one, same behavior as yesterday's trunk (of course...). Steps to reproduce: - Create a new project - Add a TChart - Set Chart1.Marging.Bottom to 0 - Set Chart1.LeftAxis.Grid.Color to clWhite (or some other bright color) - The object tree of the object inspector shows "0 - Left" and "1 - Bottom" axis, i.e. TChart should draw the left axis and its grid first, then the bottom axis on top of the lowest grid line. But you will see a dotted x axis. - Just to make sure: In the object tree, drag the bottom axis above the left axis - no change - Or change the ZPosition values of the left or bottom axes: no change also ---------------------------------------------------------------------- Ask · 2012-06-09 14:13 QuoteTChart should draw the left axis and its grid firstAs I said in the previous message, the drawing order is actually reverse. This may or may not be a bug -- I need to investigate and document why I did it this way. Quote- Just to make sure: In the object tree, drag the bottom axis above the left axis - no change - Or change the ZPosition values of the left or bottom axes: no change also Set AxisPen.Visible = true. ---------------------------------------------------------------------- wp · 2012-06-09 17:08 QuoteSet AxisPen.Visible = true. Ah, that's it. Thank you.