[apache/echarts]自定义lenged,使用icon图片,将图例换位checkbox勾选形式,这种情况下使用selector全选反选后,点击某个图例全选反选会消失

2024-07-16 909 views
2

4.7.0

自定义lenged,使用icon图片后,设置的全选反选按钮点击图例后会消失;非自定义则不会

当点击全选,反选正常,点击图例全选返选按钮还在

回答

7

不太确定这是否是一个Bug。不必更新全部的option,只传入legend可以解决你的问题。

myChart.on('legendselectchanged', (params) => {
    console.log(params)
    legendData.forEach(e => {
        if (e.name === params.name) {
            if (e.selected) {
                e.icon = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4b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CAgEBAICAYGAQEAggEBAICAQEAgIBAQCAgGBgEBAIIBAQCAgEBAICAQEAgIBgYBAAIGAQEAgIBAQCAgEBAICAYGAQACBgEBAICAQEAgIBAQCAgGBgEAcAQgEBAICAYGAQEAgIBAQCAgEEAgIBAQCAgGBgEBAICAQEAgIBBAICAQEAgIBgYBAQCAgEBAIIBAQCAgEBAICAYGAQEAgIBAQCCAQEAgIBAQCAgGBgECg43RN1A9KksRp4goCAgEEAgIBgYBAQCAgEBAICAQEAgIBBAICAYHAvwtkJOf9JzsyOkDe3+ORLJDhnA9Y6WwpuKmxZTnvO5QFMpTzAX2x2c6YAjvexn3fVKrVanpjf6yacy9iW2PTnDUFsjh2po3f89fpg5I0kCRJZsTtd+nXzhFGnYsdzJ5ivY89cCbw06X6K0h6e1PsrnOBykBsXXqj/n2Qe7EbzgYqh7Ib498o7Ku9FoGyOhF7kn1R/xQrsyb2KNbtrCiZ/tj2+m80+qjJ49iW2GfnRYlcju0e/81mn8W6E1sfG3RulMDJWhxff/svtTcKm0k/s3KkMvbXwFWzDtvV2MI/BdDoNUgz6dOubbEVsTmxef7HQ4F8qIx9pCr9JMit2uuNV60elLS4gkCp/RBgAKHG2S23r3+PAAAAAElFTkSuQmCC'
            } else {
                e.icon = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAQP0lEQVR4Xu2dechuVRXGf1bapCiWYZY2mYoGklNaapmaMxaR5dBgSnibNMghvZljWgYZFBqYheKUZGXmmGmppU0iFpGZNqGVKaUR0aDx6Hnx8973+95zzt7nvOvs86x/Lpdv73X2/u3zvGdae61VsJmACSxKYJUGbHYD9gC2AV4EbNCgr5uawLwJPAT8GbgXuA74OvC7WYOaJZBVgWXAcmCdWc78dxMYGIFvAUcDv1xs3EsJZFPgcuAVA5u0h2sCTQmcBhw7rdNiAtkeuAJYs+mR3N4EBkrgUuBA4D8Lxz9NIFsBNwPPHOhEPWwTaEtAItlvKYG8GLgdeH7bI7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F+H/DFGr71BmwnQN88bPEIWCAdrsmngSOX8K/qVxLHPzocg12nEbBA0vjN7P1h4KQp5Z8VGax9JkryZotLwALpYW3WqMLkFcOlHYAXAPf2cFwfIp2ABZLO0B4KJmCBFLy4nlo6AQsknaE9FEzAAil4cT21dAIWSDpDeyiYgAVS8OJ6aukELJB0hvZQMAELpODF9dTSCVgg6QztoWACFkjBi+uppROwQNIZ2kPBBCyQghfXU0snYIGkM7SHgglYIAUvrqeWTsACSWdoDwUTsEAKXlxPLZ2ABZLO0B4KJmCBFLy4nlo6AQsknaE9FEzAAil4cT21dAIWSDpDeyiYgAVS8OJ6aukELJB0hvZQMAELpODF9dTSCVgg6QztoWACFkjBi+uppRNoLJCrgd1qHPddwPk12rmJCUQmcCfwqhoD3HmVqtF5wDtrdDgT+EiNdm5iAlEJrA6oTn0d22wikFkp/SfOlLV8Q+D+Ot7dxgQCEqh7rmvoa08EcjBwbs3J3AMo/f9NwMM1+7iZCcybwCbAYVV5ijpj0UVgvYlAVA/8AWDy/zoO3MYESiagkt3LFgrie8COJc/YczOBBgR2Aa5fKBCVDftuAwduagKlErgV2E6TW/GW6ipg91Jn7XmZQE0CWwC3TxPI+oA+oqxT05GbmUBpBE4Gjp9MatpD+dbALcCqpc3c8zGBGQSuAPZZ2Gaxt1Z6QLkMUKFKmwmMgYDO9/1XrG2/1GtdfYqXol4yBjqe46gJnAosn0Zg1neP1YAPVJ3XHjVCT75EApcDRwJ3LTa5WQJZ2G9PYG/g1frCCGxQIjHPqVgCDwF/An4DXFvdHf121mybCGSWL//dBIoj8H9gwydXY/GgFQAAAABJRU5ErkJggg=='

            }
            e.selected = !e.selected
        }
    })
    // myChart.setOption(option)
    console.log(legendData)
    myChart.setOption({
        legend: {
            data: legendData
        }
    })
})

