zoukankan      html  css  js  c++  java
  • [D3] Margin Convention with D3 v4

    You can’t add axes to a chart if you don’t make room for them. To that end, the D3 community has adopted a simple convention for defining margin sizes that shields most of your code from having to know or care about them. This lesson demonstrates the margin convention and the simple flexibility it adds to your D3 projects.

    var margin = { top: 10, right: 20, bottom: 25, left: 25 };
    var width = 425 - margin.left - margin.right;
    var height = 625 - margin.top - margin.bottom;
    
    var svg = d3.select('.chart')
      .append('svg')
        .attr('width', width + margin.left + margin.right)
        .attr('height', height + margin.top + margin.bottom)
      .append('g')
        .attr('transform', `translate(${margin.left}, ${margin.top})`);
    
    svg.append('rect')
      .attr('width', width / 2)
      .attr('height', height)
      .style('fill', 'lightblue')
      .style('stroke', 'green');
    
    svg.append('rect')
      .attr('x', width / 2)
      .attr('width', width / 2)
      .attr('height', height)
      .style('fill', 'lightblue')
      .style('stroke', 'green');

  • 相关阅读:
    ubuntu安装-Docker(zz)
    vpp编译
    dpdk编译
    通过P4runtime进行解耦
    run p4 in mininet
    搭建基于Open vSwitch的VxLAN隧道实zz
    路由协议
    dNOS from AT&T
    《Java程序设计》实验一 Java开发环境的熟悉
    《Java程序设计》第五周学习总结
  • 原文地址:https://www.cnblogs.com/Answer1215/p/7300617.html
Copyright © 2011-2022 走看看