Issue: cannot change xrange series color
author(s): Anastasiia
by Black Label
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/xrange.js"></script>
<button id="btn-update">Update</button>
<div id="chart"></div>
CSS
#chart {
width: 200px;
height: 170px;
}
JavaScript
const axisOptions = {
title: {
text: null
},
labels: {
distance: 8
},
lineWidth: 1,
gridLineWidth: 1,
tickWidth: 1,
tickLength: 5,
tickPixelInterval: 40,
startOnTick: false,
endOnTick: false,
};
const options = {
chart: {
animation: false
},
rangeSelector: {
enabled: false
},
scrollbar: {
enabled: false
},
tooltip: {
enabled: false
},
title: {
text: undefined
},
legend: {
enabled: false
},
credits: {
enabled: false
},
accessibility: {
enabled: false
},
xAxis: {
...axisOptions,
min: -25,
max: 25,
},
yAxis: {
...axisOptions,
showFirstLabel: false,
min: 0,
max: 75,
},
series: [{
type: 'xrange',
animation: false,
enableMouseTracking: false,
colors: ['pink'],
borderColor: 'red',
data: [{
x: -20,
x2: 5,
y: 50
},
{
x: -5,
x2: 5,
y: 10
},
{
x: 5,
x2: 15,
y: 30
},
],
}, ],
};
var highchart = Highcharts.chart('chart', options);
var btnUpdate = document.getElementById('btn-update');
btnUpdate.onclick = function() {
highchart.series[0].update({
colors: ['lime'],
borderColor: 'green'
});
};