<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ECharts Line Chart Demo</title>
<script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
<style>
#main {
width: 600px;
height: 400px;
}
</style>
</head>
<body>
<div id="main"></div>
<script>
var myChart = echarts.init(document.getElementById('main'))
var option = {
title: {
text: 'Smooth Line Chart with Colored Segments'
},
tooltip: {
trigger: 'axis',
backgroundColor: "rgba(0,0,0,0.3)",
textStyle: {
show: false,
color: "#FFFFFF",
},
borderColor: "rgba(0,0,0,0.3)",
borderWidth: 1,
formatter: function (params) {
console.log('params', params)
return (
params[0].marker +
"心率: " + params[0].data +
"<br/><span style='margin-left:0.25rem'></span>" +
params[0].axisValue
)
},
},
xAxis: {
type: 'category',
data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
axisTick: {
show: false
},
axisLine: {
show: true,
lineStyle: {
color: '#CCCCCC',
},
},
axisLabel: {
color: '#000000'
},
splitLine: {
show: true,
lineStyle: {
type: 'dashed'
}
}
},
yAxis: {
type: 'value',
axisTick: {
show: false
},
axisLabel: {
color: '#000000'
},
axisLine: {
show: true,
lineStyle: {
color: '#CCCCCC',
},
},
splitLine: {
show: true,
lineStyle: {
type: 'dashed'
}
}
},
series: [
{
name: 'Values',
type: 'line',
smooth: true,
data: [12, 18, 23, 28, 34, 26, 19, 14, 22, 30, 32, 27],
showSymbol: false
}
],
visualMap: {
show: false,
dimension: 1,
pieces: [
{
gt: 10,
lte: 20,
color: 'red'
},
{
gt: 20,
lte: 30,
color: 'blue'
},
{
gt: 30,
lte: 40,
color: 'green'
}
]
}
}
myChart.setOption(option)
</script>
</body>
</html>