Skip to content

Commit

Permalink
fixes #2591; gridbands for timeline and datetime charts
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Aug 24, 2024
1 parent 0b35f7d commit 3b5d6c6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/modules/axes/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ class Grid {
const graphics = new Graphics(this.ctx)
const offX = w.globals.barPadForNumericAxis

if (type === 'column' && w.config.xaxis.type === 'datetime') return

const color = w.config.grid[type].colors[c]

let rect = graphics.drawRect(
Expand Down Expand Up @@ -522,13 +520,17 @@ class Grid {
w.config.grid.column.colors !== undefined &&
w.config.grid.column.colors.length > 0
) {
const xc =
let xc =
!w.globals.isBarHorizontal &&
w.config.xaxis.tickPlacement === 'on' &&
(w.config.xaxis.type === 'category' ||
w.config.xaxis.convertedCatToNumeric)
? xCount - 1
: xCount

if (w.globals.isXNumeric) {
xc = w.globals.xAxisScale.result.length - 1
}
let x1 = w.globals.padHorizontal
let y1 = 0
let x2 = w.globals.padHorizontal + w.globals.gridWidth / xc
Expand All @@ -537,6 +539,13 @@ class Grid {
if (c >= w.config.grid.column.colors.length) {
c = 0
}

if (w.config.xaxis.type === 'datetime') {
x1 = this.xaxisLabels[i].position
x2 =
(this.xaxisLabels[i + 1]?.position || w.globals.gridWidth) -
this.xaxisLabels[i].position
}
this._drawGridBandRect({
c,
x1,
Expand Down

0 comments on commit 3b5d6c6

Please sign in to comment.