javascript Highcharts 图例自定义 css 样式/格式仅使用 highcharts 选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10554694/
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
Highcharts legend custom css style / format using only highcharts options
提问by AlexRebula
I've tried lots of combinations in the legend options of the highcharts object, however I was not able to successfully realize the exact design that the designer made.
我在 highcharts 对象的图例选项中尝试了很多组合,但是我无法成功实现设计师所做的确切设计。
What I need is to be able to have a legend that looks exactly like this... Wanted legend layout
我需要的是能够有一个看起来完全像这样的图例...... 想要图例布局
But the closest result that I achieved with the legend options available was this... The closest legend layout I could achieve
但是我使用可用的图例选项获得的最接近的结果是... 我可以实现的最接近的图例布局
The properties I used within the highchart object definition were:
我在 highchart 对象定义中使用的属性是:
legend: {
enabled: graphProperties.legend.enabled,
backgroundColor: ...
borderRadius: ...
verticalAlign: ...
align: ...
borderWidth: ...
x: ...
y: ... }
Thank you in advance for any help.
预先感谢您的任何帮助。
回答by mg1075
Maybe you can use this as a starting point.
也许您可以以此为起点。
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
backgroundColor: '#F5F5F5',
plotBackgroundColor: '#FFFFFF'
},
symbols: [ 'square', 'square' ],
legend: {
backgroundColor: '#F5F5F5',
layout: 'horizontal',
floating: true,
align: 'left',
verticalAlign: 'top',
x: 60,
y: 1,
shadow: false,
border: 0,
borderRadius: 0,
borderWidth: 0
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
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],
color: '#47D147'
}, {
data: [95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1],
color: '#19A3FF'
}]
});
});?