import Canvas from '../references/canvas.js'; class BackgroundCanvas extends Canvas { Options = null; Debug = false; StartDate = new Date(); // Duration = 30; // StartOfWeek = 1; // RowCount = 8; constructor(el) { super(el); } get ClientRectangle() { const a = this; return { X: a.Options.Padding.Left, Y: a.Options.Padding.Top, W: (a.Width - (a.Options.Padding.Left + a.Options.Padding.Right)), H: (a.Height - (a.Options.Padding.Top + a.Options.Padding.Bottom)) }; } // get HeaderRow1Rectangle() { // return { // X: 0, // Y: 0, // W: this.Width, // H: (this.Options.HeaderRow.Height[0] - this.Options.BorderWidth) // }; // } // get HeaderRow2Rectangle() { // const a = this; // return { // X: 0, // Y: this.Options.HeaderRow.Height[0], // W: this.Width, // H: (this.Options.HeaderRow.Height[1] - this.Options.BorderWidth) // }; // } // get HeaderHeight() { // const a = this; // return a.Options.HeaderRow.Height[0] + a.Options.HeaderRow.Height[1]; // } Load(startDate) { const a = this; a.StartDate = new Date(startDate); // a.Duration = duration; // a.StartOfWeek = startOfWeek; // 1 = Monday // a.RowCount = rowCount; } Invalidate() { const a = this; if (a.Options == null) { return; } if (a.Debug) { a.DrawRectangle(a.ClientRectangle, "red", {}); } const y = Math.floor(a.ClientRectangle.Y + Math.half(a.ClientRectangle.H) + Math.half(a.Options.AxisLine.Width)); a.DrawHorizontalLine(a.ClientRectangle.X, y, a.ClientRectangle.W, a.Options.AxisLine.Colour); const days = Math.floor(a.ClientRectangle.W / a.Options.XAxisLine.Spacing); for(var i=0; i<=days; i++) { const x = (a.ClientRectangle.X + (i * a.Options.XAxisLine.Spacing)); if ((i % a.Options.XAxisLine.SegmentCount) == 0) { a.DrawVerticalLine(x, y, a.Options.XAxisLine.DayLineLength, a.Options.XAxisLine.DayLineColour, { LineWidth: a.Options.XAxisLine.DayLineWidth, Precise: true }); } else { a.DrawVerticalLine(x, y, a.Options.XAxisLine.HourLineLength, a.Options.XAxisLine.HourLineColour, { LineWidth: a.Options.XAxisLine.HourLineWidth, Precise: true }); } } // if (a.StartDate == null) { // return; // } // a.#drawChartHeader(); // a.#drawColumnLayout(); // a.#drawRowLayout(); } // #drawChartHeader() { // const a = this; // const displayDays = a.Duration + 2; // if (a.Debug) { // a.DrawRectangle(a.HeaderRow1Rectangle, "red", {}); // a.DrawRectangle(a.HeaderRow2Rectangle, "orange", {}); // } // let startDate = new Date(a.StartDate); // startDate.addDays(-1); // // Draw horizontal line under months // a.#drawHorizontalLine(a.Options.HeaderRow.Height[0]); // // Draw vertical lines for dates // for (let i=1; i