Compare commits

...

2 commits

3 changed files with 24 additions and 9 deletions

View file

@ -124,7 +124,7 @@ Canvas {
\qmlproperty int LogGraphCanvas::maxgradx
Max power of the logarithmic scaled on the x axis in logarithmic mode.
*/
property int maxgradx: 20
property int maxgradx: 90
/*!
\qmlproperty var LogGraphCanvas::imageLoaders

View file

@ -94,9 +94,13 @@ Item {
property int positionChangeTimer: 0
function updatePosition(deltaX, deltaY) {
settingsInstance.xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX))
settingsInstance.ymax += deltaY/canvas.yzoom
settingsInstance.ymax = settingsInstance.ymax.toFixed(4)
const unauthorized = [NaN, Infinity, -Infinity]
const xmin = (Modules.Canvas.px2x(Modules.Canvas.x2px(settingsInstance.xmin)-deltaX))
const ymax = settingsInstance.ymax + deltaY/canvas.yzoom
if(!unauthorized.includes(xmin))
settingsInstance.xmin = xmin
if(!unauthorized.includes(ymax))
settingsInstance.ymax = ymax.toFixed(4)
settingsInstance.changed()
parent.positionChanged(deltaX, deltaY)
@ -140,11 +144,14 @@ Item {
}
let newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(0)
let newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(0)
if(newXZoom == settingsInstance.xzoom) // No change, allow more precision.
// Check if we need to have more precision
if(newXZoom < 10)
newXZoom = (settingsInstance.xzoom+xZoomDelta).toFixed(4)
if(newYZoom == settingsInstance.yzoom) // No change, allow more precision.
if(newYZoom < 10)
newYZoom = (settingsInstance.yzoom+yZoomDelta).toFixed(4)
if(newXZoom > 0.5)
settingsInstance.xzoom = newXZoom
if(newYZoom > 0.5)
settingsInstance.yzoom = newYZoom
settingsInstance.changed()
}

View file

@ -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