这玩意到底带不带自动刷新重绘呀。。。
gauge.value = 12;代表图表显示的数值。这里可以用php获取,问题在于如何让这个定时刷新呀。
看着貌似是用gauge.update();,但百度谷歌官网愣是没找到是怎么用的、。
https://github.com/Mikhus/canvas-gauges
- <!doctype html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>图表测试</title>
- <link rel="stylesheet" href="../fonts/fonts.css">
- <script src="../gauge.min.js"></script>
- </head>
- <body style="background: #fff">
- <canvas id="canvas-id"></canvas>
- <script>
- var gauge = new RadialGauge({
- renderTo: 'canvas-id',
- width: 300,
- height: 300,
- units: "",
- //title: "",
- startAngle: 90,
- ticksAngle: 180,
- colorPlate: "#ffffff",
- //colorPlateEnd: "#ffffff",
- colorUnits: "#3CA7DB",
- colorNumbers: "#534638",
- colorNeedle: "#8E7860",
- colorNeedleEnd: "#8E7860",
- colorNeedleCircleOuter: "#8E7860",
- colorNeedleCircleOuterEnd: "#8E7860",
- colorNeedleShadowUp: "#8E7860",
- colorNeedleShadowDown: "#8E7860",
- colorMajorTicks: ["#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB", "#EBEBEB"],
- colorMinorTicks: "#EBEBEB",
- minValue: 10,
- maxValue: 35,
- majorTicks: ["10","15","20","25","30","35"],
- minorTicks: "2",
- strokeTicks: true,
- highlights: [
- {
- "from": 10,
- "to": 17.99,
- "color": "#B1B9CB"
- },
- {
- "from": 18,
- "to": 28.99,
- "color": "#8FB9BD"
- },
- {
- "from": 29,
- "to": 35,
- "color": "#FF9488"
- }
- ],
- //
- highlightsWidth: 25,
- numbersMargin: 12,
- //
- //barWidth: 20,
- //barStrokeWidth: 0,
- //barProgress: 1,
- //barShadow: 0,
- //
- animation: true,
- //animationDuration: 500,
- animationRule: "linear",
- animatedValue: true,
- //animateOnInit: true,
- borders: false,
- valueBox: false,
- needleType: "arrow",
- needleEnd: 65,
- needleWidth: 4,
- needleCircleSize: 10,
- needleCircleInner: false,
- needleCircleOuter: true,
- needleShadow: false,
- borderShadowWidth: 0
- }).draw();
- gauge.value = 12;
- gauge.update();
- </script>
- </body>
- </html>
复制代码 |