在2.2版本中,针头工作正常工作,而在Android 4.2版本中我在仿真器/手机中执行时看到双针,除了浏览器。我无法弄清楚这个问题。
<!DOCTYPE html >
<html>
<head>
<link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
<script src="core.js" ></script>
<script src="dynamic.js" ></script>
<script src="effects.js" ></script>
<script src="meter.js" ></script>
<!--[if lt IE 9]><script src="../excanvas/excanvas.js"></script><![endif]-->
<meta name="description" content="A Meter chart that has been customised to appear circular. It use Meter chart customisations as well as CSS effects" />
<meta name="robots" content="noindex,nofollow" />
</head>
<body>
<!-- <div style="width: 450px; height: 450px; background-color: white; border-radius: 250px; text-align: center; font-family: Arial; box-shadow: 0px 0px 25px gray; border: 10 px solid #ddd"> -->
<canvas id="cvs" width="300" height="300" style="background: url('background.jpg') no-repeat scroll 0 0 transparent; ">
[No canvas support]
</canvas>
<script>
meter = new RGraph.Meter('cvs', 0,100,65)
.Set('border', false)
.Set('tickmarks.small.num', 0)
.Set('tickmarks.big.num', 0)
.Set('angles.start', HALFPI + (HALFPI / 1.0))
.Set('angles.end', TWOPI +HALFPI - (HALFPI / 1.0))
.Set('segment.radius.start', 0)
.Set('text.size', 16)
.Set('colors.ranges', [])
.Set('text.color', 'transparent')
.Set('needle.radius', 110)
.Set('background.color', 'transparent')
.Set('gutter.bottom', 135)
.Draw();
meter.canvas.onclick_rgraph = function (e)
{
var obj = e.target.__object__;
var value = obj.getValue(e);
var str = (value<20.0) ? "1" :
(value<40.0) ? "2" :
(value<60.0) ? "3": (value<80.0)?"4":"5";
//document.getElementById('result').value = str;
if (typeof(value) == 'number') {
obj.value = value;
RGraph.Effects.Meter.Grow(obj);
}
}
</script>
<!-- </div> -->
</body>
</html>
在2.2版本中,针头工作正常工作,而在Android 4.2版本中我在仿真器/手机中执行时看到双针,除了浏览器。我无法弄清楚这个问题。
答案 0 :(得分:0)
您需要在加载前清除画布。 请尝试此代码。
<script>
meter = new RGraph.Meter('cvs', 0,100,65)
.Set('border', false)
.Set('tickmarks.small.num', 0)
.Set('tickmarks.big.num', 0)
.Set('angles.start', HALFPI + (HALFPI / 1.0))
.Set('angles.end', TWOPI +HALFPI - (HALFPI / 1.0))
.Set('segment.radius.start', 0)
.Set('text.size', 16)
.Set('colors.ranges', [])
.Set('text.color', 'transparent')
.Set('needle.radius', 110)
.Set('background.color', 'transparent')
.Set('gutter.bottom', 135)
.Draw();
meter.onbeforedraw = function (obj)
{
RGraph.clear(obj.canvas, 'white');
}
meter.canvas.onclick_rgraph = function (e)
{
var obj = e.target.__object__;
var value = obj.getValue(e);
var str = (value<20.0) ? "1" :
(value<40.0) ? "2" :
(value<60.0) ? "3": (value<80.0)?"4":"5";
//document.getElementById('result').value = str;
if (typeof(value) == 'number') {
obj.value = value;
RGraph.Effects.Meter.Grow(obj);
}
}
</script>