<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.3.0/echarts.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<title>Gauge Chart</title>
</head>
<body>
<div id="gaugeChartIncDropdown1" style="width: 250px; height: 250px; margin: 0 auto; margin-top: 10%"></div>
<input type="range" id="sizecluslider" min="0" max="100" step="1" value="50" style='position:absolute; top: 60%; left: 41.5%; cursor: pointer; width: 100px; accent-color: #008cba;'>
<div id="valor1" style="display: none;">123</div>
<script>
const gaugeChartIncDrop1 = echarts.init(document.getElementById('gaugeChartIncDropdown1'));
function updateGaugeDropIncFinal1(value, value2, maxValueInputSize1, customValue) {
option = {
tooltip: {
show: true,
trigger: 'item',
formatter: function(params) {
return params.name + ': ' + params.value + '%' + '<br>' + 'Custom Value: ' + customValue;
}
},
series: [
{
type: 'gauge',
min: 0,
max: 100,
splitNumber: 10,
radius: '80%',
axisLine: {
lineStyle: {
color: [[1, '#008cba']],
width: 3
}
},
splitLine: {
distance: -10,
length: 10,
lineStyle: {
color: '#008cba'
}
},
axisTick: {
distance: -10,
length: 10,
lineStyle: {
color: '#008cba'
}
},
axisLabel: {
distance: -25,
formatter: function (value) {
return value.toFixed(0) + '%';
},
color: '#008cba',
fontSize: 11,
fontFamily: 'Lato'
},
anchor: {
show: true,
size: 20,
itemStyle: {
borderColor: '#020202',
borderWidth: 2
}
},
pointer: {
offsetCenter: [0, '10%'],
icon: 'path://M2090.36389,615.30999 L2090.36389,615.30999 C2091.48372,615.30999 2092.40383,616.194028 2092.44859,617.312956 L2096.90698,728.755929 C2097.05155,732.369577 2094.2393,735.416212 2090.62566,735.56078 C2090.53845,735.564269 2090.45117,735.566014 2090.36389,735.566014 L2090.36389,735.566014 C2086.74736,735.566014 2083.81557,732.63423 2083.81557,729.017692 C2083.81557,728.930412 2083.81732,728.84314 2083.82081,728.755929 L2088.2792,617.312956 C2088.32396,616.194028 2089.24407,615.30999 2090.36389,615.30999 Z',
length: '125%'
},
title: {
fontSize: 11,
fontWeight: 'bold',
fontFamily: 'Lato'
},
detail: {
valueAnimation: true,
width: 50,
height: 20,
fontSize: 14,
precision: 1,
formatter: '{value}%',
fontFamily: 'Lato',
borderWidth: 2,
padding: [0, 0, 0, 0],
backgroundColor: '#92a192',
borderRadius: 8,
color: '#020202'
},
data: [
{
value: value,
name: 'Segm. 1',
title: {
color: '#008cba',
offsetCenter: ['0', '20%']
},
detail: {
offsetCenter: ['0', '40%'],
borderColor: '#008cba'
},
itemStyle: {
color: '#f00',
borderWidth: 1,
borderColor: '#020202'
}
},
{
value: value2,
itemStyle: {
color: 'cyan',
borderWidth: 1,
borderColor: '#020202'
},
pointer: {
offsetCenter: [0, '0%'], // Ajuste conforme necessário
icon: 'path://M-20,0 L0,-20 L20,0 L0,20 Z' // Ajuste o caminho do ícone conforme necessário
}
}
]
},
{
type: 'gauge',
min: 0,
max: 100,
splitNumber: 6,
axisLine: {
lineStyle: {
color: [[1, '#858383']],
width: 3
}
},
splitLine: {
distance: -2,
length: 10,
lineStyle: {
color: '#858383'
}
},
axisTick: {
distance: -2,
length: 10,
lineStyle: {
color: '#858383'
}
},
axisLabel: {
distance: 5,
fontSize: 11,
color: '#858383',
formatter: function (value) {
return value.toFixed(0) + '%';
}
},
pointer: {
show: false
},
title: {
show: false
},
anchor: {
show: true,
size: 14,
itemStyle: {
color: '#f00'
}
}
}
]
};
gaugeChartIncDrop1.setOption(option);
}
function updateIncDropFunc1() {
let value = Number($('#sizecluslider').val());
let maxValueInputSize1 = Number($('#maxValueInputSample1').val());
let customValue = Number($('#valor1').text())
updateGaugeDropIncFinal1(value, maxValueInputSize1, customValue);
}
updateIncDropFunc1();
$('#sizecluslider, #maxValueInputSample1').on('input', function() {
updateIncDropFunc1();
});
gaugeChartIncDrop1.on('mouseenter', { dataIndex: 0 }, function(params) {
$(this).css('pointer-events','none');
});
</script>
</body>
</html>