<1>全局选项(GLOBAL OPTIONS)
(1)使用
(2)实例一:
({
chart: {
backgroundColor: {
linearGradient: [0, 0, 500, 500],
stops: [
[0, 'rgb(255, 255, 255)'],
[1, 'rgb(240, 240, 255)']
]
},
borderWidth: 2,
plotBackgroundColor: 'rgba(255, 255, 255, .9)',
plotShadow: true,
plotBorderWidth: 1
}
});
(3)实例二:
// global Highcharts settings
({
chart: {
style: {
fontFamily: '"Helvetica", sans-serif'
},
events: {
click: function() {
(.CLOSE_DROPDOWN);
}
}
},
plotOptions: {
series: {
events: {
click: function() {
(.CLOSE_DROPDOWN);
}
}
}
}
});
<2>可以阅读的代码习惯
(1)坏的代码习惯:
// Bad code:
var options = new Object();
= new Object();
= 'container';
= 'bar';
= new Array();
[0] = new Object();
[0].name = 'Jane';
[0].data = new Array(1, 0, 4);
(2)好的代码习惯:
// Good code:
var options = {
chart: {
renderTo: 'container',
type: 'bar'
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}]
};
备注:上面两个代码片的结果是一样的。
(3)将上面的代码添加到Highcharts中
$(document).ready(function() {
var chart = new (options);
});
(4)因为 是数组,所以用数组的方式添加。
用符号点(. )(dot notation)添加。
({
name: 'John',
data: [3, 4, 2]
})
(5) 和 options['renderTo'] 效果一样