X-range series
author(s): Torstein Hønsi
by Geo George
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/xrange.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
X-range charts are used to visualize a range on the X-axis.
This is often used in Gantt charts, as seen in this example.
The X-range data series forms the basis of Highcharts Gantt,
but is also available with Highcharts.
</p>
</figure>
CSS
#container {
height: 300px;
}
.highcharts-figure,
.highcharts-data-table table {
min-width: 320px;
max-width: 800px;
margin: 1em auto;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #ebebeb;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
JavaScript
Highcharts.chart('container', {
chart: {
typ: "column"
},
title: {
text: 'Highcharts X-range'
},
accessibility: {
point: {
descriptionFormatter: function (point) {
}
}
},
xAxis: {
},
yAxis: {
title: {
text: ''
},
categories: ['Prototyping', 'Development', 'Testing'],
reversed: true
},
series: [{
name: 'Project 1',
type: 'xrange',
// pointPadding: 0,
// groupPadding: 0,
borderColor: 'gray',
pointWidth: 1,
data: [{
x: 1,
x2: 5,
y: 0
}, {
x: 2,
x2: 3,
y: 1
},{
x: 4,
x2: 8,
y: 1
}, {
x:7,
x2: 12,
y: 2
}],
dataLabels: {
enabled: true
}
}]
});