栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

js实现圆盘记速表

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

js实现圆盘记速表

如何利用AmCharts制作的汽车速度计速表,通过设置不同的速度(数字)来动态改变计速表的指针

效果图:

javascript代码:

var chart = AmCharts.makeChart("chartdiv", {
 "type": "gauge",
 "theme": "none",
 "axes": [{
   "axisThickness": 1,
   "axisAlpha": 0.2,
   "tickAlpha": 0.2,
   "valueInterval": 20,
   "bands": [{
     "color": "#84b761",
     "endValue": 90,
     "startValue": 0
   }, {
     "color": "#fdd400",
     "endValue": 130,
     "startValue": 90
   }, {
     "color": "#cc4748",
     "endValue": 220,
     "innerRadius": "95%",
     "startValue": 130
   }],
   "bottomText": "0 km/h",
   "bottomTextYOffset": -20,
   "endValue": 320
 }],
 "arrows": [{}]
      });
      window.onload=function(){
 chart.arrows[0].setValue(80);
 chart.axes[0].setBottomText(80  " km/h");
      }
      document.getElementById("btnSure").onclick=function(){
 if(document.getElementById("txtNum").value>320){
   alert("超出最大值");
   return;
 }
 if(document.getElementById("txtNum").value<0){
   alert("不能低于0");
   return;
 }
 chart.arrows[0].setValue(document.getElementById("txtNum").value);
 chart.axes[0].setBottomText(document.getElementById("txtNum").value  " km/h");
      }

引入JS:


 

以上就是本文的全部内容,希望大家喜欢。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/101377.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号