html:
<!--折線圖-->
<ve-line :extend="item.chartExtend"
:data-zoom="dataZoom"
:height="chartHeight"
:legend="item.legend"
:data="item"
:events="chartEvents"
:settings="isRateTypeData(item.id)?successRateSettings:chartSettings"></ve-line>
須要在v-charts圖表添加legend屬性
chartDataColumns.map(item => {
console.log('chartDataColumns66',chartDataColumns)
if(item !== 'TIME'){
selectedObj[item] = true
}
})
chartItem['legend'] = selectedObj
this.chartEvents = { legendselectchanged: (item) => { let currSelectName = item.name let currChartItem = self.chartData[self.deleteIndex] let selectedObj = item.selected let selectedNum = 0 for(let key in selectedObj){ if(selectedObj[key]){ // selected對象內值爲true selectedNum++ } selectedObj[key] = false } if(selectedNum > 1){ // selectedNum > 1說明當前所有選中,此時點擊,只有當前的設爲選中 for(let key in selectedObj){ selectedObj[key] = false } selectedObj[currSelectName] = true }else{ // 當前只有一個選中,點擊後,所有重置爲選中 for(let key in selectedObj){ selectedObj[key] = true } } self.$set(currChartItem['legend'], 'selected', selectedObj) }}