import com.example.d3.D3; import com.example.d3.Selection; public class ChartDemo { public static void main(String[] args) { D3 d3 = new D3(); Selection svg = d3.select("svg") .attr("width", 400) .attr("height", 200); int[] data = {10, 20, 30, 40, 50}; Selection rects = svg.selectAll("rect") .data(data) .enter() .append("rect") .attr("x", (d, i) -> i * 50) .attr("y", (d) -> 200 - d * 2) .attr("width", 40) .attr("height", (d) -> d * 2) .style("fill", "blue"); rects.transition() .duration(1000) .attr("height", (d) -> d * 3) .style("fill", "green"); } } 1. D3.js - Data-Driven Documents. (n.d.). Retrieved from https://d3js.org/


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