score:2
if you want to designate bank holidays or weekends, i would recommend using plotbands. to mark a specific milestone, you could use plotlines. here is an example of both applied to your chart.
$(function () {
/**
* highcharts x-range series plugin
*/ (function (h) {
var defaultplotoptions = h.getoptions().plotoptions,
columntype = h.seriestypes.column,
each = h.each;
defaultplotoptions.xrange = h.merge(defaultplotoptions.column, {});
h.seriestypes.xrange = h.extendclass(columntype, {
type: 'xrange',
parallelarrays: ['x', 'x2', 'y'],
animate: h.seriestypes.line.prototype.animate,
/**
* borrow the column series metrics, but with swapped axes. this gives free access
* to features like grouppadding, grouping, pointwidth etc.
*/
getcolumnmetrics: function () {
var metrics,
chart = this.chart,
swapaxes = function () {
each(chart.series, function (s) {
var xaxis = s.xaxis;
s.xaxis = s.yaxis;
s.yaxis = xaxis;
});
};
swapaxes();
this.yaxis.closestpointrange = 1;
metrics = columntype.prototype.getcolumnmetrics.call(this);
swapaxes();
return metrics;
},
translate: function () {
columntype.prototype.translate.apply(this, arguments);
var series = this,
xaxis = series.xaxis,
yaxis = series.yaxis,
metrics = series.columnmetrics;
h.each(series.points, function (point) {
barwidth = xaxis.translate(h.pick(point.x2, point.x + (point.len || 0))) - point.plotx;
point.shapeargs = {
x: point.plotx,
y: point.ploty + metrics.offset,
width: barwidth,
height: metrics.width
};
point.tooltippos[0] += barwidth / 2;
point.tooltippos[1] -= metrics.width / 2;
});
}
});
/**
* max x2 should be considered in xaxis extremes
*/
h.wrap(h.axis.prototype, 'getseriesextremes', function (proceed) {
var axis = this,
datamax = number.min_value;
proceed.call(this);
if (this.isxaxis) {
each(this.series, function (series) {
each(series.x2data || [], function (val) {
if (val > datamax) {
datamax = val;
}
});
});
if (datamax > number.min_value) {
axis.datamax = datamax;
}
}
});
}(highcharts));
// the chart
$('#container').highcharts({
chart: {
type: 'xrange'
},
title: {
text: 'highcharts x-range study'
},
xaxis: {
type: 'datetime',
/* start plotbands and plotlines edits */
pointinterval: 24 * 3600 * 1000, // one day,
plotlines: [{ // mark milestone date with vertical line
color: '#f45b5b',
width: '2',
value: date.utc(2014, 11, 6),
label: {
usehtml: true,
text: '<span style="color:#f45b5b"">dec 6, 2014</span>'
}
}],
plotbands: [{ // visualize the weekend or other range of dates
from: date.utc(2014, 11, 2),
to: date.utc(2014, 11, 5),
color: 'rgba(68, 170, 213, .2)'
}]
/* end plotbands and plotlines edits */
},
yaxis: {
title: '',
categories: ['prototyping', 'development', 'testing'],
min: 0,
max: 2
},
series: [{
name: 'project 1',
// pointpadding: 0,
// grouppadding: 0,
borderradius: 5,
pointwidth: 10,
data: [{
x: date.utc(2014, 11, 1),
x2: date.utc(2014, 11, 2),
y: 0
}, {
x: date.utc(2014, 11, 2),
x2: date.utc(2014, 11, 5),
y: 1
}, {
x: date.utc(2014, 11, 8),
x2: date.utc(2014, 11, 9),
y: 2
}, {
x: date.utc(2014, 11, 9),
x2: date.utc(2014, 11, 19),
y: 1
}, {
x: date.utc(2014, 11, 10),
x2: date.utc(2014, 11, 23),
y: 2
}]
}]
});
});
score:0
if you add a second axis and series (with the data of the milestones) you should be able to do it.
here is an example with a line on top of a column chart
$(function () {
$('#container').highcharts({
chart: {
zoomtype: 'xy'
},
title: {
text: 'average monthly temperature and rainfall in tokyo'
},
subtitle: {
text: 'source: worldclimate.com'
},
xaxis: [{
categories: ['jan', 'feb', 'mar', 'apr', 'may', 'jun',
'jul', 'aug', 'sep', 'oct', 'nov', 'dec'],
crosshair: true
}],
yaxis: [{ // primary yaxis
labels: {
format: '{value}°c',
style: {
color: highcharts.getoptions().colors[1]
}
},
title: {
text: 'temperature',
style: {
color: highcharts.getoptions().colors[1]
}
}
}, { // secondary yaxis
title: {
text: 'rainfall',
style: {
color: highcharts.getoptions().colors[0]
}
},
labels: {
format: '{value} mm',
style: {
color: highcharts.getoptions().colors[0]
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'left',
x: 120,
verticalalign: 'top',
y: 100,
floating: true,
backgroundcolor: (highcharts.theme && highcharts.theme.legendbackgroundcolor) || '#ffffff'
},
series: [{
name: 'rainfall',
type: 'column',
yaxis: 1,
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
tooltip: {
valuesuffix: ' mm'
}
}, {
name: 'temperature',
type: 'spline',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
tooltip: {
valuesuffix: '°c'
}
}]
});
});
score:0
you can use plotlines on xaxis.
score:1
thanks joshwa for a great answer.
if there are 2 projects, each of the 3 sections ('prototyping', 'development', 'testing') would have 2 bar one on top of the other for comparison.
$(function () {
/**
* highcharts x-range series plugin
*/ (function (h) {
var defaultplotoptions = h.getoptions().plotoptions,
columntype = h.seriestypes.column,
each = h.each;
defaultplotoptions.xrange = h.merge(defaultplotoptions.column, {});
h.seriestypes.xrange = h.extendclass(columntype, {
type: 'xrange',
parallelarrays: ['x', 'x2', 'y'],
animate: h.seriestypes.line.prototype.animate,
/**
* borrow the column series metrics, but with swapped axes. this gives free access
* to features like grouppadding, grouping, pointwidth etc.
*/
getcolumnmetrics: function () {
var metrics,
chart = this.chart,
swapaxes = function () {
each(chart.series, function (s) {
var xaxis = s.xaxis;
s.xaxis = s.yaxis;
s.yaxis = xaxis;
});
};
swapaxes();
this.yaxis.closestpointrange = 1;
metrics = columntype.prototype.getcolumnmetrics.call(this);
swapaxes();
return metrics;
},
translate: function () {
columntype.prototype.translate.apply(this, arguments);
var series = this,
xaxis = series.xaxis,
yaxis = series.yaxis,
metrics = series.columnmetrics;
h.each(series.points, function (point) {
barwidth = xaxis.translate(h.pick(point.x2, point.x + (point.len || 0))) - point.plotx;
point.shapeargs = {
x: point.plotx,
y: point.ploty + metrics.offset,
width: barwidth,
height: metrics.width
};
point.tooltippos[0] += barwidth / 2;
point.tooltippos[1] -= metrics.width / 2;
});
}
});
/**
* max x2 should be considered in xaxis extremes
*/
h.wrap(h.axis.prototype, 'getseriesextremes', function (proceed) {
var axis = this,
datamax = number.min_value;
proceed.call(this);
if (this.isxaxis) {
each(this.series, function (series) {
each(series.x2data || [], function (val) {
if (val > datamax) {
datamax = val;
}
});
});
if (datamax > number.min_value) {
axis.datamax = datamax;
}
}
});
}(highcharts));
// the chart
$('#container').highcharts({
chart: {
type: 'xrange'
},
title: {
text: 'highcharts x-range study'
},
xaxis: {
type: 'datetime',
pointinterval: 24 * 3600 * 1000, // one day,
},
yaxis: {
title: '',
categories: ['prototyping', 'development', 'testing'],
min: 0,
max: 2
},
series: [{
name: 'project 1',
borderradius: 5,
pointwidth: 10,
data: [{
x: date.utc(2014, 11, 1),
x2: date.utc(2014, 11, 2),
y: 0
},{
x: date.utc(2014, 11, 3),
x2: date.utc(2014, 11, 9),
y: 0
}, {
x: date.utc(2014, 11, 2),
x2: date.utc(2014, 11, 5),
y: 1
}, {
x: date.utc(2014, 11, 1),
x2: date.utc(2014, 11, 9),
y: 2
}, {
x: date.utc(2014, 11, 9),
x2: date.utc(2014, 11, 19),
y: 1
}, {
x: date.utc(2014, 11, 10),
x2: date.utc(2014, 11, 23),
y: 2
}]
},{
name: 'project 2',
borderradius: 5,
pointwidth: 10,
data: [{
x: date.utc(2014, 11, 1),
x2: date.utc(2014, 11, 2),
y: 0
}, {
x: date.utc(2014, 11, 2),
x2: date.utc(2014, 11, 5),
y: 1
}, {
x: date.utc(2014, 11, 8),
x2: date.utc(2014, 11, 9),
y: 2
}, {
x: date.utc(2014, 11, 9),
x2: date.utc(2014, 11, 19),
y: 1
}, {
x: date.utc(2014, 11, 13),
x2: date.utc(2014, 11, 18),
y: 2
}]
}]
});
});
Source: stackoverflow.com
Related Query
- How can I make milestone lines with a GANTT chart using the highcharts library?
- How can I display crosshair labels on top of the chart with Highcharts
- How can I get a chart only with legends using highcharts
- How can I make HighCharts 4.2.5 with boost.js invoke the tooltip formatter?
- How can I replace the term "Week" in highcharts Gantt Chart Timeline?
- How can I format the Highcharts gantt chart to be a dashed line instead of a solid line?
- The RTL language (Arabic) is not working with HighCharts pie chart correctly, how can I fix this?
- How to display the value instead of percentage in a pie chart using jquery Highcharts
- Add onclick event on chart made with the highcharts library
- How can I extend the lines of this Highchart series to the edges of my chart area?
- How can I force ticks/grid lines on a Highcharts datetime X axis to arbitrarily line up with data points?
- highcharts- stacked bar, how can I make the chart cover the width 100%?
- Highcharts : How do I keep the marker formatting and make the click event fire with a 5K+ point scatter plot?
- How can I make a graph with highcharts from csv file?
- How to use Highcharts React to create chart with multiple lines for same XAxis?
- Highcharts Gantt - how to make the horizontal rows / lanes taller?
- How do I make a Tornado Chart using Highcharts
- How to make a Highcharts semi-circle donut chart using Hightchart-ng
- How to make split grouped column bar chart in highcharts with percentage?
- How to make hover effect for two bar in highcharts at the same time is there any way by using css or any inbuilt method to achieve this?
- highcharts how to make x and y axis starting on the same zero using categories on yAxis
- In highcharts how can I provide data with values x, y, title so that I can put the title in the tooltip?
- How can i load external json data in highcharts to show the bar chart
- How can I prepare a Group Stacked Bar Chart in Highcharts using multiple and different types of data?
- How to make a HighCharts drilldown column/bar chart that does not hide the non-drilldown categories
- How can I reverse the series order of a pyramid chart in Highcharts
- How can a text box be bound dynamically to the right border of a chart created with Highcharts?
- How to show circular progress pie chart using the highcharts
- How can I make Highcharts label a datetime X-axis with relative dates?
- How can I get HighCharts column chart to scale the yAxis to not have so much whitespace?
More Query from same tag
- Highcharts: custom datalabel for bar chart. Format in PlotOptions not working
- Adding round corners to Highcharts Bar Chart with stacked bars when value is 0
- how to view graph based on date selection using highcharts
- Create a floating bar in HighCharts cloud
- How to make highchart chart (version 3) automatically resize with parent container?
- Dynamically update pointStart and pointInterval
- Passing callback function to labelFormatter in highchart legend in typescript
- Unable to change default rangeSelector Highstock
- Highcharts (grouped_category styling) and tooltip formatter not working
- How to change zone line color in highcharts
- Changing the color of each column in high charts
- HighCharts (Stock) Styling Issues (Mobile and Date Selector)
- HighCharts - bar chart with indicator
- Angular : Filter object data to build a Highchart Widget with distinct elements attributes
- Highcharts bubbles incorrect initial size, changes on resize
- highcharts, Set minimum height for stacked column chart?
- How to display data labels vertical?
- gem Lazy High Charts - Pie Donut
- Accessing a Highmaps node from outside the map
- In highcharts, the state of rangeselector buttons with custom events do not change correctly
- tickmarkPlacement 'between' doesn't work
- How to place dataLabels on series point in Highcharts
- Avoid showing duplicate stack labels on the every column series in a. highcharts
- Is there a way to plot more than 1000 points in a scatter plot using the Highcharts .NET Wrapper?
- Highchart: How to change y-axis title text inside angularjs controller?
- Time series horizontal bar chart for running queries visualization
- Using multiple hicharts on ASP.NET web form but only one shows on the upper section of the page pushing the page header down
- HighCharts getting data from database to outside js file
- Highcharts: How to access range values in formatter for "columnrange" type?
- Highstock - change tickpositioner dynamically