echarts 实现3d饼图
时间: 2023-11-27 07:46:36 浏览: 117
以下是使用Apache ECharts实现3D饼图的示例代码:
```javascript
option = {
series: [{
type: 'pie',
radius: [50, 150],
center: ['50%', '50%'],
roseType: 'area',
itemStyle: {
borderRadius: 8,
borderColor: '#fff',
borderWidth: 1
},
label: {
show: false
},
emphasis: {
label: {
show: true
}
},
data: [
{value: 40, name: 'rose 1'},
{value: 33, name: 'rose 2'},
{value: 28, name: 'rose 3'},
{value: 22, name: 'rose 4'},
{value: 20, name: 'rose 5'},
{value: 15, name: 'rose 6'},
{value: 12, name: 'rose 7'},
{value: 10, name: 'rose 8'}
]
}]
};
// 构建饼图函数,绘制3d图
function buildPieChart() {
// 设置透明的空心占比
var internalDiameterRatio = 0;
// 设置饼图的3D效果
option.series[0].type = 'pie3D';
option.series[0].radius = [50, 150];
option.series[0].itemStyle = {
borderRadius: 8,
borderColor: '#fff',
borderWidth: 1,
opacity: 1 - internalDiameterRatio,
shadowBlur: 20,
shadowOffsetX: 0,
shadowOffsetY: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
};
option.series[0].label = {
show: true,
formatter: '{b}: {c} ({d}%)'
};
option.series[0].emphasis = {
label: {
show: true,
fontSize: '30',
fontWeight: 'bold'
}
};
// 绘制饼图
var myChart = echarts.init(document.getElementById('main'));
myChart.setOption(option);
}
buildPieChart();
```
阅读全文