你能帮我弄清楚如何计算下面的js脚本来显示提醒总量(而不是百分比)吗?
例如,如果总(给定) 90 且with datelist ([date]) as
(
select dateadd(dd, -15, cast(getdate() as date)) as [date] -- 15 days back
union all
select dateadd(dd, 1, [date]) from datelist where dateadd(dd, 1, [date]) <= getdate()
)
select 'cricket' as activity,
d.[date],
coalesce(SUM(datediff(second, u.starttime, u.endtime)/60.0), 0)
as TimePerDay
from datelist d
left join
(
select [starttime], [endtime], cast(starttime as date) as [date]
from [users]
where activity='cricket' and email='abc'
) u
on d.[date] = u.[date]
group by d.[date]
option (maxrecursion 400)
90 ,则将绘制整个弧,如果当前金额为{{1}必须绘制弧的一半。
current
&#13;
45
&#13;
答案 0 :(得分:1)
您只需要更改var percentage
即可。现在它可以正常运行,根据您的需要设置current
和given
。
var can = document.getElementById('canvas1');
var ctx = can.getContext("2d");
var context = can.getContext('2d');
var given = SET YOUR GIVEN VALUE;
var current = SET YOUR CURRENT VALUE;
var percentage = current/given;
var degrees = percentage * 360;
var radians = degrees * (Math.PI / 180);
var x = 50;
var y = 50;
var r = 30;
var s = 1.5 * Math.PI;
ctx.beginPath();
ctx.arc(50,50,30,0,2*Math.PI);
ctx.fillStyle = "#FF0000";
ctx.fill();
ctx.stroke();
context.beginPath();
context.lineWidth = 10;
context.arc(x, y, r, s, radians+s, false);
context.stroke();
<canvas id="canvas1" width="100" height="100"></canvas>