Scale: Missing Min and Max indication when Chart.Margins.Left/Right=0 lazarus / 55-TAChart ---------------------------------------------------------------------- CM630 · 2021-01-12 16:53 When I place a TAchart on a form and execute the code below the minimum and maximum values of the X scale (0 and 0,4) are not displayed. It occurs that this is caused by Chart.Margins.Left:=0; and Chart.Margins.Right:=0;. If I set Chart.Margins.Left:=1; and Chart.Margins.Right:=1; the problem is gone. Is there a way to have a normal scale with Chart.Margins.Left/Right=0; ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);begin  Chart.Extent.UseXMax:=True;  Chart.Extent.UseXMin:=True;  Chart.Extent.UseYMax:=True;  Chart.Extent.UseYMin:=True;  Chart.Extent.XMin:=0;  Chart.Extent.XMax:=0.4;  Chart.Extent.YMin:=0;  Chart.Extent.YMax:=0.4;  Chart.Margins.Top:=0;  Chart.Margins.Bottom:=0;  Chart.MarginsExternal.Left:=20;  chart.LeftAxis.Margin:=0;  Chart.LeftAxis.Title.Margins.Left:=0;  Chart.LeftAxis.Title.Distance:=0;    //Next two problem remove the Mn and Max values of the X scale.  Chart.Margins.Left:=0;  Chart.Margins.Right:=0;end; ---------------------------------------------------------------------- wp · 2021-01-12 17:36 Maybe there is some round-off error when the label positions are calculated. You know: in floating point calculations 0 is not necessarily equal to 0. It works for me when I set Chart.Extent.XMin = -1E-12. I cannot comment on Xmax which is working for me out of the box, but maybe you must apply a tiny offset there too (add it in this case) ---------------------------------------------------------------------- CM630 · 2021-01-12 20:44 I am aware that float integers are never integers, though I am not sure if 0 and 2 are the only exceptions. But for some reason when Chart.Margins.Right/Left are changed zero<-> nonzero the scale is recalculated, and when Chart.Margins.Top/Bottom are changed the scale is not recalculated, as it can be seen from the attached snippet. ---------------------------------------------------------------------- wp · 2021-01-12 22:20 Calculation of the scaling factors is a quite complex iterative process, because when the available chart size changes (for example by changing Margins), the labels may change and thus change the available chart size in turn and so on. Trying to fix this labeling issue is an operation in the heart of TAChart, and the chance to break something is very high. The last time I worked in this context I was busy for weeks. So please, either accept the situation or work around it by expanding the labeled axis range by a tiny epsilon as explained above. ---------------------------------------------------------------------- CM630 · 2021-01-13 07:55 Thank you for the assistance.Quote from: wp on January 12, 2021, 11:20:28 pm...work around it by expanding the labeled axis range by a tiny epsilon as explained above... If I get you right, the tiny epsilon has to be applied for each value manually, until a result is achieved, so it is not applicable for dynamically changing scales. So I will stick to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Chart.Margins.Left:=1;  Chart.Margins.Right:=1; ---------------------------------------------------------------------- wp · 2021-01-13 08:47 Sorry, I don't understand what you want to achieve. Force the axis to begin and end at a given value and to place the first/last labels immediately at the begin/end of the axis? In this case the axis limits must be input by the user, and I don't see a problem to subtract/add an epsilon. Here is an example in which the user can enter the axis limit in edit controls: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  TAChartUtils; procedure TForm1.Button1Click(Sender: TObject);const  EPS = 1E-9;var  ext: TDoubleRect;begin  ext.a.x := StrToFloat(EditXMin.Text) - EPS;  ext.b.x := StrToFloat(EditXMax.Text) + EPS;  ext.a.y := StrToFloat(EditYMin.Text) - EPS;  ext.b.y := StrToFloat(EditYMax.Text) + EPS;  Chart1.Extent.FixTo(ext);end;But this works only when the first and/or last labels are integer multiples of the interval length that the chart determines. Suppose the user wants the axis to begin at 0 and to end at 0.39. Then the final label will not be drawn when the interval length is determined to be 0.02, 0.05, 0.1, for example. Automatic labeling is very complex, and will probably fail if you have certain restrictions in mind. In this case, calculate the labels yourself and store them in a ChartListSource which you attach to the Marks.Source of the axis. ---------------------------------------------------------------------- CM630 · 2021-01-14 07:05 I think I've got it now: When Chart.Margins.Left:=1; TaChart considers Chart.Extent.XMin:=0 for 0 - ε, and when Chart.Margins.Left:=0; it considers it for 0 + ε. And because Chart.Extent.XMin:=0+ε > 0, the 0 is not shown on the scale, because it is out of it. I have tried to apply Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ext.a.x := StrToFloat(EditXMin.Text) - EPS;  ext.b.x := StrToFloat(EditXMax.Text) + EPS;  ext.a.y := StrToFloat(EditYMin.Text) - EPS;  ext.b.y := StrToFloat(EditYMax.Text) + EPS; It works for the 0 but not for the 0,4. I suppose that it can be handled with Chart.BottomAxis.Marks.Source := TListChartSource; but there is another complication- I have to buffer the desired values of the extents, because I cannot read them back from the chart. So,it seems there is a solution, but for now, I will stick to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Chart.Margins.Left:=0;  Chart.Margins.Right:=0; Thanks once again!