option = {
xAxis: {
type: 'category',
data: ['Category A', 'Category B', 'Category C', 'Category D']
},
yAxis: {
type: 'value'
},
tooltip: {
show: true,
formatter: function (params) {
// 自定义提示框内容
return 'Value: ' + params.value;
}
},
series: [{
type: 'pictorialBar',
symbol: 'rect',
itemStyle: {
color: 'skyblue'
},
symbolSize: 40,
data: [100, 80, 120, 150],
symbolRepeat: 'fixed',
symbolMargin: '50%',
z: 3,
label: {
show: true,
position: 'top',
formatter: '{c}%',
fontSize: 12,
color: 'black'
},
emphasis: {
itemStyle: {
color: 'orange'
},
label: {
show: true,
position: 'inside',
fontSize: 14,
color: 'white'
}
},
animationDuration: 1000,
animationEasing: 'cubicOut'
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
在上述代码中,tooltip 部分包含了自定义提示框的内容,可以通过 formatter 函数来定义。在这个例子中,显示的内容是象形柱图对应的数值。
你可以根据实际需求定制提示框的内容,以使其符合你的信息展示需求。
转载请注明出处:http://www.zyzy.cn/article/detail/5448/ECharts