// 全选 此事件API文档未提供描述
myChart.on('legendselectall', (params) => {
    console.log('legendselectall', params)
    legendData.forEach(e => {
        e.selected = true
        e.icon = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM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O9/1XrG2/1GtdfYqXol4yBjqe46gJnAosn0Zg1neP1YAPVJ3XHjVCT75EApcDRwJ3LTa5WQJZ2G9PYG/g1frCCGxQIjHPqVgCDwF/An4DXFvdHf121mybCGSWL//dBIoj8H9gwydXY/GgFQAAAABJRU5ErkJggg=='
    })
    console.log(legendData)
    myChart.setOption({
        legend: {
            data: legendData
        }
    })
})

// 反选 此事件API文档未提供描述
myChart.on('legendinverseselect', (params) => {
    console.log('legendinverseselect', params)
    legendData.forEach(e => {
        e.selected = false
        e.icon = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5j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AgEEAgIBAQCAgEBAICAYGAQEAggEBAICAQEAgIBAQCAgGBgEBAIIBAQCAgEBAICAQEAgIBgYBAAIGAQEAgIBAQCAgEBAICAYGAQACBgEBAICAQEAgIBAQCAgGBgEAcAQgEBAICAYGAQEAgIBAQCAgEEAgIBAQCAgGBgEBAICAQEAgIBBAICAQEAgIBgYBAQCAgEBAIIBAQCAgEBAICAYGAQEAgIBAQCCAQEAgIBAQCAgGBgECg43RN1A9KksRp4goCAgEEAgIBgYBAQCAgEBAICAQEAgIBBAICAYHAvwtkJOf9JzsyOkDe3+ORLJDhnA9Y6WwpuKmxZTnvO5QFMpTzAX2x2c6YAjvexn3fVKrVanpjf6yacy9iW2PTnDUFsjh2po3f89fpg5I0kCRJZsTtd+nXzhFGnYsdzJ5ivY89cCbw06X6K0h6e1PsrnOBykBsXXqj/n2Qe7EbzgYqh7Ib498o7Ku9FoGyOhF7kn1R/xQrsyb2KNbtrCiZ/tj2+m80+qjJ49iW2GfnRYlcju0e/81mn8W6E1sfG3RulMDJWhxff/svtTcKm0k/s3KkMvbXwFWzDtvV2MI/BdDoNUgz6dOubbEVsTmxef7HQ4F8qIx9pCr9JMit2uuNV60elLS4gkCp/RBgAKHG2S23r3+PAAAAAElFTkSuQmCC'
    })
    console.log(legendData)
    myChart.setOption({
        legend: {
            data: legendData
        }
    })
})
2

API有提供全选/反选的事件和action 只是文档未说明 全选的action是 legendAllSelect 反选的action是 legendInverseSelect 全选的event是 legendselectall 反选的event是 legendinverseselect

1

这么写还有些bug关于反选,我在改下 感谢!!