D3.js Study 3

Source: Internet
Author: User

Enter-update-exit mode

Select.data (data), which represents the intersection of the selection graph with the data->update Mode

Select.data (data). Enter () to exclude the intersection of selection graphics with data data on behalf of data->enter Mode

Select.exit, removes all data, representing parts of the selection graph->exit Mode

E-U-E is the foundation of D3.js

Array Data binding

var data=[10,15,24,46,13,6,96,12,44,61,17];function render (data) {    //Enter    d3.select ("Body"). SelectAll (" Div.h-bar ")//Select all the H-bar elements on the page that are about to be generated    . Data    . Enter ()    . Append (" div ")    . attr (" Class "," H-bar ")    . Append (" span ");//used to display the current value D    //update    D3.select (" Body "). SelectAll (" Div.h-bar ")    . Data (data)    . Style ("width", function (d) {//Set the histogram length to 3 times times    return (d*3) + "px";  }) of D.    Select ("span")//outputs the D value within span    . Text (function (d) {    return D;    });    Exit    D3.select ("Body"). SelectAll ("Div.h-bar")    . Data (data).    exit ()    . Remove (); SetInterval (function () {    data.shift ();//Remove the first element for Dynamic loop presentation of data    Data.push (Math.Round (Math.random () *100)); /Add a random data at the end, also used for Dynamic loop presentation of render (data),    },15000),//1.5 seconds per cycle to update data render (data);//Initial presentation

Css:

<style type= "Text/css" >.h-bar {    min-height:15px;    min-width:10px;    Background-color:steelblue;    margin-bottom:2px;    font-size:11px;    Color: #f0f8ff;    Text-align:right;    padding-right:2px;} </style>

D3.js Study 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.