javascript - 是否可以在区域范围图表顶部显示文本
问题描述
Highcharts.chart('container', {
chart: {
type: 'arearange',
zoomType: 'x',
scrollablePlotArea: {
minWidth: 600,
scrollPositionX: 1
}
},
title: {
text: 'Temperature variation by day'
},
xAxis: {
//type: 'datetime',
accessibility: {
rangeDescription: 'Range: Jan 1st 2017 to Dec 31 2017.'
}
},
yAxis: {
title: {
text: null
},
labels: {
enabled:true
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
//stacking: 'normal',
borderColor: '#303030',
color : '#cac9c9',
lineWidth: 1,
marker: {
lineWidth: 1,
lineColor: '#303030'
}
},
dataLabels: {
useHTML: true,
enabled: true,
inside: true,
align:'left',
allowDecimals: true,
formatter: function(){
return "SOME_TEXT_INSIDE_HTML_TAG";
}
},
},
series: [{
data: [
[0, 10],
[0, 10],
],
borderColor: 'black',
borderWidth: 0.2,
},
{
data: [
[20, 40],
[20, 40],
]
}]
});
以上是区域范围图的代码。几个问题。
- 我只想在每个区域的顶部显示一些随机文本。我尝试使用 dataLabels,但似乎没有用。难道不能这样做吗?
- 当鼠标悬停在图表上时,Yaxis 似乎显示在 AreaRange 图表中。可以设置为默认显示吗?
任何帮助将非常感激。提前致谢。
解决方案
我试图重现您的代码,这是一个输出:https ://jsfiddle.net/BlackLabel/uqmyjsr9/
配置
dataLabels
需要嵌套在series
对象中。plotOptions: { series: { //stacking: 'normal', borderColor: '#303030', color: '#cac9c9', lineWidth: 1, marker: { lineWidth: 1, lineColor: '#303030' }, dataLabels: { useHTML: true, enabled: true, inside: true, align: 'left', allowDecimals: true, formatter: function() { return "SOME_TEXT_INSIDE_HTML_TAG"; } }, }, },
我不确定 - yAxis 一直显示,不仅在悬停在图表上之后。
推荐阅读
- javascript - 反应原生 | 如何使用 Typescript 访问键盘的 endCoordinates 并重新组合
- go - 无法访问 Golang 中的登录页面
- ruby - chef 模板给出 No such file or directory @ rb_sysopen Errno::ENOENT
- php - PHP获取本地语言
- c# - 使用访问数据库将具有多个值的项目从列表框中显示到文本框中
- qt - 在 qml 自定义构建步骤中复制文件夹永远不会结束
- css - React Fontawesome 没有免费品牌 svg 图标,因此无法显示社交媒体图标
- php - 是否可以在 CodeIgniter 挂钩中加载单例?
- karma-jasmine - 启动 Pact 服务器抛出 Pact 二进制错误
- android - 将信用卡保存到 Google Pay