@@ -306,11 +306,26 @@ export default class Dimensions {
306
306
307
307
if (
308
308
( w . config . xaxis . type === 'category' && w . globals . isBarHorizontal ) ||
309
- w . config . xaxis . type === 'numeric'
309
+ w . config . xaxis . type === 'numeric' ||
310
+ w . config . xaxis . type === 'datetime'
310
311
) {
311
312
const rightPad = ( labels ) => {
312
- if ( w . config . grid . padding . right < labels . width ) {
313
- this . xPadRight = labels . width / 2 + 1
313
+ if ( this . timescaleLabels ) {
314
+ // for timeline labels, we take the last label and check if it exceeds gridWidth
315
+ const lastTimescaleLabel = this . timescaleLabels [
316
+ this . timescaleLabels . length - 1
317
+ ]
318
+ const labelPosition = lastTimescaleLabel . position + labels . width
319
+ if ( labelPosition > w . globals . gridWidth ) {
320
+ w . globals . skipLastTimelinelabel = true
321
+ } else {
322
+ // we have to make it false again in case of zooming/panning
323
+ w . globals . skipLastTimelinelabel = false
324
+ }
325
+ } else if ( w . config . xaxis . type !== 'datetime' ) {
326
+ if ( w . config . grid . padding . right < labels . width ) {
327
+ this . xPadRight = labels . width / 2 + 1
328
+ }
314
329
}
315
330
}
316
331
@@ -320,20 +335,19 @@ export default class Dimensions {
320
335
}
321
336
}
322
337
323
- const lineArea =
324
- w . config . chart . type === 'line' || w . config . chart . type === 'area'
338
+ const isXNumeric = w . globals . isXNumeric
325
339
326
340
w . config . yaxis . forEach ( ( yaxe , i ) => {
327
341
let shouldPad =
328
342
! yaxe . show ||
329
343
yaxe . floating ||
330
344
w . globals . collapsedSeriesIndices . indexOf ( i ) !== - 1 ||
331
- lineArea ||
345
+ isXNumeric ||
332
346
( yaxe . opposite && w . globals . isBarHorizontal )
333
347
334
348
if ( shouldPad ) {
335
349
if (
336
- ( lineArea &&
350
+ ( isXNumeric &&
337
351
w . globals . isMultipleYAxis &&
338
352
w . globals . collapsedSeriesIndices . indexOf ( i ) !== - 1 ) ||
339
353
( w . globals . isBarHorizontal && yaxe . opposite )
@@ -345,7 +359,7 @@ export default class Dimensions {
345
359
( ! w . globals . isBarHorizontal &&
346
360
yaxe . opposite &&
347
361
w . globals . collapsedSeriesIndices . indexOf ( i ) !== - 1 ) ||
348
- ( lineArea && ! w . globals . isMultipleYAxis )
362
+ ( isXNumeric && ! w . globals . isMultipleYAxis )
349
363
) {
350
364
rightPad ( xaxisLabelCoords )
351
365
}
@@ -438,12 +452,12 @@ export default class Dimensions {
438
452
let w = this . w
439
453
let rect
440
454
441
- let timescaleLabels = w . globals . timelineLabels . slice ( )
455
+ this . timescaleLabels = w . globals . timelineLabels . slice ( )
442
456
if ( w . globals . isBarHorizontal && w . config . xaxis . type === 'datetime' ) {
443
- timescaleLabels = w . globals . invertedTimelineLabels . slice ( )
457
+ this . timescaleLabels = w . globals . invertedTimelineLabels . slice ( )
444
458
}
445
459
446
- let labels = timescaleLabels . map ( ( label ) => {
460
+ let labels = this . timescaleLabels . map ( ( label ) => {
447
461
return label . value
448
462
} )
449
463
@@ -519,6 +533,7 @@ export default class Dimensions {
519
533
val = xFormat . xLabelFormat ( xlbFormatter , val )
520
534
521
535
let graphics = new Graphics ( this . ctx )
536
+
522
537
let xLabelrect = graphics . getTextRects (
523
538
val ,
524
539
w . config . xaxis . labels . style . fontSize
0 commit comments