[英]How can I get arrows at the end of x-axis and y-axis using highcharts.js?
You can render you own shapes and lay them on top of axis lines. 您可以渲染自己的形状并将其放置在轴线上方。 Rendering custom shapes can be achieved via renderer .
可以通过renderer实现自定义形状的渲染 。
You can also extend Highcharts in a way that the method responsible for rendering an axis line will be changed. 您还可以通过更改负责渲染轴线的方法的方式来扩展Highcharts 。
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: 填充箭头的CSS:
.highcharts-axis-line {
fill: black;
stroke-linejoin: round;
}
example: http://jsfiddle.net/z2aagpeu/ 示例: http : //jsfiddle.net/z2aagpeu/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.