jQuery 如何在 Highcharts 中移动图例?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17500064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I move legend in Highcharts?
提问by PSR
By default legend is displaying at the top-right side of the graph. I want to show it just above the graph. I've used the following code:
默认情况下,图例显示在图表的右上角。我想在图表上方显示它。我使用了以下代码:
legend: {
layout: 'vertical',
align: 'left',
x: 600,
verticalAlign: 'top',
y: 40,
floating: true,
backgroundColor: '#FFFFFF'
}
But it is not working for me. Am I doing anything wrong?
但它对我不起作用。我做错了什么吗?
回答by Sri--
Like this:
像这样:
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
floating: true,
backgroundColor: '#FFFFFF'
},
http://api.highcharts.com/highcharts#legend.verticalAlignhttp://api.highcharts.com/highcharts#legend.align
http://api.highcharts.com/highcharts#legend.verticalAlign http://api.highcharts.com/highcharts#legend.align
回答by Andrey Nelubin
Do you want to place legend above whole graph or just above plot? Is that what you need? http://jsfiddle.net/8Qm5a/
您想将图例放在整个图形上方还是图上方?那是你需要的吗?http://jsfiddle.net/8Qm5a/
Anyway, if you need to place legend above the title, try to change marginTop
of chart settings and set y
settings in title options:
无论如何,如果您需要在标题上方放置图例,请尝试更改marginTop
图表设置并y
在标题选项中设置设置:
chart: {
marginTop: 100
},
title: {
text: "test",
y: 60
},