【发布时间】:2021-05-09 11:50:19
【问题描述】:
我正在尝试将经典动画添加到伪 3D 条形图。用 rect 来做这件事很简单。但是路径呢?
我有 3d 效果的三个基本路径: 如何制作和谐的成长动画?
createColumns(bars, data) {
//...skip code
bars
.data(data)
.append('path')
.attr(
'd',
(d) => `M 0,0 V ${rectHeight(d.value)} H ${rectWidth()} V 0 H 0 Z`,
)
.attr('class', 'forward-bar')
.classed('bar', true);
bars
.data(data)
.append('path')
.attr(
'd',
() =>
`M 0,0 L ${rectWidth()},0 L ${
rectWidth() + depth
}, ${-depth} H ${depth} Z`,
)
.attr('class', 'top-bar')
.classed('bar', true);
bars
.data(data)
.append('path')
.attr(
'd',
(d) =>
`M ${rectWidth()},0 L ${rectWidth() + depth},${-depth}, V ${
rectHeight(d.value) - depth
} L ${rectWidth()} ${rectHeight(d.value)} Z`,
)
.attr('class', 'side-bar')
.classed('bar', true);
}
【问题讨论】:
标签: javascript d3.js 3d