當前位置:編程學習大全網 - 網絡軟體 - html怎麽用js特效做折線圖

html怎麽用js特效做折線圖

使用原生js自己寫或js庫(框架)都是可以的,由於目前HTML5並不是所有的瀏覽器都完美支持,使用兼容性比較好的js庫是個不錯的選擇。

例如Highcharts圖標庫就可以實現各類曲線圖、折線圖、區域圖、3D圖、柱狀圖等等。具體使用參考:/demo/index.php。

Highcharts中做折線圖的demo代碼可以作為參考:

<html?lang="en">

<head>

<script?type="text/javascript"?src="/jquery/jquery-1.8.3.min.js"></script>

<script?type="text/javascript"?src="/highcharts/highcharts.js"></script>

<script?type="text/javascript"?src="/highcharts/exporting.js"></script>

<script>

$(function?()?{

$('#container').highcharts({

chart:?{

type:?'line'

},

title:?{

text:?'Monthly?Average?Temperature'

},

subtitle:?{

text:?'Source:?WorldClimate.com'

},

xAxis:?{

categories:?['Jan',?'Feb',?'Mar',?'Apr',?'May',?'Jun',?'Jul',?'Aug',?'Sep',?'Oct',?'Nov',?'Dec']

},

yAxis:?{

title:?{

text:?'Temperature?(°C)'

}

},

tooltip:?{

enabled:?false,

formatter:?function()?{

return?'<b>'+?this.series.name?+'</b><br/>'+this.x?+':?'+?this.y?+'°C';

}

},

plotOptions:?{

line:?{

dataLabels:?{

enabled:?true

},

enableMouseTracking:?false

}

},

series:?[{

name:?'Tokyo',

data:?[7.0,?6.9,?9.5,?14.5,?18.4,?21.5,?25.2,?26.5,?23.3,?18.3,?13.9,?9.6]

},?{

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"?style="min-width:700px;height:400px"></div>

</body>

</html>

  • 上一篇:《奔跑吧兄弟》running man來的那期是哪壹期?
  • 下一篇:矢量圖是什麽
  • copyright 2024編程學習大全網