-
Notifications
You must be signed in to change notification settings - Fork 0
/
yAxis.js
33 lines (29 loc) · 1.16 KB
/
yAxis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Get the y-axis canvas
const yAxisCanvas = document.getElementById('yAxisCanvas');
const yAxisCtx = yAxisCanvas.getContext('2d');
// Draw the y-axis line with an arrow
function drawYAxisArrow() {
const width = yAxisCanvas.width;
const height = yAxisCanvas.height;
const arrowSize = 20;
const padding = 0;
// Draw the y-axis line
yAxisCtx.beginPath();
yAxisCtx.moveTo(width / 2, height); // Start of the line (bottom at the x-axis)
yAxisCtx.lineTo(width / 2, padding + arrowSize); // End of the line before the arrow (top)
yAxisCtx.strokeStyle = '#000';
yAxisCtx.lineWidth = 2;
yAxisCtx.stroke();
// Draw the arrow pointing upwards
yAxisCtx.beginPath();
yAxisCtx.moveTo(width / 2 - arrowSize / 2, padding + arrowSize); // Left side of the arrowhead
yAxisCtx.lineTo(width / 2, padding); // Arrow tip
yAxisCtx.lineTo(width / 2 + arrowSize / 2, padding + arrowSize); // Right side of the arrowhead
yAxisCtx.strokeStyle = '#000';
yAxisCtx.lineWidth = 2;
yAxisCtx.stroke();
yAxisCtx.fillStyle = '#000';
yAxisCtx.fill(); // Fill the arrow
}
// Call the function to draw the y-axis arrow
drawYAxisArrow();