gpt4 book ai didi

javascript - Highcharts - 图表下的位置标题

转载 作者:搜寻专家 更新时间:2023-11-01 05:12:02 33 4
gpt4 key购买 nike

是否可以将标题直接放置在图表下方,如果我将其设置为 verticalAlign: 'bottom' 它不是直接放置在图表下方而是在底部,这不是我想要的。

title: {
enabled: true,
text: 'Foo',
verticalAlign: 'bottom',
align: 'left'
},

最佳答案

请参阅此 fiddle :Fiddle

我通过给它一个固定的 y 坐标将标题移动到所需的位置。

$(function () {
$('#container').highcharts({
chart: {
plotBorderWidth: 1,
marginLeft: 80,
marginBottom : 100 // this to make room for title under axis
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
title: {
text: 'My custom title',
align: 'center',
y: 340 // this to move y-coordinate of title to desired location
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});

如果您不想使用固定数字来定位您的标题(例如,您的图表可能会动态改变大小),不用担心,您可以为其提供公式或函数,例如:

$('#container').highcharts({
...
title: { y : $('#container').height() * 0.85 } // this will position the title with 85% margin from the top.
...
});

function myTitlePosition(params){ //return some custom value in here }

$('#container').highcharts({
...
title: { y : mytitlePosition(params) }
...
});

关于javascript - Highcharts - 图表下的位置标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21757174/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com