|
|
|
@ -590,6 +590,7 @@ export default { |
|
|
|
xAxis: { data: this.lineXaxis }, |
|
|
|
series: [ |
|
|
|
{ data: this.lineSeriesData }, |
|
|
|
{ data: this.lineSeriesData }, |
|
|
|
|
|
|
|
] |
|
|
|
}, true) |
|
|
|
@ -792,6 +793,7 @@ export default { |
|
|
|
let hoveredIndex = '' |
|
|
|
// 监听点击事件,实现选中效果(单选) |
|
|
|
myChart.on('click', (params) => { |
|
|
|
debugger |
|
|
|
// 从 option.series 中读取重新渲染扇形所需的参数,将是否选中取反。 |
|
|
|
const isSelected = !this[optionName].series[params.seriesIndex].pieStatus |
|
|
|
.selected |
|
|
|
@ -834,107 +836,107 @@ export default { |
|
|
|
myChart.setOption(this[optionName]) |
|
|
|
}) |
|
|
|
// 监听 mouseover,近似实现高亮(放大)效果 |
|
|
|
// myChart.on('mouseover', (params) => { |
|
|
|
// // 准备重新渲染扇形所需的参数 |
|
|
|
// let isSelected |
|
|
|
// let isHovered |
|
|
|
// let startRatio |
|
|
|
// let endRatio |
|
|
|
// let k |
|
|
|
// // 如果触发 mouseover 的扇形当前已高亮,则不做操作 |
|
|
|
// if (hoveredIndex === params.seriesIndex) { |
|
|
|
// // 否则进行高亮及必要的取消高亮操作 |
|
|
|
// } else { |
|
|
|
// // 如果当前有高亮的扇形,取消其高亮状态(对 option 更新) |
|
|
|
// if (hoveredIndex !== '') { |
|
|
|
// // 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 false。 |
|
|
|
// isSelected = this[optionName].series[hoveredIndex].pieStatus.selected |
|
|
|
// isHovered = false |
|
|
|
// startRatio = this[optionName].series[hoveredIndex].pieData.startRatio |
|
|
|
// endRatio = this[optionName].series[hoveredIndex].pieData.endRatio |
|
|
|
// k = this[optionName].series[hoveredIndex].pieStatus.k |
|
|
|
// // 对当前点击的扇形,执行取消高亮操作(对 option 更新) |
|
|
|
// this[optionName].series[ |
|
|
|
// hoveredIndex |
|
|
|
// ].parametricEquation = getParametricEquation( |
|
|
|
// startRatio, |
|
|
|
// endRatio, |
|
|
|
// isSelected, |
|
|
|
// isHovered, |
|
|
|
// k, |
|
|
|
// this[optionName].series[hoveredIndex].pieData.value |
|
|
|
// ) |
|
|
|
// this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered |
|
|
|
// // 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空 |
|
|
|
// hoveredIndex = '' |
|
|
|
// } |
|
|
|
// // 如果触发 mouseover 的扇形不是透明圆环,将其高亮(对 option 更新) |
|
|
|
// if ( |
|
|
|
// params.seriesName !== 'mouseoutSeries' && |
|
|
|
// params.seriesName !== 'pie2d' |
|
|
|
// ) { |
|
|
|
// // 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。 |
|
|
|
// isSelected = |
|
|
|
// this[optionName].series[params.seriesIndex].pieStatus.selected |
|
|
|
// isHovered = true |
|
|
|
// startRatio = |
|
|
|
// this[optionName].series[params.seriesIndex].pieData.startRatio |
|
|
|
// endRatio = this[optionName].series[params.seriesIndex].pieData.endRatio |
|
|
|
// k = this[optionName].series[params.seriesIndex].pieStatus.k |
|
|
|
// // 对当前点击的扇形,执行高亮操作(对 option 更新) |
|
|
|
// this[optionName].series[ |
|
|
|
// params.seriesIndex |
|
|
|
// ].parametricEquation = getParametricEquation( |
|
|
|
// startRatio, |
|
|
|
// endRatio, |
|
|
|
// isSelected, |
|
|
|
// isHovered, |
|
|
|
// k, |
|
|
|
// this[optionName].series[params.seriesIndex].pieData.value + 60 |
|
|
|
// ) |
|
|
|
// this[optionName].series[ |
|
|
|
// params.seriesIndex |
|
|
|
// ].pieStatus.hovered = isHovered |
|
|
|
// // 记录上次高亮的扇形对应的系列号 seriesIndex |
|
|
|
// hoveredIndex = params.seriesIndex |
|
|
|
// } |
|
|
|
// // 使用更新后的 option,渲染图表 |
|
|
|
// myChart.setOption(this[optionName]) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// // 修正取消高亮失败的 bug |
|
|
|
// myChart.on('globalout', () => { |
|
|
|
// // 准备重新渲染扇形所需的参数 |
|
|
|
// let isSelected |
|
|
|
// let isHovered |
|
|
|
// let startRatio |
|
|
|
// let endRatio |
|
|
|
// let k |
|
|
|
// if (hoveredIndex !== '') { |
|
|
|
// // 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。 |
|
|
|
// isSelected = this[optionName].series[hoveredIndex].pieStatus.selected |
|
|
|
// isHovered = false |
|
|
|
// k = this[optionName].series[hoveredIndex].pieStatus.k |
|
|
|
// startRatio = this[optionName].series[hoveredIndex].pieData.startRatio |
|
|
|
// endRatio = this[optionName].series[hoveredIndex].pieData.endRatio |
|
|
|
// // 对当前点击的扇形,执行取消高亮操作(对 option 更新) |
|
|
|
// this[optionName].series[ |
|
|
|
// hoveredIndex |
|
|
|
// ].parametricEquation = getParametricEquation( |
|
|
|
// startRatio, |
|
|
|
// endRatio, |
|
|
|
// isSelected, |
|
|
|
// isHovered, |
|
|
|
// k, |
|
|
|
// this[optionName].series[hoveredIndex].pieData.value |
|
|
|
// ) |
|
|
|
// this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered |
|
|
|
// // 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空 |
|
|
|
// hoveredIndex = '' |
|
|
|
// } |
|
|
|
// // 使用更新后的 option,渲染图表 |
|
|
|
// myChart.setOption(this[optionName]) |
|
|
|
// }) |
|
|
|
myChart.on('mouseover', (params) => { |
|
|
|
// 准备重新渲染扇形所需的参数 |
|
|
|
let isSelected |
|
|
|
let isHovered |
|
|
|
let startRatio |
|
|
|
let endRatio |
|
|
|
let k |
|
|
|
// 如果触发 mouseover 的扇形当前已高亮,则不做操作 |
|
|
|
if (hoveredIndex === params.seriesIndex) { |
|
|
|
// 否则进行高亮及必要的取消高亮操作 |
|
|
|
} else { |
|
|
|
// 如果当前有高亮的扇形,取消其高亮状态(对 option 更新) |
|
|
|
if (hoveredIndex !== '') { |
|
|
|
// 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 false。 |
|
|
|
isSelected = this[optionName].series[hoveredIndex].pieStatus.selected |
|
|
|
isHovered = false |
|
|
|
startRatio = this[optionName].series[hoveredIndex].pieData.startRatio |
|
|
|
endRatio = this[optionName].series[hoveredIndex].pieData.endRatio |
|
|
|
k = this[optionName].series[hoveredIndex].pieStatus.k |
|
|
|
// 对当前点击的扇形,执行取消高亮操作(对 option 更新) |
|
|
|
this[optionName].series[ |
|
|
|
hoveredIndex |
|
|
|
].parametricEquation = getParametricEquation( |
|
|
|
startRatio, |
|
|
|
endRatio, |
|
|
|
isSelected, |
|
|
|
isHovered, |
|
|
|
k, |
|
|
|
this[optionName].series[hoveredIndex].pieData.value |
|
|
|
) |
|
|
|
this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered |
|
|
|
// 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空 |
|
|
|
hoveredIndex = '' |
|
|
|
} |
|
|
|
// 如果触发 mouseover 的扇形不是透明圆环,将其高亮(对 option 更新) |
|
|
|
if ( |
|
|
|
params.seriesName !== 'mouseoutSeries' && |
|
|
|
params.seriesName !== 'pie2d' |
|
|
|
) { |
|
|
|
// 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。 |
|
|
|
isSelected = |
|
|
|
this[optionName].series[params.seriesIndex].pieStatus.selected |
|
|
|
isHovered = true |
|
|
|
startRatio = |
|
|
|
this[optionName].series[params.seriesIndex].pieData.startRatio |
|
|
|
endRatio = this[optionName].series[params.seriesIndex].pieData.endRatio |
|
|
|
k = this[optionName].series[params.seriesIndex].pieStatus.k |
|
|
|
// 对当前点击的扇形,执行高亮操作(对 option 更新) |
|
|
|
this[optionName].series[ |
|
|
|
params.seriesIndex |
|
|
|
].parametricEquation = getParametricEquation( |
|
|
|
startRatio, |
|
|
|
endRatio, |
|
|
|
isSelected, |
|
|
|
isHovered, |
|
|
|
k, |
|
|
|
this[optionName].series[params.seriesIndex].pieData.value + 60 |
|
|
|
) |
|
|
|
this[optionName].series[ |
|
|
|
params.seriesIndex |
|
|
|
].pieStatus.hovered = isHovered |
|
|
|
// 记录上次高亮的扇形对应的系列号 seriesIndex |
|
|
|
hoveredIndex = params.seriesIndex |
|
|
|
} |
|
|
|
// 使用更新后的 option,渲染图表 |
|
|
|
myChart.setOption(this[optionName]) |
|
|
|
} |
|
|
|
}) |
|
|
|
// 修正取消高亮失败的 bug |
|
|
|
myChart.on('globalout', () => { |
|
|
|
// 准备重新渲染扇形所需的参数 |
|
|
|
let isSelected |
|
|
|
let isHovered |
|
|
|
let startRatio |
|
|
|
let endRatio |
|
|
|
let k |
|
|
|
if (hoveredIndex !== '') { |
|
|
|
// 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。 |
|
|
|
isSelected = this[optionName].series[hoveredIndex].pieStatus.selected |
|
|
|
isHovered = false |
|
|
|
k = this[optionName].series[hoveredIndex].pieStatus.k |
|
|
|
startRatio = this[optionName].series[hoveredIndex].pieData.startRatio |
|
|
|
endRatio = this[optionName].series[hoveredIndex].pieData.endRatio |
|
|
|
// 对当前点击的扇形,执行取消高亮操作(对 option 更新) |
|
|
|
this[optionName].series[ |
|
|
|
hoveredIndex |
|
|
|
].parametricEquation = getParametricEquation( |
|
|
|
startRatio, |
|
|
|
endRatio, |
|
|
|
isSelected, |
|
|
|
isHovered, |
|
|
|
k, |
|
|
|
this[optionName].series[hoveredIndex].pieData.value |
|
|
|
) |
|
|
|
this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered |
|
|
|
// 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空 |
|
|
|
hoveredIndex = '' |
|
|
|
} |
|
|
|
// 使用更新后的 option,渲染图表 |
|
|
|
myChart.setOption(this[optionName]) |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|