This commit is contained in:
‘937886381’
2026-01-07 16:47:49 +08:00
parent 51e66cf6e1
commit b76f3bfd37
164 changed files with 4179 additions and 2297 deletions

View File

@@ -67,15 +67,28 @@ export default {
this.myChart = echarts.init(chartDom);
// 绑定点击事件(只绑定一次,永久生效)
this.myChart.on('click', (params) => {
// 提取点击的基地名称
const itemName = params.name;
// 根据映射表获取对应的序号未匹配到则返回0或其他默认值
const baseIndex = this.baseNameToIndexMap[itemName] || 0;
this.myChart.getZr().on('click', (params) => {
console.log('params', params);
// 兼容不同图表类型的value柱状图value是数值折线图是[横坐标, 纵坐标]
// const itemValue = Array.isArray(params.value) ? params.value[1] : params.value;
// const seriesName = params.seriesName;
// 提取点击的基地名称
// const itemName = params.name;
let itemName = undefined
// 根据映射表获取对应的序号未匹配到则返回0或其他默认值
let pointInPixel = [params.offsetX, params.offsetY];
if (this.myChart.containPixel('grid', pointInPixel)) {
let pointInGrid = this.myChart.convertFromPixel({
seriesIndex: 0
}, pointInPixel);
let xIndex = pointInGrid[0]; //索引
let handleIndex = Number(xIndex);
let seriesObj = this.myChart.getOption(); //图表object对象
var op = this.myChart.getOption();
//获得图表中点击的列
itemName = op.xAxis[0].data[handleIndex]; //获取点击的列名
console.log(itemName,'monthmonthmonth');
console.log(handleIndex, seriesObj);
};
const baseIndex = this.baseNameToIndexMap[itemName] || 0;
console.log(`你点击了【${itemName}】(序号:${baseIndex})`);