Dart js interop with D3 [英] Dart js interop with D3
本文介绍了Dart js interop with D3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图整合D3和dart:我的代码到这一点如下:
I am trying to integrate D3 with dart: My code to this point is as follows:
import 'dart:html';
import 'package:js/js.dart' as js;
void main() {
js.scoped(() {
var dee3 = js.context.d3;
var dataset = js.array([ 5, 10, 15, 20, 25 ]);
dee3.select("body").selectAll("p")
.data(dataset)
.enter()
.append("p")
.text(function(d) { return d; });
});
每当我在dartium中运行时,我得到以下异常:
异常:在被序列化之前被转换为回调。
如何将匿名函数(d)转换为回调?
Whenever I run this in dartium I get the following exception: Exception: A function must be converted to a Callback before it can be serialized. How can I convert the anonymous function(d) to a callback?
推荐答案
作为包:js> 0.2.0 回调$
As package:js > 0.2.0 Callback
and js.scoped
are no longer needed.
import 'dart:html';
import 'package:js/js.dart' as js;
void main() {
var dee3 = js.context.d3;
var dataset = js.array([ 5, 10, 15, 20, 25 ]);
dee3.select("body").selectAll("p")
.data(dataset)
.enter()
.append("p")
.text((d, i, context) => d);
}
这篇关于Dart js interop with D3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文