Interested friends Welcome to http://www.ourd3js.com/Discussion
Now let's start with D3.js to deal with the first simple question, and look at the following code:
If you have studiedHTML, you should know that two lines of text will be printed on the screen, such as:
If you want to useJavaScriptTo change these two lines of text, what to do? We will add the code into:The result becomes:
As you can see, using JavaScript, we've added 4 lines of code, and if you useD3.jsit? Just add one line of code. Be careful not to forget to refer to the D3.js source file.
The results will change to:
similar to JavaScript like jquery, it simplifies the process of using JavaScript.
Next change the font color and size, as follows:
var p = d3.select ("Body"). SelectAll ("P"). Text ("www.ourd3js.com");p. Style ("Color", "red");p. Style ("Font-size", "72px ");
you can see that the above code assigns a value to the variable p before using P. This will make the code cleaner.