您的位置:首页 > 其它

【HighCharts系列教程】十、图例属性——legend

2015-01-27 16:39 190 查看

一、legend属性说明

Legend是HighCharts图表的图例属性,如图





默认情况下,HighCharts都会有图例,无特殊情况,默认即可满足需求,所以一般不用配置Legend属性。

二、lang属性详解

参数说明默认值
labelFormatter显示函数,主要是调用该数据列的名字labelFormatter: function() {
return this.name;
}
backgroundColor图例的背景颜色null
floating是否随x,y轴浮动false
shadow是否显示阴影false
layout布局,有垂直(vertical)和水平(horizontal)horizontal
width图例的宽度null
reversed数据列显示的顺序,为false时,从第一个数据列开始,否则倒序false
symbolWidth颜色条的宽度30
borderRadius图例边框圆角角度5
borderColor图例边框颜色#909090
borderWidth图例边框宽度1
align水平对齐,有left(左),centerr(中),右(right)center
verticalAlign垂直对齐,有top(上),middle(中),下(bottom)bottom
x

y

图例位置x:15

y:0

三、实例说明

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'bar',
},
credits : {
enabled:false//不显示highCharts版权信息
},
legend:{
labelFormatter: function() {
return this.name+"xx";
},
backgroundColor :'#6DBFBB',
floating:true,
shadow :true,
layout :'vertical',
width :150,
reversed :true,
symbolWidth :40,
borderRadius :10,
//borderColor :'red',
borderWidth :2,
align:'right',
verticalAlign :'top',
x:-20,
y:50
},
xAxis: {
type:'datetime',
categories: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
},
series: [{
name: 'series1',
data: [2,4,5,9,2,7]
},{
name:'series2',
data:[3,5,7,2,1,4]
}]
});
});
});
</script>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>

四、在线演示

演示地址:http://www.52wulian.org/test/HighCharts/highcharts_2_8_legend.html

五、资源下载

本文实例源文件:http://pan.baidu.com/share/link?shareid=263060&uk=3087605183
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: