Doughnut Chart with Rounded Corners (Original)

Add-ons
2026-07-26 03:59 5 次浏览 • 0 次下载 5.7KB
Doughnut Chart with Rounded Corners (Original)

This plugin uses canvas to help you quickly create a doughnut chart with rounded segment boundaries.

Compatibility

Compatible with all mainstream desktop and mobile browsers. Not supported in IE8 and earlier versions.

Installation

1
npm install donut-chart

Usage

First, you need a canvas element as the rendering container.

1
<canvas id="myCanvas" width="750" height="600"></canvas>

Then create a doughnut chart object.

1
var cir = new DonutChart('myCanvas', option)

Finally, initialize it and optionally specify a callback function.

1
2
3
cir.init(function (result) {
// result: Information about the selected range
})

Parameters

Option Example (Default Values)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
var option = {
type: 'pie', // pie: Doughnut chart || gauge: Gauge chart
title: {
show: true,
text: 'Total Assets (CNY)',
textStyle: {
fontSize: "20px",
lineHeight: "30px",
color: '#9f9f9f'
},
subtext: '360',
subtextStyle: {
fontSize: "30px",
lineHeight: "35px",
color: '#e53344'
},
x: '50%', // Title position
y: "50%",
},
tooltip: {
show: true,
fontStyle: "normal", // Specifies the font style: normal || italic || oblique
fontVariant: "normal", // Specifies the font variant: normal || small-caps
fontWeight: 'normal', // Specifies the font weight: normal || bold || bolder || lighter || 100 || 200 || 300 || 400 || 500 || 600 || 700 || 800 || 900
fontSize: "20px", // Specifies the font size in pixels
lineHeight: "30px", // Specifies the line height in pixels
fontFamily: 'Arial',// Specifies the font family
color: 'white', // Font color
backgroundColor: '#00000099', // Tooltip background
formatter: function (param) { // Similar to ECharts rich text editing
var str = "{a|" + param.name + "}" + "{c|" + param.percent + "}" + '\n' + "{b|" + param.value +
"CNY}"
return str
},
rich: {
a: {
fontStyle: "normal",
fontVariant: "normal",
fontWeight: 'bold',
fontSize: "20px",
lineHeight: "30px",
fontFamily: 'Arial',
color: 'white',
},
c: {
fontStyle: "normal",
fontVariant: "normal",
fontWeight: 'normal',
fontSize: "20px",
lineHeight: "30px",
fontFamily: 'Arial',
color: 'white',
},
b: {
fontStyle: "normal",
fontVariant: "normal",
fontWeight: 'bold',
fontSize: "30px",
lineHeight: "35px",
fontFamily: 'Arial',
color: '#e53344',
}
}
},
x: "50%", // Icon position
y: "50%",
radius: "30%", // Radius
lineWidth: "5%", // Ring width
// {{if type === gauge: Gauge chart}}
// max: 120, // Total mapped value
// data: [{
// name: "Used Duration (minutes)",
// value: 85, // Mapped measurement value
// }],
// {{else if type === pie: Doughnut chart}}
// data: [{
// name: "Account Balance (CNY)",
// value: 110,
// }, {
// name: "Pending Fixed-Income Returns (CNY)",
// value: 120,
// }, {
// name: "Funds in Transit (CNY)",
// value: 130,
// }],
// {{/if}}
label: {
show: true,
fontStyle: "normal",
fontVariant: "normal",
fontWeight: 'bold',
fontSize: "20px",
lineHeight: "30px",
fontFamily: 'Arial',
color: '#9f9f9f',
formatter: function (param) {
var str = "{a|" + param.name + "}" + "{c|" + param.percent + "}" + '\n' + "{b|" + param.value +
"CNY}"
return str
},
rich: {
a: {
fontStyle: "normal",
fontVariant: "normal",
fontWeight: 'bold',
fontSize: "20px",
lineHeight: "30px",
fontFamily: 'Arial',
},
b: {
fontStyle: "normal",
fontVariant: "normal",
fontWeight: 'bold',
fontSize: "30px",
lineHeight: "35px",
fontFamily: 'Arial',
color: '#e53344',
},
c: {
fontStyle: "normal",
fontVariant: "normal",
fontWeight: 'bold',
fontSize: "20px",
lineHeight: "30px",
fontFamily: 'Arial',
}
}
},
capType: "round", // Rounded corners || butt: Square corners
selectedStyle: { // Style when selected
color: "white", // Border color
borderWidth: 10 // Border width
},
color: ["#fe7c00", "#e83227", "#32a676"],
labelCoverTitle: true, // label: Whether to overlap the title
backgroundArc: '#999' // Empty ring color
}
星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare