import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; public class D3Example { public static void main(String[] args) { try (Context context = Context.create()) { Value d3 = context.eval("js", "require('d3')"); int[] data = {10, 20, 30, 40, 50}; Value selector = d3.getMember("select"); Value svg = selector.execute("#chart"); svg.call("selectAll", "rect") .data(data) .enter() .append("rect") .attr("height", d -> d) .attr("width", "50") .attr("x", (d, i) -> i * 60) .attr("y", d -> 100 - d); } } }


上一篇:
下一篇:
切换中文