@@ -9,6 +9,10 @@ defaults._set('scale', {
99 display : true ,
1010 position : 'left' ,
1111 offset : false ,
12+ borderColor : 'rgba(0, 0, 0, 0.4)' ,
13+ borderWidth : 0 ,
14+ borderDash : [ ] ,
15+ borderDashOffset : 0.0 ,
1216
1317 // grid line settings
1418 gridLines : {
@@ -809,14 +813,15 @@ module.exports = function(Chart) {
809813 } ) ;
810814 } ) ;
811815
812- // When offsetGridLines is enabled, there is one less tick mark than
813- // there are tick labels , thefore it has to be manually added
816+ // When offsetGridLines is enabled, there should be one more tick mark than there
817+ // are ticks in scale.ticks array , thefore the missing gridLine has to be manually added
814818 if ( gridLines . offsetGridLines ) {
819+ var aliasPixel = helpers . aliasPixel ( gridLines . lineWidth ) ;
815820 itemsToDraw . push ( {
816- tx1 : ! isHorizontal ? xTickStart : chartArea . right ,
817- ty1 : ! isHorizontal ? chartArea . bottom : yTickStart ,
818- tx2 : ! isHorizontal ? xTickEnd : chartArea . right ,
819- ty2 : ! isHorizontal ? chartArea . bottom : yTickEnd ,
821+ tx1 : ! isHorizontal ? xTickStart : chartArea . right + aliasPixel ,
822+ ty1 : ! isHorizontal ? chartArea . bottom + aliasPixel : yTickStart ,
823+ tx2 : ! isHorizontal ? xTickEnd : chartArea . right + aliasPixel ,
824+ ty2 : ! isHorizontal ? chartArea . bottom + aliasPixel : yTickEnd ,
820825 tmWidth : gridLines . lineWidth ,
821826 tmColor : gridLines . color ,
822827 tmBorderDash : gridLines . borderDash ,
@@ -902,6 +907,40 @@ module.exports = function(Chart) {
902907 context . fillText ( scaleLabel . labelString , 0 , 0 ) ;
903908 context . restore ( ) ;
904909 }
910+
911+ // gridLines.drawBorder is deprecated
912+ if ( gridLines . drawBorder && options . borderColor !== null && options . borderWidth !== 0 && options . borderWidth !== null ) {
913+ // Draw the scale border
914+ context . lineWidth = options . borderWidth ;
915+ context . strokeStyle = options . borderColor ;
916+ if ( context . setLineDash ) {
917+ context . setLineDash ( helpers . getValueOrDefault ( options . borderDash , globalDefaults . borderDash ) ) ;
918+ context . lineDashOffset = helpers . getValueOrDefault ( options . borderDashOffset , globalDefaults . borderDashOffset ) ;
919+ }
920+
921+ var x1 = Math . round ( me . left ) ;
922+ var x2 = Math . round ( me . right ) ;
923+ var y1 = Math . round ( me . top ) ;
924+ var y2 = Math . round ( me . bottom ) ;
925+
926+ if ( isHorizontal ) {
927+ y1 = y2 = options . position === 'top' ? me . bottom : me . top ;
928+ y1 += helpers . aliasPixel ( context . lineWidth ) ;
929+ y2 += helpers . aliasPixel ( context . lineWidth ) ;
930+ } else {
931+ x1 = x2 = options . position === 'left' ? me . right : me . left ;
932+ x1 += helpers . aliasPixel ( context . lineWidth ) ;
933+ x2 += helpers . aliasPixel ( context . lineWidth ) ;
934+ }
935+
936+ context . beginPath ( ) ;
937+
938+ context . moveTo ( x1 , y1 ) ;
939+ context . lineTo ( x2 , y2 ) ;
940+
941+ context . stroke ( ) ;
942+ context . restore ( ) ;
943+ }
905944 }
906945 } ) ;
907946} ;
0 commit comments