diff --git a/lichartee.js b/lichartee.js index b9a7b45..e18b42d 100644 --- a/lichartee.js +++ b/lichartee.js @@ -711,18 +711,18 @@ class Axis * draw xaxis and yaxis to canvas * * @param ctx CanvasRenderingContext2D Context of canvas - * @param window 2darray Window where to draw the canvas - * @param view 2darray Window where to draw the canvas with - * the real value + * @param box 2darray Window where to draw the axis + * @param view 2darray Window where to draw the canvas with the + * real value */ - draw(ctx, window, view) + draw(ctx, box, view) { ctx.strokeStyle = 'black'; ctx.fillStyle = 'black'; let index = 0; - let start_pos = window[0][1]; + let start_pos = box[0][1]; let padding = ( - window[1][1] - window[0][1] - this.margin - this.text_height - this.size_tick + box[1][1] - box[0][1] - this.margin - this.text_height - this.size_tick ) / this.number_y_tick; let step = (view[1][1] - view[0][1]) / this.number_y_tick; let width = 2 * this.text_height; @@ -735,27 +735,27 @@ class Axis let text_position = current_y + this.text_height / 2 ctx.beginPath(); ctx.moveTo( - window[0][0] + this.margin + width, + box[0][0] + this.margin + width, current_y, ); ctx.lineTo( - window[0][0] + this.margin + this.size_tick + width, + box[0][0] + this.margin + this.size_tick + width, current_y, ); ctx.stroke(); ctx.fillText( text, - window[0][0] + this.margin, + box[0][0] + this.margin, text_position, ); current_y += padding; index += 1; } index = 0; - start_pos = window[0][0] + this.margin + this.size_tick + start_pos = box[0][0] + this.margin + this.size_tick + width; padding = ( - window[1][0] - this.margin - start_pos + box[1][0] - this.margin - start_pos ) / this.number_x_tick; step = (view[1][0] - view[0][0]) / this.number_x_tick; while (index <= this.number_x_tick) @@ -770,23 +770,23 @@ class Axis ctx.beginPath(); ctx.moveTo( current_x, - window[1][1] - this.margin - this.text_height, + box[1][1] - this.margin - this.text_height, ); ctx.lineTo( current_x, - window[1][1] - this.margin - this.size_tick - this.text_height, + box[1][1] - this.margin - this.size_tick - this.text_height, ); ctx.stroke(); ctx.fillText( text , text_position, - window[1][1] - this.margin, + box[1][1] - this.margin, ); index += 1; } return [ - [window[0][0] + this.margin + this.size_tick + width, window[0][1]], - [window[1][0] - this.margin , window[1][1] - this.text_height - this.margin - this.size_tick], + [box[0][0] + this.margin + this.size_tick + width, box[0][1]], + [box[1][0] - this.margin , box[1][1] - this.text_height - this.margin - this.size_tick], ]; } }