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 life into your data using HTML, SVG, and CSS, w
D3 is widely used and is now one of the mainstream data visualization tools. Everyone in the first contact with the use of d3.js, the most difficult place is data (), enter (), exit () these several operations.
After I have been in touch for some time and have some understanding, simply say what I understand.
Data ()
Let's look at one example:
Execute code:
This article brings you the content is about how to use CSS and D3 to achieve small fish swimming interactive animation (with code), there is a certain reference value, the need for a friend can refer to, I hope you have some help.
Effect Preview
Source code Download
Https://github.com/comehope/front-end-daily-challenges
Code interpretation
Defines the DOM, which contains child elements that represent the body, eyes, dorsal fin, and tail of the fish
D3 is a visual library of JavaScript, you can make a very beautiful table, which has a very interesting mechanics diagram, can be easily dragged, etc., but on the update of the operation of the online introduction of the few, the following describes the mechanics of the update, first look at an example (http:// example.codeboy.me/d3/force-layout.html, click the following image once to add directly to the EN
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),
Most of the data bound in D3 is done by the function, how does it work, and how does it differ from datum ()?The data () function can bind array items to each element individually, and can set rules for binding. Data () can also handle cases where the length of the array is inconsistent with the number of elements. When the array length is greater than the number of elements, the element position can be reserved for extra data so that new elements can
In the previous chapter, we used a very important concept-scale, which explains how to use this section.1. Maximum value and minimum valueBefore introducing the scale, we introduce two functions that appear together with the scale bar, and also appear in the "3rd chapter".
D3.max ()
D3.min ()
These two functions are used to find the maximum and minimum values in an array, and if it is a on
In general, there is not much text in the chart. However, sometimes you need some text to describe some graphical elements. Then, you can implement an interaction: when the user mouse slides to a graphic element, a prompt box appears with descriptive text. This is a simple, universal interaction that works on almost all charts. By customizing the appearance to the cue box, you can give the user a good experience.1. How to make a prompt boxThe Prompt box is "text" Plus "border". display text, gen
and introduced in the tag:
To realize data visualization with D3, you first need to define the data. We will use JSON-formatted data. Of course, you can use other types of data.
var data = {"East": [{"Ordernum": 12}
, {"Ordernum": 20}
, {"Ordernum": 30}
, {"Ordernum": 40}
, {"Ordernum": 40}
]};
The Select command in D3, the primary feature is the selection of elements to be manipulated by the data.
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 HTML file to write,
p.data (persons, function (d) {return d.id;}). Text (function (d) {return d.id + ":" + D.name;});There is only one statement return d.id in the key function. Represents a key using the ID property of an array item. After modifying the contents of the P element with the data of this binding, the result is as follows:As you can see, the results are not arranged in the order of the New Persons Array (6: Zhang San, 9: John Doe, 3: Harry). As shown in binding procedure 1, the order of the bindings d
Website:
http://d3js.org/Example:
Https://github.com/mbostock/d3/wiki/GalleryReference:
Online reference //or download to local Begin:
D3.select implementing a single element selectionSelect.attr, reading/Setting element properties
select.classed, adding/removing element classes
Remove the P1 class for P tags D3.js Study 1
D3.js Data Visualization Practical Manual study notesThe interpolator interpolation a given range of values and prints it in the middle.Character interpolation
var data=[];var sizescale=d3.scale.linear (). Domain ([0,9]). Range (["Italic bold 12px/30px Georgia, serif", "Italic bold 120px/180px Georgia, serif "]); for (Var i=0;iColor interpolation
var data=[];var colorscale=
My personal blog is: www.ourd3js.comCSDN Blog for: blog.csdn.net/lzhlzzReprint please indicate the source, thank you.[5.1] A better chart is produced in the section. But it is static. Want to make a dynamic effect on it? In D3, just a few lines of code are needed.This section will cover the use of 4 functions.1.transition ()The effect of starting the transition is just to add it.Add it between the two states. Like what:. attr ("Fill", "red"). Transiti
simplified version of GeoJSON, which can be said to be a GeoJSON child. The author of D3.js thinks GeoJSON is not very good, and it is more admired Topojson format.Topojson compared to GeoJSON, the file size is reduced by 80% because:
The boundary line is recorded only once (for example, the junction lines in Guangxi and Guangdong province are recorded only once)
Do not use floating-point numbers, use integers only
But Topojson seem
How about the Shenzhou Tang one machine? We can learn from the following to understand the Shenzhou Tang M35 d3 Integrated machine configuration content, Shenzhou released the Tang Dynasty in one model for the M35 D3, its configuration performance? Let's get to know each other.
Tang-m35 D3 equipped with Intel dual-core processor, the main frequency of 2.1
Online DemoIf you want to create a nice text cloud or tag cloud effect, you can consider using D3-cloud, which is an awesome open source font cloud effect JavaScript class library, based on the well-known d3.js, can help you generate similar wordle.com style fonts or tag cloud effects.
This class library uses the HTML5 canvas to generate the font effect, and the entire layout algorithm can be implemented a
The zoning diagram (Partition) is also a layout of the D3. This layout is very interesting, can be made into a square is also possible to make a circle, this article first introduce the method of making square partition diagram, which is the most basic form of the partition diagram.A partition diagram is also used to represent the containing relationship.1. DataThis article uses the "Getting Started-chapter 9.4" Data, which is the affiliation of sever
Advanced series of articles from last October began to write, dazzling is 4 months, want to summarize a year ago.First of all, Happy New Year. It's the year of the goat. Some time ago and friends chat, chat to 12 zodiac Why no cat, I mouth dear: not because of the 12 zodiac when the cat was late for the meeting?Oh, I do not know who this is to instill in my view. O (>﹏The advanced series of articles is divided into two parts, the article is written in parentheses:
"
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.