Reputation: 109
I want to get some arrows like the picture above
Upvotes: 0
Views: 1712
Reputation: 12472
You can render you own shapes and lay them on top of axis lines. Rendering custom shapes can be achieved via renderer.
You can also extend Highcharts in a way that the method responsible for rendering an axis line will be changed.
A simplified extension could look like this:
Highcharts.wrap(Highcharts.Axis.prototype, 'getLinePath', function(p, lineWidth) {
var linePath = p.call(this, lineWidth);
if (this.options.arrowOnEnd) {
var arrowFactor = 20,
x,
y,
arrowPath,
newPath;
if (this.horiz) {
x = linePath[4] = linePath[4] - arrowFactor;
y = linePath[5];
arrowPath = [
'L', x - 0.35 * arrowFactor, y - 0.35 * arrowFactor,
'L', x + 1 * arrowFactor, y,
'L', x - 0.35 * arrowFactor, y + 0.35 * arrowFactor,
'L', x, y
];
newPath = linePath.concat(arrowPath);
} else {
x = linePath[1];
y = linePath[2] = linePath[2]; // + arrowFactor;
arrowPath = [
'M', x, y,
'L', x - 0.35 * arrowFactor, y + 0.35 * arrowFactor,
'L', x, y - 1 * arrowFactor,
'L', x + 0.35 * arrowFactor, y + 0.35 * arrowFactor,
'L', x, y
];
newPath = arrowPath.concat(linePath);
}
return newPath;
}
return linePath;
});
CSS for filling the arrows:
.highcharts-axis-line {
fill: black;
stroke-linejoin: round;
}
example: http://jsfiddle.net/z2aagpeu/
Upvotes: 3