【HighCharts系列教程】10、圖例屬性——legend

1、legend屬性說明

Legend是HighCharts圖表的圖例屬性,如圖javascript

highcharts_2_8_legend

默認狀況下,HighCharts都會有圖例,無特殊狀況,默認便可知足需求,因此通常不用配置Legend屬性。html

2、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

xjava

yjquery

圖例位置

x:15函數

y:0佈局

3、實例說明

 

<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>

4、在線演示

5、資源下載

相關文章
相關標籤/搜索