|
1390 | 1390 | }
|
1391 | 1391 | };
|
1392 | 1392 |
|
1393 |
| - JustGage.prototype.drawTargetLine = function() { |
1394 |
| - const obj = this; |
1395 |
| - |
1396 |
| - if (obj.config.targetLine === null) { |
1397 |
| - return; |
1398 |
| - } |
1399 |
| - |
1400 |
| - let path; |
1401 |
| - const w = obj.params.widgetW; |
1402 |
| - const h = obj.params.widgetH; |
1403 |
| - const dx = obj.params.dx; |
1404 |
| - const dy = obj.params.dy; |
1405 |
| - const gws = obj.config.gaugeWidthScale; |
1406 |
| - const donut = obj.config.donut; |
1407 |
| - |
1408 |
| - let alpha = (1 - (obj.config.targetLine - obj.config.min) / (obj.config.max - obj.config.min)) * Math.PI; |
1409 |
| - let Ro = w / 2 - w / 10; |
1410 |
| - let Ri = Ro - w / 6.666666666666667 * gws; |
1411 |
| - |
1412 |
| - let Cx, Cy, Xo, Yo, Xi, Yi; |
1413 |
| - |
1414 |
| - if (donut) { |
1415 |
| - Ro = w / 2 - w / 30; |
1416 |
| - Ri = Ro - w / 6.666666666666667 * gws; |
1417 |
| - |
1418 |
| - Cx = w / 2 + dx; |
1419 |
| - Cy = h / 2 + dy; |
1420 |
| - |
1421 |
| - Xo = Cx + Ro * Math.cos(alpha); |
1422 |
| - Yo = Cy - Ro * Math.sin(alpha); |
1423 |
| - Xi = Cx + Ri * Math.cos(alpha); |
1424 |
| - Yi = Cy - Ri * Math.sin(alpha); |
1425 |
| - |
1426 |
| - path = "M" + Xi + "," + Yi + " L" + Xo + "," + Yo; |
1427 |
| - } else { |
1428 |
| - Cx = w / 2 + dx; |
1429 |
| - Cy = h / 1.25 + dy; |
1430 |
| - |
1431 |
| - Xo = Cx + Ro * Math.cos(alpha); |
1432 |
| - Yo = Cy - Ro * Math.sin(alpha); |
1433 |
| - Xi = Cx + Ri * Math.cos(alpha); |
1434 |
| - Yi = Cy - Ri * Math.sin(alpha); |
1435 |
| - |
1436 |
| - path = "M" + Xi + "," + Yi + " L" + Xo + "," + Yo; |
1437 |
| - } |
1438 |
| - |
1439 |
| - obj.targetLine = obj.canvas.path(path).attr({ |
1440 |
| - "stroke": obj.config.targetLineColor, |
1441 |
| - "stroke-width": obj.config.targetLineWidth |
1442 |
| - }); |
1443 |
| - |
1444 |
| - if (donut) { |
1445 |
| - obj.targetLine.transform("r" + obj.config.donutStartAngle + "," + (w / 2 + dx) + "," + (h / 2 + dy)); |
1446 |
| - } |
1447 |
| - }; |
| 1393 | + JustGage.prototype.drawTargetLine = function () { |
| 1394 | + const obj = this; |
| 1395 | + |
| 1396 | + if (obj.config.targetLine === null) { |
| 1397 | + return; |
| 1398 | + } |
| 1399 | + |
| 1400 | + let path; |
| 1401 | + const w = obj.params.widgetW; |
| 1402 | + const h = obj.params.widgetH; |
| 1403 | + const dx = obj.params.dx; |
| 1404 | + const dy = obj.params.dy; |
| 1405 | + const gws = obj.config.gaugeWidthScale; |
| 1406 | + const donut = obj.config.donut; |
| 1407 | + |
| 1408 | + const alpha = |
| 1409 | + (1 - |
| 1410 | + (obj.config.targetLine - obj.config.min) / |
| 1411 | + (obj.config.max - obj.config.min)) * |
| 1412 | + Math.PI; |
| 1413 | + let Ro = w / 2 - w / 10; |
| 1414 | + let Ri = Ro - (w / 6.666666666666667) * gws; |
| 1415 | + |
| 1416 | + let Cx, Cy, Xo, Yo, Xi, Yi; |
| 1417 | + |
| 1418 | + if (donut) { |
| 1419 | + Ro = w / 2 - w / 30; |
| 1420 | + Ri = Ro - (w / 6.666666666666667) * gws; |
| 1421 | + |
| 1422 | + Cx = w / 2 + dx; |
| 1423 | + Cy = h / 2 + dy; |
| 1424 | + |
| 1425 | + Xo = Cx + Ro * Math.cos(alpha); |
| 1426 | + Yo = Cy - Ro * Math.sin(alpha); |
| 1427 | + Xi = Cx + Ri * Math.cos(alpha); |
| 1428 | + Yi = Cy - Ri * Math.sin(alpha); |
| 1429 | + |
| 1430 | + path = "M" + Xi + "," + Yi + " L" + Xo + "," + Yo; |
| 1431 | + } else { |
| 1432 | + Cx = w / 2 + dx; |
| 1433 | + Cy = h / 1.25 + dy; |
| 1434 | + |
| 1435 | + Xo = Cx + Ro * Math.cos(alpha); |
| 1436 | + Yo = Cy - Ro * Math.sin(alpha); |
| 1437 | + Xi = Cx + Ri * Math.cos(alpha); |
| 1438 | + Yi = Cy - Ri * Math.sin(alpha); |
| 1439 | + |
| 1440 | + path = "M" + Xi + "," + Yi + " L" + Xo + "," + Yo; |
| 1441 | + } |
| 1442 | + |
| 1443 | + obj.targetLine = obj.canvas.path(path).attr({ |
| 1444 | + stroke: obj.config.targetLineColor, |
| 1445 | + "stroke-width": obj.config.targetLineWidth, |
| 1446 | + }); |
| 1447 | + |
| 1448 | + if (donut) { |
| 1449 | + obj.targetLine.transform( |
| 1450 | + "r" + |
| 1451 | + obj.config.donutStartAngle + |
| 1452 | + "," + |
| 1453 | + (w / 2 + dx) + |
| 1454 | + "," + |
| 1455 | + (h / 2 + dy) |
| 1456 | + ); |
| 1457 | + } |
| 1458 | + }; |
1448 | 1459 |
|
1449 | 1460 | //
|
1450 | 1461 | // tiny helper function to lookup value of a key from two hash tables
|
|
0 commit comments