# 標示區(plotBands)
標示區同標示線,只不過標示的內容為一段范圍。標示區的作用、事件等很多都類似標示線,這里就只是簡單說明標示區的相關內容,不做過多累述。

### 一、標示區的基本配置
```
xAxis: {
// ... 省略代碼
plotBands: [{
from: , // 標示區開始值
to: , // 標示區結束值
label: { // 標示區文字標簽配置,詳見API
},
color: '', // 標示區背景顏色
borderWidth: , // 標示區邊框寬度
borderColor: , // 標示區邊框顏色
id: , // 標示區 id,用于刪除等操作
zIndex:, // 標示區層疊,用于調整顯示層次
events: { // 事件,支持 click、mouseover、mouseout、mousemove等事件
click: function(e) {
},
mouseover: function(e) {
},
mouseout: function(e) {
},
mousemove: function(e) {
}
}
}]
},
yAxis: {
// ... 省略代碼
plotBands: [{
// 標示區配置,同上
}]
}
```
[在線試一試](http://code.hcharts.cn/hcharts.cn/hhhGfX)
### 二、動態增加或刪除標示區
同標示線一樣,我們可以通過 Axis.addPlotBand 及 Axis.removePlotBand 來動態增加或刪除標示線。
#### 1、動態增加標示區
```
// 實例化圖表并保存圖表對象
var chart = new Highcharts.Chart();
var axis = chart.xAxis[0];
axis.addPlotBand({
id: 'myXAxisPlotBand', // id 用于后續刪除用
from: 20,
to: 40,
// ...
});
```
[在線試一試](http://code.hcharts.cn/hcharts.cn/hhhGfQ)
#### 2、動態刪除標示區
```
var chart = new Highcharts.Chart();
var axis = chart.xAxis[0];
axis.removePlotBand('myXAxisPlotBand')
```
[在線試一試](http://code.hcharts.cn/hcharts.cn/hhhGfQ)
* * *
(正文完,最后更新時間:2015-09-11 09:48:22)
- Highcharts中文教程
- Highcharts入門(100%)
- Highcharts簡介
- Highcharts下載與使用
- Highcharts配置
- Hello World程序
- Highcharts兼容性
- Highcharts使用許可
- Highcharts基礎教程(67%)
- Highcharts主要組成
- 圖表配置(Chart)
- 標題(Title)
- 坐標軸(Axis)
- 數據列(Series)
- 顏色(colors)
- 數據提示框(Tooltip)
- 圖例(Legend)
- 版權信息(credits)
- HTML標簽(labels)
- 標示線(plotLines)
- 標示區(plotBands)
- 圖表縮放(Zoom)
- 語言文字(lang)
- 標簽及字符串格式化(Format)