diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml index bd10c29..55ef234 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml @@ -301,7 +301,7 @@ Canvas { } else { for(var x = 1; x < drawMaxX; x += 1) { var drawX = x*xaxisstep1 - var txtX = xaxisstepExpr.simplify(x) + var txtX = xaxisstepExpr.simplify(x).replace(/^\((.+)\)$/, '$1') var textSize = measureText(ctx, txtX, 6).height drawVisibleText(ctx, txtX, x2px(drawX)-4, axisxpx+textsize/2+textSize) drawVisibleText(ctx, '-'+txtX, x2px(-drawX)-4, axisxpx+textsize/2+textSize) @@ -311,7 +311,7 @@ Canvas { if(showygrad) { for(var y = 0; y < drawMaxY; y += 1) { var drawY = y*yaxisstep1 - var txtY = yaxisstepExpr.simplify(y) + var txtY = yaxisstepExpr.simplify(y).replace(/^\((.+)\)$/, '$1') var textSize = ctx.measureText(txtY).width drawVisibleText(ctx, txtY, axisypx-6-textSize, y2px(drawY)+4+(10*(y==0))) if(y != 0) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js index 01b25b9..f4deb0d 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js @@ -68,6 +68,7 @@ class Expression { simplify(x) { var expr = this.calc.substitute('x', x).simplify() + print(this.expr, this.calc.substitute('x', x), expr) if(expr.evaluate() == 0) return '0' var str = Utils.makeExpressionReadable(expr.toString()); if(str != undefined && str.match(/^\d*\.\d+$/)) { diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js index 8ca3a69..624b3a5 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/utils.js @@ -256,14 +256,14 @@ function makeExpressionReadable(str) { // Other [/ \* /g, '×'], [/ \^ /g, '^'], - [/\^\(([^\^]+)\)/g, function(match, p1) { return textsup(p1) }], - [/\^([^ "]+)/g, function(match, p1) { return textsup(p1) }], - [/_\(([^_]+)\)/g, function(match, p1) { return textsub(p1) }], - [/_([^ "]+)/g, function(match, p1) { return textsub(p1) }], + [/\^\(([\d\w+-]+)\)/g, function(match, p1) { return textsup(p1) }], + [/\^([\d\w+-]+)/g, function(match, p1) { return textsup(p1) }], + [/_\(([\d\w+-]+)\)/g, function(match, p1) { return textsub(p1) }], + [/_([\d\w+-]+)/g, function(match, p1) { return textsub(p1) }], [/\[([^\[\]]+)\]/g, function(match, p1) { return textsub(p1) }], [/(\d|\))×/g, '$1'], //[/×(\d|\()/g, '$1'], - [/[^a-z]\(([^)(+.\/-]+)\)/g, "$1"], + [/([^a-z])\(([^)(+.\/-]+)\)/g, "$1×$2"], [/integral\((.+),\s?(.+),\s?("|')(.+)("|'),\s?("|')(.+)("|')\)/g, function(match, a, b, p1, body, p2, p3, by, p4) { if(a.length < b.length) { return `∫${textsub(a)}${textsup(b)} ${body} d${by}`