Upping logarithmic graduation limit to 309 (maximum before Infinity, probably some dragons to be had there)

This commit is contained in:
Ad5001 2024-09-17 01:35:47 +02:00
parent d7fe760900
commit 91e4220397
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
2 changed files with 10 additions and 8 deletions

View file

@ -120,12 +120,6 @@ Canvas {
*/
property bool showygrad: false
/*!
\qmlproperty int LogGraphCanvas::maxgradx
Max power of the logarithmic scaled on the x axis in logarithmic mode.
*/
property int maxgradx: 20
/*!
\qmlproperty var LogGraphCanvas::imageLoaders
Dictionary of format {image: [callback.image data]} containing data for defered image loading.

View file

@ -17,7 +17,7 @@
*/
import { Module } from "./modules.mjs"
import { textsup } from "./utils.mjs"
import { textsup, roundAwayFromZero } from "./utils.mjs"
import { Expression } from "./mathlib.mjs"
import Latex from "./math/latex.mjs"
@ -139,7 +139,15 @@ class CanvasAPI extends Module {
* Max power of the logarithmic scaled on the x axis in logarithmic mode.
* @returns {number}
*/
get maxgradx() { return this._canvas.maxgradx }
get maxgradx() {
return Math.min(
309, // 10e309 = Infinity (beyond this land be dragons)
Math.max(
Math.ceil(Math.abs(Math.log10(this.xmin))),
Math.ceil(Math.abs(Math.log10(this.px2x(this.width))))
)
)
}
//
// Methods to draw the canvas