<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Highcharts Demo</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/highcharts.js"></script>
<script type="text/javascript" src="js/excanvas.compiled.js"></script>
<script type="text/javascript">
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',//設置顯示圖表的容器
type: 'line',//設置圖表樣式,可以爲line,spline, scatter, splinearea bar,pie,area,column
// defaultSeriesType: 'column', //圖表的默認樣式
// margin:[21, 23, 24, 54],//整個圖表的位置(上下左右的空隙)
marginRight: 200,//右邊間距
marginBottom: 25//底部間距/空隙
// inverted: false,//可選,控制顯示方式,默認上下正向顯示
// shadow:true,//外框陰影
// backgroundColor:"#FFF",
// animation:true,
// borderColor:"#888",
// borderRadius:5,
// borderWidth:1,
// ignoreHiddenSeries:true,
// reflow:true,
// plotBorderWidth:1,
// alignTicks:true
},
labels:{//在報表上顯示的一些文本
items:[{
html:'本圖表數據有誤,僅用於說明相應的屬性',
style:{left:'100px',top:'60px'}
}, {
html:'http://www.highcharts.com/demo',
style:{left:'100px',top:'100px'}
}]
},
credits:{//右下角的文本
enabled: true,
position: {//位置設置
align: 'right',
x: -10,
y: -10
},
href: "http://www.highcharts.com",//點擊文本時的鏈接
style: {
color:'blue'
},
text: "Highcharts Demo"//顯示的內容
},
// plotOptions:{//繪圖線條控制
// spline:{
// allowPointSelect :true,//是否允許選中點
// animation:true,//是否在顯示圖表的時候使用動畫
// cursor:'pointer',//鼠標移到圖表上時鼠標的樣式
// dataLabels:{
// enabled :true,//是否在點的旁邊顯示數據
// rotation:0
// },
// enableMouseTracking:true,//鼠標移到圖表上時是否顯示提示框
// events:{//監聽點的鼠標事件
// click: function() {
// }
// },
// marker:{
// enabled:true,//是否顯示點
// radius:3,//點的半徑
// fillColor:"#888"
// lineColor:"#000"
// symbol: 'url(http://highcharts.com/demo/gfx/sun.png)',//設置點用圖片來顯示
// states:{
// hover:{
// enabled:true//鼠標放上去點是否放大
// },
// select:{
// enabled:false//控制鼠標選中點時候的狀態
// }
// }
// },
// states:{
// hover:{
// enabled:true,//鼠標放上去線的狀態控制
// lineWidth:3
// }
// },
// stickyTracking:true,//跟蹤
// visible:true,
// lineWidth:2//線條粗細
// pointStart:100,
// }
// },
title: {
text: 'Monthly Average Temperature',//標題
x: -20 //center設置標題的位置
},
subtitle: {
text: 'Source: WorldClimate.com',//副標題
x: -20//副標題位置
},
xAxis: {//橫軸的數據
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
// lineWidth:1,//縱軸一直爲空所對應的軸,即X軸
// plotLines: [{//一條豎線
// color: '#FF0000',
// width: 2,
// value: 5.5
// }]
// labels: {//設置橫軸座標的顯示樣式
// rotation: -45,//傾斜度
// align: 'right',
// style: {
// font: 'normal 13px Verdana, sans-serif'
// color: 'white'
// }
// }
},
yAxis: {
// tickInterval: 200, //自定義刻度
// max:1000,//縱軸的最大值
// min: 0,//縱軸的最小值
title: {//縱軸標題
text: '百分數'
},
labels : {
formatter : function() {//設置縱座標值的樣式
return this.value + '%';
}
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {//鼠標移到圖形上時顯示的提示框
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y +'°C';
}
// crosshairs:[{//控制十字線
// width:1,
// color:"#CCC",
// dashStyle:"longdash"
// }
},
legend: {//方框所在的位置(不知道怎麼表達) 圖例
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{//以下爲縱軸數據
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'New York',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
name: 'Berlin',
data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
});
</script>
</head>
<body>
<div id="container" ></div>
</body>
</html>
效果圖類似於如下:
轉自:http://blog.csdn.net/dengsilinming/article/details/7303468