[英]JsxGraph from Dart using Dart JS interop
I am trying to use the plotting library JSXGraph from Dart using dart js but I have problems. 我试图使用dart js的绘图库JSXGraph ,但我有问题。
This is working javascript code 这是工作的JavaScript代码
var board = JXG.JSXGraph.initBoard(
'box',
{
boundingbox: [-10, 10, 2, -1],
axis: true,
keepaspectratio: false,
showNavigation: false
}
);
var graph = board.create(
'functiongraph',
[function(x){ return 3*x*x + 5*x + 1;}, -10, 10],
{strokeColor: '#ffff00'}
);
You can try it here on jsFiddle. 你可以在这里尝试jsFiddle。
I want to do basically the identicall thing but from dart. 我想基本上做同样的事情,但是从飞镖。 This is what I have come up with so far:
这是我到目前为止所提出的:
JsObject jsxGraph = context['JXG']['JSXGraph'];
var board = jsxGraph.callMethod('initBoard', [
'box',
new JsObject.jsify({
'boundingbox': [-10, 10, 2, -1],
'axis': true,
'keepaspectratio': false,
'showNavigation': false
})
]);
var graph = board.callMethod('create', [
'functiongraph',
[(x){return 3*x*x + 5*x + 1;}, -10, 10],
new JsObject.jsify({'strokeColor': '#ffff00'})
]);
I get the plot area and axes but I can't get the actual plot line. 我得到了绘图区域和轴,但我无法获得实际的绘图线。 Instead, there is an error on the console:
Uncaught TypeError: this.Y is not a function
. 相反,控制台上有一个错误:
Uncaught TypeError: this.Y is not a function
。
Could someone, please, point me to what I could be doing wrong? 有人可以指出我可能做错了吗? I suspect it is something about the callback function but I really don't know what.
我怀疑它是关于回调函数的东西,但我真的不知道是什么。
There's a jsify
missing in your code: 您的代码中缺少
jsify
:
JsObject jsxGraph = context['JXG']['JSXGraph'];
var board = jsxGraph.callMethod('initBoard', [
'box',
new JsObject.jsify({
'boundingbox': [-10, 10, 2, -1],
'axis': true,
'keepaspectratio': false,
'showNavigation': false
})
]);
var graph = board.callMethod('create', [
'functiongraph',
new JsObject.jsify([(x){return 3*x*x + 5*x + 1;}, -10, 10]},
new JsObject.jsify({'strokeColor': '#ffff00'})
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.