Home is my personal blog: http://www.ourd3js.com/, csdn Blog home for: http://blog.csdn.net/lzhlzz/. Reprint please indicate the source, thank you.D3 's full name is (Data-driven Documents), as the name implies to know is a data-driven documentation JavaScript class Library. Suppose you don't know what JavaScript is.Learn about JavaScript first. To put it simply, d3.js is primarily used to manipulate data
":", "Value": 3}, {"Source":, "target": 17 , "Value": 3}, {"source": "Target": 3}, {"source": "Target":, "Value": 3}, {"source": "Target": 2 0, "Value": 5}]}
The data consists of two parts, dots (nodes) and edges (links), and the values of source and target represent the elements corresponding to the numeric subscript of the nodes array.
Note that, regardless of the number of attributes of the nodes element, source and target temporarily point to a person's name, such as Source 1 target0 repr
, show, how to do? Insert the following code:var wx = d3.scale.linear () . Domain ([0, D3.max (DataSet)]) . Range ([0,500]);D3.scale.linear () is used to generate a scale bar of a linear function whose initial definition domain is [0, 1], the initial range range is [0, 1], where [] represents the scope. Now we set domain to [0,
My personal blog is: www.ourd3js.com
The csdn blog is blog.csdn.net/lzhlzz.
Please indicate the source for reprinting. Thank you.
As mentioned above, the text is processed. In this section, D3.js is used as a simple column chart.
There are many ways to create a column chart, such as using HTML div labels or svg.
SVG is recommended for various graphics. SVG indicates Scalable Vector Graphics. SVG defines ima
My personal blog is: www.ourd3js.comCSDN Blog for: blog.csdn.net/lzhlzzReprint please indicate the source, thank you.In the previous sections, all the text is processed, and this section will use D3.js to make a simple column chart.There are many ways to do a column chart, such as using an HTML div tag, or using SVG.It is recommended to use SVG to do all kinds of graphics. SVG means scalable vector graphics
above code, we bound the converted data pie (dataset), there are 5 data, so we will add 5 g elements, the last line of code is the position of moving elements, the default starting position is the SVG draw box (0,0) coordinates, that is, the upper left corner. Note that this time the above code returns theChoose between 5 g elements at the same time. Next, for each G element, add path.Arcs.append ("path"). attr ("Fill", function (d,i) {return color (i);}). attr ("D", function (d) {return arc (d
want to learn more about D3.js's friends, welcome to http://www.ourd3js.com/discussionD3 's full name is (Data-driven Documents), as the name implies can be known as a data-driven documentation JavaScript class Library.If you don't know what JavaScript is, learn about JavaScript first. to put it simply, d3.js is primarily used to manipulate data by injecting li
piedata = pie (DataSet);
Layout is called a layout, and in D3.js it provides a number of functions that are converted to specific chart data, including pie charts. It provides a basic transformation function, on the basis of which we further set the function according to our own needs, and we get the same transformation tool as the function saved by the pie variable in the above code, and the drawing
D3.js A simple primerD3 is a JavaScript framework: The main purpose is to visualize data,So he developed it under JavaScript, and currently has the D3.js 3.0 and D3.js 4.0 versions.The use of the method is very simple, 1. Download
The first test of the successful D3.js code needs to be opened in the IE9 and above browsers. Firefox and Google can also try. Delete "20"rows="8"id="con">"运行代码"type="button"id="btn"/>Test the successful D3.js code
) {return d.x;}). attr ("Cy", function (d) {return d.y;}). attr ("R", function (d) {return D.R;}). On ("MouseOver", function (d,i) {d3.select (this). attr ("Fill", "Yellow");}). On ("Mouseout", function (d,i) {d3.select (this). attr ("Fill", "RGB (31, 119, 180)");});This is the code to draw the circle, see the previous sections of the friends must have been very familiar with it.The resulting diagram is as
D3 is a visual JS library based on data manipulation, and the understanding of D3 can be discussed from the most basic display of loadable data.
The basic framework of HTML is not much said, the first code to explain:
Create a new test directory under which the demo and D3 two folders are created. Demo to store the H
the axes
Orient () This function is used to specify the dividing point of the axis and the direction of the number in which to display. Bottom is displayed below the axis.
The code for the axis is drawn as follows:[JavaScript]View PlainCopy
Svg.append ("G")
. Call (axis);
Adding a g,g in SVG is an attribute in SVG, which is the group meaning, which represents a set of things, such as a group lines, rects, circles actually the axis is composed of these things. It also
If you want to know more about D3.js, welcome to http://www.ourd3js.com/discussion
D3 is a javascript class library for Data-Driven Documents. If you do not know what javascript is, learn about javascript first.
To put it simply, D3.js is mainly used to operate data. It
When I first approached the use of D3.js, one of the most confusing places was data (), enter (), and exit () . After I have been in touch for a while and have some understanding, simply say what I understand.data ()Let's look at an example: Body > P > P > P > P > P > P > Body >Execute code:D3.select ("Body"). SelectAll ("P"). data ([1, 2, 3])Here, Data() is used to bind to the selected DOM ele
In D3.js, there are two functions for selecting an element: Select and SelectAll. Let's start by explaining their differences:
Select is the first selection of all specified elements
SelectAll is the selection of all of the specified elements (for later simultaneous operation)
To see a specific example, the following code is available:[HTML]View PlainCopy
html>
head>
meta charse
China), just:[HTML]View PlainCopy
Sp.text ("China");
Can. If you want to use the set to assign a value, to use function functions (d,i), the function of the first parameter means datum (data), the second argument is index (index), it is important to note that when data function data is specified The set of data set and the P set you selected are one by one corresponding (if the number of sets and p is exactly the same, the case will be discussed later). The function has only one
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.