How to access the displayed value of JSXgraph integral?

156 Views Asked by At

I can see on https://jsxgraph.uni-bayreuth.de/docs/symbols/Integral.html that the value of the integral is displayed as part of the integral object created.

Can someone please tell me how to access this value (or the text object which is displayed as the label)? I did not find this information in the documentation.

I am aware of the similar question: How to access value of integral with JSXGraph?. Please do not mark my question as a duplicate unless you answer that other question. The answer there is not really an answer. It tells how to use numerical integration to find this value (so practically tells to calculate the integral again). It does not tell how to access the value without this redundant calculation. The integral is already calculated and displayed, I would like to know how to access this information without calculating it again.

1

There are 1 best solutions below

0
On BEST ANSWER

There are two ways to access the value of the integral. One is to call the method Value() of the integral element. The other method is to read from the integral element's label element:

const board = JXG.JSXGraph.initBoard('jxgbox', { 
    boundingbox: [-5, 5, 5, -5], axis:true
});

var plot = board.create('functiongraph', ['x^2 * sin(x)']);
var integral = board.create('integral', [[-1, 2], plot]);
document.getElementById('output').value = integral.Value() + ' ' + integral.label.plaintext;

See it live at https://jsfiddle.net/ve0d3mr6/1/.