javascript - 如何在xaxis上添加多个文本
问题描述
我正在努力在 x 轴上添加多个文本。大多数像在 x 轴上给出名称字段这样的东西都不适用于桑基图。
问题:我需要在桑基图的 x 轴下方添加 2 个文本。蓝条正下方和中心的第一个文本。我需要的第二个文本就在灰色条的下方,但它应该与第一个文本在同一行
这是我的代码
Highcharts.chart('container', {
title: {
text: ''
},
xAxis: {
type: 'football league'
},
series: [{
keys: ['from', 'to', 'weight'],
data: [
['Football', 'Messi', 20 ],
['Football', 'ronaldo', 3 ],
//['Challenged', 'Terminated', 0 ],
['Football', 'sachin', 1 ],
['Messi', 'sehqag', 12 ],
//['Instituted', ' Terminated', 0 ],
['Messi', 'ashwin', 6 ],
['Messi', ' ramesg', 2 ],
],
type: 'sankey',
name: 'Sankey demo series'
}]
});
解决方案
要将文本添加到图表中,您可以使用annotations模块或Highcharts.SVGRenderer:
annotations: [{
labels: [{
text: 'annotations',
point: {
x: 100,
y: 380
}
}, {
text: 'annotations2',
point: {
x: 400,
y: 380
}
}]
}]
现场演示:https ://jsfiddle.net/BlackLabel/odc4jsku/
API:https ://api.highcharts.com/class-reference/Highcharts.SVGRenderer#text
文档:https ://www.highcharts.com/docs/advanced-chart-features/annotations-module
推荐阅读
- events - Flutter BLoC - 如何将参数传递给事件?
- spring-boot - 无法通过 servlet.context.path 连接 websocket
- php - 如何将用逗号分隔的 SQL 列数据分隔为单个值,然后对这些值进行计数
- php - 用于版本控制的 php ROUNDDOWN 双数字
- wordpress - 如何在我们的前端代码中使用 wordpress 默认图像编辑器?
- c# - WPF - 更新已发布应用程序的简单方法
- deep-learning - 在内存中加载 caffe 模型
- css - 如何使 div 宽度适应内部图像的宽度:自动?
- c# - System.reactive - 按频率动态切换
- django - 如何将ajax添加到删除表行的按钮?