highcharts - Highchart - 更改线性量规图表的次要间距
问题描述
我正在尝试生成一个高图表线性度量图表。根据我检查的文档,我能够创建以下小提琴:http: //jsfiddle.net/7ch69o1p/
但我无法完成两件事:在顶部添加低、中、高并在底部绘制较长的刻度。
你能建议我必须更新的属性吗
我认为更新将在这里进行:
gridLineWidth: 1,
minorTickInterval: 8.33,
minorTickWidth: 1,
minorTickLength: 5,
minorGridLineWidth: 1,
解决方案
我准备了一个演示,它展示了如何通过使用渲染事件中的 SVGRenderer 功能来渲染自定义文本,该事件在每个窗口调整大小后触发以保持响应。请注意,我已将 id 添加到应呈现文本的带区,稍后我对它们进行了循环。我还添加了逻辑以使它们居中。
演示:http: //jsfiddle.net/BlackLabel/d3nf2yo7/
events: {
render() {
let chart = this,
yAxis = chart.yAxis[0];
//check if text exist after resize
if (customText.length) {
customText.forEach(text => {
text.destroy();
})
customText.length = 0;
}
//create a text for each plotBand with id
yAxis.plotLinesAndBands.forEach(pl => {
if (pl.id) {
let d = pl.svgElem.d,
textX = d.split(' '),
textY = d.split(' ')[2] - 5, //where 5 is a ppadding;
text;
text = chart.renderer.text(pl.id, textX[1], textY).add();
//set medium and high on the middle
if (pl.id === "Medium" || pl.id === "High") {
text.translate((textX[6] - textX[1]) / 2 - text.getBBox().width / 2, 0)
}
// set last value
if (pl.id === "Significant") {
text.translate(-text.getBBox().width + (textX[6] - textX[1]), 0)
}
customText.push(text);
}
})
}
}
API:https ://api.highcharts.com/highcharts/chart.events.render
API:https ://api.highcharts.com/class-reference/Highcharts.SVGRenderer#text
推荐阅读
- html - 我更改字体大小时不适用
- discord.js - 所以我想问一个问题来检索提到的频道但不起作用
- javascript - 如何防止使用 React-Router 和 Framer Motion 重新渲染父路由?
- google-cloud-platform - 如何在 Google Cloud 中创建默认项目?
- python - 如何检查经过训练的神经网络的预测输出
- php - 通过 PHP 获取 URL 的第二部分
- r - R为什么在管道之前使用<-
- c# - 独立运行单元测试(.net core)
- html - 列表中是否允许使用 HTML标签?
- python - 在 Python selenium 中,如何从具有相同名称的类中获取返回文本?