[D3] Start Visualizing Data Driven Documents with D3 v4
with Data start v4 D3 driven
2023-09-14 09:00:51 时间
It’s time to live up to D3’s true name and potential by integrating some real data into your visualization. This lesson introduces the fundamental concepts of enter, update, and exit selections, topics essential for being successful with D3.
var scores = [ { name: 'Alice', score: 96 }, { name: 'Billy', score: 83 }, { name: 'Cindy', score: 91 }, { name: 'David', score: 96 }, { name: 'Emily', score: 88 } ]; // There are three selection: // enter: which in the data, but not yet on the page // upate: which in the data, and also in the page // exit: which not in the data, but exist on the page // update function handle those elements which already on the page var update = d3.select('.chart') .selectAll('div') .data(scores, function(d) { // A compare function which checks whether there are existing elements return d ? d.name : this.innerText; }) .style('color', 'blue'); var enter = update.enter() .append('div') .text(function(d) { return d.name; }) .style('color', 'green'); update.exit() .style('width', '1px') .style('height', '50px') .style('background', 'white') .style('border', '1px solid black'); // You can merge selection by using .merge() function update.merge(enter) .style('width', d => d.score + 'px') .style('height', '50px') .style('background', 'lightgreen') .style('border', '1px solid black');
相关文章
- Error:(1, 0) Plugin with id 'com.android.application' not found
- 关于git拉取项目时,报RPC failed; curl 18 transfer closed with outstanding read data remaining错的解决方案
- [RxJS] Share data among multiple subscribers with Subjects
- [DevOps] Environment Variables with Travis
- [React] Avoid Too Many Spinners with React SuspenseList’s tail Prop
- [Bash] Search for Text with `grep`
- [Javascript] Simplify Creating Immutable Data Trees With Immer
- [Nuxt] Navigate with nuxt-link and Customize isClient Behavior in Nuxt and Vue.js
- [Nuxt] Setup a "Hello World" Server-Rendered Vue.js Application with the Vue-CLI and Nuxt
- [SCSS] Loop Over Data with the SCSS @each Control Directive
- [Vue] Preload Data using Promises with Vue.js and Nuxt.js
- [Practical Git] Show who changed a line last with git blame
- [RxJS] Displaying Initial Data with StartWith
- [Unit Testing] Karma with Angular mocks
- [Postgres] Bulk Insert and Export Data with csv Files with Postgres copy Command
- [Angular 8] Keep original DOM structure with ng-container
- [Dart] Capture and Handle Data Sequences with Streams in Dart
- [Webpack] Externalize Dependencies to be Loaded via CDN with webpack
- [Vue @Component] Define Props on a Vue Class with vue-property-decorator
- [Angular] Make a chatbot with DialogFlow
- [Javascript] Writing conventional commits with commitizen
- 成功解决ImportError: Something is wrong with the numpy installation. While importing we detected an olde
- 【已解决】NotImplementedError: The pixel data with transfer syntax JPEG 2000 Image Compression
- 论文阅读《Named Entity Recognition with Small Strongly Labeled and Large Weakly Labeled Data》