web123456

Echarts custom tooltip levitation prompt box

// Initialize the chart var myChart = echarts.init(document.getElementById('main')) // Specify the chart options 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", // The color of the text }, borderColor: "rgba(0,0,0,0.3)", borderWidth: 1, formatter: function (params) { console.log('params', params) return ( params[0].marker + "Heart Rate: " + 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 // Disable x-axis tick lines }, axisLine: { show: true, // Enable x-axis line lineStyle: { color: '#CCCCCC', // Set y-axis line color }, }, axisLabel: { color: '#000000' // Set x-axis label color }, splitLine: { show: true, // Show x-axis grid lines lineStyle: { type: 'dashed' // Set grid lines to dashed } } }, yAxis: { type: 'value', axisTick: { show: false // Disable y-axis tick lines }, axisLabel: { color: '#000000' // Set x-axis label color }, axisLine: { show: true, // Enable y-axis line lineStyle: { color: '#CCCCCC', // Set y-axis line color }, }, splitLine: { show: true, // Show y-axis grid lines lineStyle: { type: 'dashed' // Set grid lines to dashed } } }, series: [ { name: 'Values', type: 'line', smooth: true, data: [12, 18, 23, 28, 34, 26, 19, 14, 22, 30, 32, 27], showSymbol: false // Disable the points at each data mark } ], visualMap: { show: false, dimension: 1, pieces: [ { gt: 10, lte: 20, color: 'red' }, { gt: 20, lte: 30, color: 'blue' }, { gt: 30, lte: 40, color: 'green' } ] } } // Set the chart options myChart.setOption(option)