Gauge with Custom Label in JavaScript
Using ApexCharts with JavaScript
This Gauge with Custom Label example uses ApexCharts.js directly in JavaScript, with no wrapper component.
Install it with npm install apexcharts, then mount the chart with new ApexCharts(element, options).render().
var options = {
series: [58],
chart: {
height: 350,
type: 'gauge',
},
plotOptions: {
radialBar: {
hollow: {
margin: 15,
size: '70%',
},
dataLabels: {
name: {
show: true,
offsetY: -20,
fontSize: '16px',
color: '#999',
},
value: {
show: true,
fontSize: '40px',
fontWeight: 700,
offsetY: 6,
formatter: function (val) {
return val + '%'
},
},
},
},
},
fill: {
type: 'gradient',
gradient: {
shade: 'dark',
type: 'horizontal',
shadeIntensity: 0.5,
gradientToColors: ['#ABE5A1'],
inverseColors: true,
opacityFrom: 1,
opacityTo: 1,
stops: [0, 100],
},
},
stroke: {
lineCap: 'round',
},
labels: ['CPU Usage'],
}
var chart = new ApexCharts(document.querySelector('#chart'), options)
chart.render()