问题描述
我无法从该库制作动态图 http://jsxgraph.uni-bayreuth.de/docs/symbols/Integral. html
I have a problem to make a dynamic graph from this libraryhttp://jsxgraph.uni-bayreuth.de/docs/symbols/Integral.html
==这将使f(x)= x ^ 3
== this will make f(x) = x^3
var c1 = board.create('functiongraph', [function (t) { return t*t*t; }]);
var i1 = board.create('integral', [[-1.0, 4.0], c1]);
但是,我如何使function(t)取决于用户输入?例如,用户从texboxt输入x ^ 2 + 4x,代码将生成以下内容:var fx = $(#fx").val();//fx = x ^ 2 + 4xvar c1 = board.create('functiongraph',[function(x){return fx;}]);
but, how can i make function(t) depends from user input ? for example user input x^2+4x from texboxt and the code will generate this:var fx = $("#fx").val(); // fx = x^2 + 4xvar c1 = board.create('functiongraph', [function (x) { return fx; }]);
推荐答案
JSXGraph带有自己的解析器JessieCode(请参见 https ://github.com/jsxgraph/JessieCode )来做到这一点. JessieCode读取Math语法,即x ^ 2转换为x * x,并移交可以由JSXGraph绘制的对象.
JSXGraph comes with its own parser JessieCode (see https://github.com/jsxgraph/JessieCode) which does exactly this. JessieCode reads Math syntax, i.e. x^2 is converted to x*x, and hands over an object which can be plotted by JSXGraph.
这是您通过JessieCode实现的示例:
Here is your example realized with JessieCode:
var fx = $("#fx").val();
var f = board.jc.snippet(fx, true, 'x', true);
var c1 = board.create('functiongraph', [f]);
这篇关于如何使用JSXGraph从用户输入绘制动态图形来绘制积分图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!