TFunctionSeries not updating y extent lazarus / 55-TAChart ---------------------------------------------------------------------- wp · 2012-09-06 08:21 I am experimenting with a math function plotter based upon TExpressionParser and TFuncSeries. Works fine, but what I found out is that the TFuncSeries does not update the vertical extent of the y axis. Am I missing something? ---------------------------------------------------------------------- Ask · 2012-09-06 12:17 Use FuncSeries.Extent and DomainExclusions properties. Automatic determination of function extent is quite hard. Consider f(x)=1/x. If I understand correctly, mathematical software uses symbolic calculation for that, which is obviously out of scope for TAChart. I guess I can add some heuristics (for example, setting "outer bounds" extent and automatically shrinking it if all calculated values fit inside). Similarly, user must currently set DomainExclusions by hand, although it can be, to some extent, determined heuristically (which would also fix your old issue about fit series incorrectly working with NaNs). ---------------------------------------------------------------------- wp · 2012-09-06 17:25 Quotesetting "outer bounds" extent and automatically shrinking it if all calculated values fit inside Something like this would be fine. Quoteuser must currently set DomainExclusions by hand To be honest I still have to dig into the details of DomainExclusions. If I understand correctly, this is a mechanism which prevents drawing of undefined function values, like the 1/x at x=0 that you mention, or log(x) for x <=0? ---------------------------------------------------------------------- Ask · 2012-09-18 09:47 Added TFuncSeries.ExtentAutoY property in r38730, see "Auto Y extent" page in "func" demo since r38731. Note that the property applies only if both Extent.UseXMin and Extent.UseXMax are true. Additionally, if the function is not smooth, it is recommended to set UseYMin and UseXMax anyway. You can try to set Chart1.Extent.UseYMax = false and Chart1FuncSeries1.ExtentAutoY = true on the "Domain" page of the "func" demo to see what happens otherwise. Quotedetails of DomainExclusions. If I understand correctly, this is a mechanism which prevents drawing of undefined function valuesYes, exactly. You can also use it to arbitrarily split function domain into several disconnected parts. What I talked about is that DomainExclusions might be automatically added for points where function returns NaN (or even raises an exception). ---------------------------------------------------------------------- wp · 2012-09-18 10:54 QuoteAdded TFuncSeries.ExtentAutoY property in r38730Thank you - I'll test it as soon as I can. QuoteWhat I talked about is that DomainExclusions might be automatically added for points where function returns NaN That's what I do not understand with DomainExclusions: when the function returns NaN then the line segment should not be drawn (as it is the case with TLineSeries), and that's the same effect as the DomainExclusion. I have to admit, though, that the exception handling of Lazarus seems to be a bit rough - I am getting nonrecoverable math exceptions (like divide by zero, or log of negative numbers) when the debugger is running; but when the application runs on its own the exceptions are nicely trapped. I'll try to find some systematics and post this issue separately. ---------------------------------------------------------------------- Ask · 2012-09-18 16:38 There are several differences between NaNs and DomainExclusions in functional series: 1) Currently DomainExclusions work, while NaNs do not 2) Automatically extracting domain from arbitrary function is unreliable -- this is quite similar to the reason I did not want to implement automatic extent. Finding discontinuity will be predicated on trying to calculate value inside of it, which may be unlikely, especially for single-point exclusions. 3) Once found, it is not entirely obvious what to do -- actual point of discontinuity is somewhere between current point and previously drawn one. Ideally, chart should use binary search to find it. 4) Raising exceptions is slow. So finding domain based on exceptions may be inefficient for functions like Log and Sqrt. Nevertheless, all of the above is "just a matter of programming", so if it is required, I'll consider implementing it. Additionally, I have thought about adding discontinuity marks, but postponed it until somebody needs them. ---------------------------------------------------------------------- wp · 2012-09-18 20:29 QuoteQuoteAdded TFuncSeries.ExtentAutoY property in r38730Thank you - I'll test it as soon as I can. Working perfectly - thanks again. QuoteThere are several differences between NaNs and DomainExclusions in functional series Thanks for the explanation. Quoteso if it is required, I'll consider implementing it I'm not sure if I need it... My primary intention was to use this project in a tutorial on TFuncSeries, but it is getting quite complicated anyway (NaNs not working ideally, DomainExclusions difficult to handle with parsed functions), so maybe I'll look for another example.