ECharts
Pie Chart
Donut-style pie with emphasis effect and percentage labels.
By EZ4Code Team
echartspie
Code
const chart = echarts.init(document.getElementById('chart'));
chart.setOption({
tooltip: { trigger: 'item', formatter: '{a} <br/>{b}: {c} ({d}%)' },
legend: { bottom: '5%', left: 'center' },
series: [{
name: 'Access Source',
type: 'pie',
radius: ['40%', '70%'],
avoidLabelOverlap: false,
label: { show: true, formatter: '{b}: {d}%' },
emphasis: {
label: { show: true, fontSize: 18, fontWeight: 'bold' },
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0,0,0,0.5)'
}
},
data: [
{ value: 1048, name: 'Direct' },
{ value: 735, name: 'Search' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union' },
{ value: 300, name: 'Video' }
]
}]
});Explanation
A two-element radius array (['40%','70%']) turns the pie into a donut. The formatter tokens {b} (name), {c} (value), and {d} (percentage) make labels and tooltips easy to customize. The emphasis block scales label size and adds a shadow on hover; avoidLabelOverlap:false keeps labels positioned naturally.
More ECharts Snippets
Bar Chart
Category bar chart with axis tooltip and styled bars.
Line Chart
Smooth multi-series line chart with area fill.
Scatter Plot
Scatter plot with point size encoded by a third dimension.
Radar Chart
Radar with multiple indicators and overlaid value series.
Options & Series
Dataset-driven multi-series chart with grid and legend config.
Tooltip
Custom HTML tooltip with crosshair axis pointer.