使用js来动态绘制svg图片,首先就是要创建svg 节点。

使用createElementNS(),语法:

document.createElementNS(namespaceURI, qualifiedName[, options]);

参数:

SVG的学习(34—36)

有效的命名空间URL有:

SVG的学习(34—36)

代码举例:

var nameSpace = 'http://www.w3.org/2000/svg';  //命名空间url
    var max = Math.max.apply(null, data);
    var proportion = max/350;
    var interval = 40;
    var columnStyle = 'stroke: blue; fill: blue';
    for (var singleColumn of data) {
        document.createElementNS(nameSpace,'rect') //创建矩形
    }

 

相关文章:

  • 2022-12-23
  • 2021-11-07
  • 2021-09-08
  • 2022-12-23
  • 2021-11-21
  • 2021-09-18
  • 2021-07-26
  • 2021-06-21
猜你喜欢
  • 2021-09-18
  • 2021-08-28
  • 2022-02-13
  • 2021-08-21
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案