I want to display my highchart like below. I'm using an 'xrange' type highchart for this. I'm trying to display an event for each data point where there will be a start data and an end date.
So far i was able to create this chart using xrange type, but I was not able to get the exact display like the above image. Below is my code,
Highcharts.chart('container', {
chart: {
type: 'xrange'
},
title: {
text: ''
},
xAxis: {
visible: false
},
yAxis: {
visible: false
},
legend: {
enabled: false
},
series: [{
name: '',
pointWidth: 20,
data: [{
x: Date.UTC(2014, 10, 21),
x2: Date.UTC(2014, 11, 2),
y: 0,
color: 'rgba(230, 141, 11, 0.5)',
pointWidth: 10
}, {
x: Date.UTC(2014, 10, 26),
x2: Date.UTC(2014, 11, 5),
color: 'rgba(228, 53, 70, 0.5)',
y: 0,
pointWidth: 10
}, {
x: Date.UTC(2014, 11, 8),
x2: Date.UTC(2014, 11, 10),
color: 'rgba(40, 167, 69, 0.5)',
y: 0,
pointWidth: 10
}, {
x: Date.UTC(2014, 11, 9),
x2: Date.UTC(2014, 11, 19),
color: 'rgba(40, 147, 164, 0.5)',
y: 0,
pointWidth: 10
}],
dataLabels: {
enabled: false
}
}]
});
@import 'https://code.highcharts.com/css/highcharts.css';
#container {
min-width: 300px;
max-width: 800px;
height: 300px;
margin: 1em auto;
}
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/xrange.js"></script>
<div id="container"></div>
Is there a way to change my implementation in highchart to get output like the above?
You can set a transparent color for points and use border color to achieve the wanted result. Use xAxis
to add the black line under the series.
xAxis: {
visible: true,
tickLength: 0,
lineWidth: 6,
lineColor: '#000',
labels: {
enabled: false
}
},
series: [{
borderWidth: 6,
data: [{
x: Date.UTC(2014, 10, 21),
x2: Date.UTC(2014, 11, 2),
y: 0,
color: 'transparent',
borderColor: 'rgba(230, 141, 11, 0.5)'
}, ...],
...
}]
Live demo: http://jsfiddle.net/BlackLabel/8p0weh7s/
API Reference:
https://api.highcharts.com/highcharts/series.xrange.borderColor