@@ -24,6 +24,7 @@ Chart.register(...registerables);
2424 * @param {Boolean } showCrosshair
2525 * @param {CallableFunction|null } tooltipHandler
2626 * @param {Boolean } hasDateTimeLabels
27+ * @param {String|null } dateUnitOverride
2728 * @return {Object }
2829 */
2930const CustomChart = (
@@ -39,7 +40,8 @@ const CustomChart = (
3940 xPadding = 10 ,
4041 showCrosshair = false ,
4142 tooltipHandler = null ,
42- hasDateTimeLabels = false
43+ hasDateTimeLabels = false ,
44+ dateUnitOverride = null
4345) => {
4446 const themeMode = ( ) => {
4547 if ( theme . mode === "auto" ) {
@@ -318,7 +320,9 @@ const CustomChart = (
318320 if ( hasDateTimeLabels ) {
319321 options . scales . xAxes . type = "time" ;
320322 options . scales . xAxes . ticks . maxRotation = 0 ;
321- options . scales . xAxes . ticks . autoSkipPadding = 10 ;
323+ options . scales . xAxes . ticks . autoSkipPadding = 20 ;
324+ options . scales . yAxes . ticks . autoSkipPadding = 15 ;
325+
322326 options . scales . xAxes . time = {
323327 displayFormats : {
324328 hour : "HH:00" ,
@@ -327,6 +331,10 @@ const CustomChart = (
327331 year : "yyyy" ,
328332 } ,
329333 } ;
334+
335+ if ( dateUnitOverride ) {
336+ options . scales . xAxes . time . unit = dateUnitOverride ;
337+ }
330338 }
331339
332340 this . chart = new Chart ( this . getCanvasContext ( ) , { data, options } ) ;
0 commit comments