[D3.js advanced series-6.2] drag and drop a pie chart, d3.js6.2
This article describes a more complex drag-and-drop application, that is, the drag-and-drop Pie Chart Section.
In Chapter 9.1, I will explain how to create a pie chart
Objective
Small make up has already shared with everybody before "D3.js realizes the method of the histogram to explain" and "D3.js realizes the method of line chart to explain" these two articles, have already introduced the columnar c
Objective
D3.js is a JavaScript class library that helps developers manipulate data-based documents, in the "D3.js method of implementing a histogram." has been introduced to you how to use d3.js to achieve a simple histogram, to
Date: 2012-6-30 Source: gbin1.com
Online Demo
There are many powerful chart class libraries. Today we will introduce nvd3.js, which is based on the well-known d3.js class library. It is designed to help you create reusable d3.js
"). Text (function (d) {return d.name;});As shown in result 5. Thanks to the most high-speed rail lines in Beijing, the most densely connected circle in Beijing is like tying a lot of ropes here.Figure 5When nodes and wires become much more complex, it becomes an example at the beginning of this article. As I said at the beginning of this article, the completion of that example is too high to provide a reference at all. I hope the example of this article can give you a reference example of bundl
for each region: DX and dy. Used to save offsets.2. Definition of the Drag eventEach time the drag event is triggered, we just need to get the mouse offset and add it to the original offset dx and dy.Then use D3.select (this) to select the current element and apply the transform to it to complete the panning operation.var drag = D3.behavior.drag (). Origin (function (d) {return D;}). On ("Drag", DragMove),
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
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
First make a dynamic column chart (the version of D3.js used here is V3, some functions will change with V4):Code:Now add the mouseover and mouseout events like this dynamic column chart.Practice:1. Remove the style from the style. MyText class that adds a color attribute directly when adding a rectangle2. Add an event when adding a rectangle...//adding rectangle
, 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
(DataSet)). Enter () . Append ("G") . attr ("Transform", " Translate ("+outerradius+", "+outerradius+") ");In the above code, we bind the converted data pie (dataset). There are 5 of data. So 5 g elements are added. The last line of code is the position of the moving element, and the default starting position is the (0,0) coordinates of the SVG draw box, which is the upper-left corner. Note that this time the above code returns theSelect 5 g elements at the same time. Next, for each G elemen
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
rectheight =; // the pixel height of each rectangle (including white space) Svg.selectall ("rect"). data (DataSet). Enter () . Append ("rect"). attr ( "x") . attr ("y",function(d,i) { return i * rectheight; }) . attr ("width",function(d) { return D; }) . attr ("height", rectHeight-2) . attr ("Fill", "steelblue");This code adds the same number of rectangles as the length of the dataset array, using the following statement:Svg.selectall ("rect")
slowly reaches the last state of the transformation
Elastic with bouncing reach finally state
Bounce bouncing a few times at the last state.
Called when the shape is:. Ease ("bounce")4.delay ()Specifies the time of the delay, which indicates a certain amount of time before the transition is initiated and the unit is the same in milliseconds. This function can specify a delay for the population. You can also specify a delay for an individual.For general designations, such as:. Trans
part of the outer chord, in fact, and draw a pie chart is the same, you can refer to section 9.1, then the above code is not difficult to understand. There is the text outside the string (that is, the city name), see the last piece of code:After binding the data, there is a each (), which represents the code for any one of the binding elements that executes the following nameless function functions, where the code is: calculate an angle, assign a val
Use D3.js Library to implement Focus+context line chart, read DATA.TSV file dataIndex.htmlAs follows: Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. "D3.js" Focus + Context Line
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.