* @protected
(chartArea)
| 1466 | * @protected |
| 1467 | */ |
| 1468 | drawGrid(chartArea) { |
| 1469 | const grid = this.options.grid; |
| 1470 | const ctx = this.ctx; |
| 1471 | const items = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(chartArea)); |
| 1472 | let i, ilen; |
| 1473 | |
| 1474 | const drawLine = (p1, p2, style) => { |
| 1475 | if (!style.width || !style.color) { |
| 1476 | return; |
| 1477 | } |
| 1478 | ctx.save(); |
| 1479 | ctx.lineWidth = style.width; |
| 1480 | ctx.strokeStyle = style.color; |
| 1481 | ctx.setLineDash(style.borderDash || []); |
| 1482 | ctx.lineDashOffset = style.borderDashOffset; |
| 1483 | |
| 1484 | ctx.beginPath(); |
| 1485 | ctx.moveTo(p1.x, p1.y); |
| 1486 | ctx.lineTo(p2.x, p2.y); |
| 1487 | ctx.stroke(); |
| 1488 | ctx.restore(); |
| 1489 | }; |
| 1490 | |
| 1491 | if (grid.display) { |
| 1492 | for (i = 0, ilen = items.length; i < ilen; ++i) { |
| 1493 | const item = items[i]; |
| 1494 | |
| 1495 | if (grid.drawOnChartArea) { |
| 1496 | drawLine( |
| 1497 | {x: item.x1, y: item.y1}, |
| 1498 | {x: item.x2, y: item.y2}, |
| 1499 | item |
| 1500 | ); |
| 1501 | } |
| 1502 | |
| 1503 | if (grid.drawTicks) { |
| 1504 | drawLine( |
| 1505 | {x: item.tx1, y: item.ty1}, |
| 1506 | {x: item.tx2, y: item.ty2}, |
| 1507 | { |
| 1508 | color: item.tickColor, |
| 1509 | width: item.tickWidth, |
| 1510 | borderDash: item.tickBorderDash, |
| 1511 | borderDashOffset: item.tickBorderDashOffset |
| 1512 | } |
| 1513 | ); |
| 1514 | } |
| 1515 | } |
| 1516 | } |
| 1517 | } |
| 1518 | |
| 1519 | /** |
| 1520 | * @protected |
no test coverage detected