全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2272|回复: 4
打印 上一主题 下一主题

用过canvas-gauges的jj进来帮忙看看呀。

[复制链接]
跳转到指定楼层
1#
发表于 2017-12-10 08:31:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
200金钱
这玩意到底带不带自动刷新重绘呀。。。

gauge.value = 12;代表图表显示的数值。这里可以用php获取,问题在于如何让这个定时刷新呀。

看着貌似是用gauge.update();,但百度谷歌官网愣是没找到是怎么用的、。

https://github.com/Mikhus/canvas-gauges


  1. <!doctype html>
  2. <html>
  3. <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.     <title>图表测试</title>
  6.     <link rel="stylesheet" href="../fonts/fonts.css">
  7.     <script src="../gauge.min.js"></script>
  8. </head>
  9. <body style="background: #fff">

  10. <canvas id="canvas-id"></canvas>

  11. <script>
  12.     var gauge = new RadialGauge({
  13.         renderTo: 'canvas-id',
  14.         width: 300,
  15.         height: 300,
  16.         units: "",
  17.         //title: "",

  18.         startAngle: 90,
  19.         ticksAngle: 180,
  20.         colorPlate: "#ffffff",
  21.         //colorPlateEnd: "#ffffff",
  22.         colorUnits: "#3CA7DB",
  23.         colorNumbers: "#534638",
  24.         colorNeedle: "#8E7860",
  25.         colorNeedleEnd: "#8E7860",
  26.         colorNeedleCircleOuter: "#8E7860",
  27.         colorNeedleCircleOuterEnd: "#8E7860",

  28.         colorNeedleShadowUp: "#8E7860",
  29.         colorNeedleShadowDown: "#8E7860",

  30.         colorMajorTicks: ["#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB"],
  31.         colorMinorTicks: "#EBEBEB",

  32.         minValue: 10,
  33.         maxValue: 35,
  34.         majorTicks: ["10","15","20","25","30","35"],
  35.         minorTicks: "2",
  36.         strokeTicks: true,
  37.         highlights: [
  38.             {
  39.                 "from": 10,
  40.                 "to": 17.99,
  41.                 "color": "#B1B9CB"
  42.             },
  43.             {
  44.                 "from": 18,
  45.                 "to": 28.99,
  46.                 "color": "#8FB9BD"
  47.             },
  48.             {
  49.                 "from": 29,
  50.                 "to": 35,
  51.                 "color": "#FF9488"
  52.             }
  53.         ],
  54.         //
  55.         highlightsWidth: 25,
  56.         numbersMargin: 12,
  57.         //
  58.         //barWidth: 20,
  59.         //barStrokeWidth: 0,
  60.         //barProgress: 1,
  61.         //barShadow: 0,
  62.         //
  63.         animation: true,
  64.         //animationDuration: 500,
  65.         animationRule: "linear",
  66.         animatedValue: true,
  67.         //animateOnInit: true,

  68.         borders: false,
  69.         valueBox: false,

  70.         needleType: "arrow",
  71.         needleEnd: 65,
  72.         needleWidth: 4,
  73.         needleCircleSize: 10,
  74.         needleCircleInner: false,
  75.         needleCircleOuter: true,
  76.         needleShadow: false,

  77.         borderShadowWidth: 0

  78.     }).draw();


  79.     gauge.value = 12;
  80.     gauge.update();
  81. </script>
  82. </body>
  83. </html>
复制代码

最佳答案

查看完整内容

更新不用update , 设置 gauge.value 后就可以了。
来自 2#
发表于 2017-12-10 08:31:26 | 只看该作者
更新不用update , 设置 gauge.value 后就可以了。
  1. var tick = 3000;
  2.     function update(){
  3.       var v = Math.floor(10 + Math.random() * 25 );
  4.       gauge.value = v;
  5.       setTimeout(update , tick);

  6.       //异步更新
  7.       /*
  8.       $.ajax('update_api' , function(resp){
  9.         gauge.value = resp;
  10.         setTimeout(update , tick);
  11.       });
  12.       */

  13.     }

  14.     update();
复制代码
3#
 楼主| 发表于 2017-12-10 09:38:23 | 只看该作者
  感觉loc现在一眼望去怎么全是看不懂的内容。。。。。。就如同现在的a5.。。。
4#
发表于 2017-12-10 09:39:35 | 只看该作者
zzr 发表于 2017-12-10 09:38
感觉loc现在一眼望去怎么全是看不懂的内容。。。。。。就如同现在的a5.。。。 ...

我跟你感觉一样的,而且你发的我也看不懂
5#
 楼主| 发表于 2017-12-10 15:27:02 | 只看该作者
wuting0122 发表于 2017-12-10 10:21
更新不用update , 设置 gauge.value 后就可以了。

厉害了,常年不更新的博客。。。
https://reruin.net/?p=23

确实直接设置就能用。。。。。不过原来直接以下操作就可以了。。现在貌似直接加入php不行了。。。
  1. gauge.value = <?php  
  2. $ch = curl_init();  
  3. $timeout = 5;  
  4. curl_setopt ($ch, CURLOPT_URL, 'http://www.domain.com/');  
  5. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);  
  6. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);  
  7. $file_contents = curl_exec($ch);  
  8. curl_close($ch);  
  9. echo $file_contents;  
  10. ?>
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-6-10 08:43 , Processed in 0.060890 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表