如何在列高图中添加不同的颜色边框

切换方法 – 单击条形图显示边框和隐藏边框。 但背景不应该改变。 请参考我的代码,我们有任何切换方法吗?

使用此post中的先前代码,您的代码无法重现

更新如下

plotOptions: { series: { events: { click: function(e) { var chart = e.point.series.chart; e.point.select(true, false); //at any time only one column is selected /*logic for toggle*/ if (currSel !== e.point.index) { chart.series[0].data[e.point.index].graphic.attr({ 'stroke': colors[e.point.index], 'stroke-width': width[e.point.index], 'fill': Highcharts.defaultOptions.colors[e.point.index], }); currSel = e.point.index; } else { chart.series[0].data[e.point.index].graphic.attr({ 'stroke': "", 'stroke-width': 0, 'fill': Highcharts.defaultOptions.colors[e.point.index], }); currSel = ""; } } }, } }, 
 var colors = ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92' ]; var width = [2, 5, 6, 8, 9, 3, 4]; var currSel; Highcharts.chart('container', { chart: { type: 'column' }, title: { text: 'Stacked bar chart' }, xAxis: { categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] }, yAxis: { min: 0, title: { text: 'Total fruit consumption' } }, legend: { reversed: true }, plotOptions: { series: { events: { click: function(e) { var chart = e.point.series.chart; e.point.select(true, false); if (currSel !== e.point.index) { chart.series[0].data[e.point.index].graphic.attr({ 'stroke': colors[e.point.index], 'stroke-width': width[e.point.index], 'fill': Highcharts.defaultOptions.colors[e.point.index], }); currSel = e.point.index; } else { chart.series[0].data[e.point.index].graphic.attr({ 'stroke': "", 'stroke-width': 0, 'fill': Highcharts.defaultOptions.colors[e.point.index], }); currSel = ""; } } }, } }, series: [{ name: 'John', data: [3, 4, 4, 2, 5], showInLegend: false, name: 'Twitter Trending', colorByPoint: true, }] });