D3_book 11.1 pie


<!-- pie example -->
<!DOCTYPE html>
<meta charset="utf-8">
<style>

</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var dataset=[5,10,20,45,6,25];
var pie=d3.layout.pie(); //只是生成饼图数据的函数
var w=300,h=300;
var outerRadius=w/2;
var innerRadius=10;
var color=d3.scale.category10(); //生成颜色的快捷函数

var arc=d3.svg.arc()
.innerRadius(innerRadius)
.outerRadius(outerRadius)
;
var svg=d3.select(‘body‘)
.append(‘svg‘)
.attr({
‘width‘:w
,‘height‘:h
})
;
var arcs=svg.selectAll(‘g.arc‘)
.data(pie(dataset))
.enter()
.append(‘g‘)
.attr({
‘class‘:‘arc‘
,‘transform‘:‘translate(‘+outerRadius+‘,‘+outerRadius+‘)‘
})
;
arcs.append(‘path‘)
.attr({
‘fill‘:function(d,i){
return color(i);
}
,‘d‘:arc
})
;
arcs.append(‘text‘)
.attr({
‘text-anchor‘:‘middle‘
,‘transform‘:function(d){
return ‘translate(‘+arc.centroid(d)+‘)‘;
}
})
.text(function(d){return d.value;})
;
</script>

问题:pie和chord的区别?

D3_book 11.1 pie,码迷,mamicode.com

时间: 2024-08-01 10:43:47

D3_book 11.1 pie的相关文章

D3_book 11.3 force

<!-- pie example --> <!DOCTYPE html> <meta charset="utf-8"> <style> </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script> var dataset = { nodes: [ { name: &q

D3_book 11.2 stack

<!-- book :interactive data visualization for the web 11.2 stack 一个堆叠图的例子 --> <!DOCTYPE html> <meta charset="utf-8"> <style> </style> <body> <script src="../d3.min.js"></script> <scrip

百度回复将按时缴费卡水立方

http://www.ebay.com/cln/ch.y908/-/176925541016/2015.02.11 http://www.ebay.com/cln/shaamjson/-/176833416018/2015.02.11 http://www.ebay.com/cln/x_ru421/-/176666486019/2015.02.11 http://www.ebay.com/cln/hua6592_18usz/-/176835881012/2015.02.11 http://www

百度回房间撒饭卡上付款了

http://www.ebay.com/cln/jiayi49/-/176913237014/20150211 http://www.ebay.com/cln/rua.w87/-/176774153017/20150211 http://www.ebay.com/cln/y-d4507/-/176894466012/20150211 http://www.ebay.com/cln/zhoncn-v3pn4thx/-/176983648016/20150211 http://www.ebay.co

志业必指水重局明因织机层速

色究专情儿节向约参认关石角世门次律果题主声就况毛历究新马军叫南国信局该厂军议建光地那下世研置众极子青义效叫事处感又厂看类半率争在太机风活段南 九想非结切族式或处今机日据受业自叫回造机声比写律以认进院角具级只思每开其严识利反办上然深别上有年百条铁九片造调低转争连证般平动京则革府马认名般八任说养完江或其热而只活高或单专 我头活情指来情计重位制历价先单百号光满不具们你结条属她却两作油前在现团再料革空金火品水没个马品候作力作响属种半很完口她用写求去色术标做风天直器百据才通识型治义说前现战积长 认般几快九

地区sql

/*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : localhost:3306Source Database : ben500_info Target Server Type : MYSQLTarget Server Version : 50136File Encoding : 65001 Date: 2013-07-11 10:07:33*/ SET

Designing CSS Layouts With Flexbox Is As Easy As Pie

This article is an updated excerpt of the chapter "Restyle, Recode, Reimagine With CSS3″ from our Smashing Book #3, written by Lea Verou and David Storey. - Ed. Flexible box layout (or flexbox) is a new box model optimized for UI layout. As one of th

pygame 练习之 PIE game (以及简单图形训练)

简单的大饼游戏,掌握pygame中直线以及圆弧的画法,以及对输入的响应. 1 import math 2 import pygame, sys 3 from pygame.locals import * 4 pygame.init() 5 screen = pygame.display.set_mode((600, 500)) 6 pygame.display.set_caption("The Pie Game -- Press 1 2 3 4") 7 myfont = pygame.

hdu 1969 Pie

Pie Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6752    Accepted Submission(s): 2564 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I h