本文引用 极客学院的d3基础教程 stroke 描边引用 csdn博客 d3 排行案例
1. 颜色
var c
= d3
.color('red')
var c
= d3
.hsl('red') {h
, s
, l
, opacity
}
c
= c
.brighter(1.5)
c
= c
.darker(3)
var disable
= c
.displayable()
var str
= c
+ ''
var i
= d3
.interpolate('red', 'green')
2. 动画
var t
= d3
.transition()
.duration(4000)
.delay(200)
d3
.select('svg')
.transition(t
)
.attrTween
[:styleTween
]("fill", function() {
return d3
.interpolate("red", "blue");
})
svg
.append('rect')
.attr({
height
: 200,width
:400,
fill
: i(0)
})
.transition(t
)
.attr('fill', i(1))
.on('start', function repeat() {
d3
.active(this)
.attr('ry',0)
.transition()
.attr('ry',100)
.transition()
.on('start', repeat
)
})
3. d3添加文字
d3
.select('svg').append('text')
.text('测试api')
.attr({
x
: 300,y
:300,fill
:'red',
dx
: 20,
})
https://github.com/jackfrued/Python-100-Days