zoukankan      html  css  js  c++  java
  • D3.js学习

    // 1.选择
    d3.select('p')
    d3.selectAll('p')
    d3.select('.txt').style('color', '#fff')
    // 2.支持动态设置属性
    // a:随机属性
    d3.selectAll('p').style('color', function (d, i) {
    return 1 % 2 ? '#fff' : '#eee'
    })
    // b.将数组中的属性设置给元素
    d3.selectAll('p')
    .data([4, 8, 15, 16, 23, 42])
    .style('font-size', function (d) {
    return d + 'px'
    });
    // enter操作:添加DOM
    d3.select('body')
    .selectAll('p')
    .data([4, 8, 15, 16, 23, 42])
    .enter()
    .append('p')
    .text(function (d) {
    return 'i am number' + d + '!'
    })
    // 数据和元素一样
    var p = d3.select('body')
    .selectAll('p')
    .data([4, 8, 15, 16, 23, 42])
    .text(function (d) {
    return d
    })
    // exit操作:删除DOM
    var p = d3.select('body')
    .selectAll('p')
    .data([4, 8, 15, 16, 23, 42])
    .text(function (d) {
    return d;
    })
    p.exit().remove()
    // 不确定数据多少的情况下,可以三种方法一起使用;
    var p=select('body')
    .selectAll('p')
    .data([4, 8, 15, 16, 23, 42])
    .text(function(d){return d;})
    p.enter().append('p').text(function(d){return d;})
    p.exit().remove()
    // classed:设置元素的类class一个或者多个
    // var p = d3.select('body').select('p').classed('test foo', true)
    // attr:设置元素的属性,selection.attr(name[,value]),如果value是一个函数,参数为d和i
    // var p = d3.select('body').selectAll('p').data('2').attr('title',function(d){return d;})
    // selection.style(name,[,value[,priority]])设置元素的样式;
    // selection.style({'stroke': 'black', 'stroke-width': 2})
    // selection.property:可设置元素的属性,如checkbox的选中等;
    // d3.select('.check').property('checked',true)
    D3的布局:
      一共有12种,这些布局的作用都是将某种数据转换成另一种数据,而转换后的数据是利于可视化的;

  • 相关阅读:
    Potato工作流管理系统 组织模型用例描述
    6/27 项目编码开始:一个简单的员工管理程序
    6/16 6/17加班2天
    重新过一遍ASP.NET 2.0(C#)(8) DataSourceControl(数据源控件)
    可行性分析报告结构
    6/27 一个简单的员工管理程序:添加微软成员资格数据表
    在asp.net 2.0中使用母版页和工厂方法模式
    工作流功能特性
    6/21 系统分析阶段汇报
    什么是工作流
  • 原文地址:https://www.cnblogs.com/yangguoe/p/10309147.html
Copyright © 2011-2022 走看看