仅将特定系列添加到Shield UI图表图例中

Adding only specific series to the Shield UI Chart legend

本文关键字:UI Shield 系列 添加      更新时间:2023-09-26

有没有办法不在图例中显示序列?正如我所看到的,有

 seriesSettings:{
                line:{
                    addToLegend:true,
                    dataPointText:{
                        enabled:true,
                            borderRadius:4,
                            borderWidth:2,
                            borderColor:'red',
                    }
                }
}, 

但这显示/隐藏了整个系列。例如,如果我有一行和一个条形图数据序列,是否可以只隐藏其中一个?

是的,您可以有选择地显示/隐藏相同类型的序列,但需要为addToLegend属性添加必要的值。

              {
                    seriesType: 'line',
                    addToLegend:true,
                    collectionAlias: 'Households',
                    data: [0.164, 0.173, 0.184, 0.125,0.258,0.255]
                },                    
                {
                    seriesType: 'line',
                    addToLegend:false,
                    collectionAlias: 'Industry',
                    data: [0.103,0.105,0.112]
                },     
            ]. 

此外,您甚至可以省略序列中的初始声明设置:{line:{,因为默认情况下该属性为true。为了减轻代码的负担,您只能在需要时将该属性设置为false。