@@ -126,7 +126,7 @@ describe('Time scale tests', function() {
126126 var ticks = getLabels ( scale ) ;
127127
128128 // `bounds === 'data'`: first and last ticks removed since outside the data range
129- expect ( ticks . length ) . toEqual ( 217 ) ;
129+ expect ( ticks . length ) . toEqual ( 44 ) ;
130130 } ) ;
131131
132132 it ( 'should accept labels as date objects' , function ( ) {
@@ -137,7 +137,7 @@ describe('Time scale tests', function() {
137137 var ticks = getLabels ( scale ) ;
138138
139139 // `bounds === 'data'`: first and last ticks removed since outside the data range
140- expect ( ticks . length ) . toEqual ( 217 ) ;
140+ expect ( ticks . length ) . toEqual ( 44 ) ;
141141 } ) ;
142142
143143 it ( 'should accept data as xy points' , function ( ) {
@@ -185,7 +185,7 @@ describe('Time scale tests', function() {
185185 var ticks = getLabels ( xScale ) ;
186186
187187 // `bounds === 'data'`: first and last ticks removed since outside the data range
188- expect ( ticks . length ) . toEqual ( 217 ) ;
188+ expect ( ticks . length ) . toEqual ( 37 ) ;
189189 } ) ;
190190
191191 it ( 'should accept data as ty points' , function ( ) {
@@ -233,7 +233,7 @@ describe('Time scale tests', function() {
233233 var ticks = getLabels ( tScale ) ;
234234
235235 // `bounds === 'data'`: first and last ticks removed since outside the data range
236- expect ( ticks . length ) . toEqual ( 217 ) ;
236+ expect ( ticks . length ) . toEqual ( 37 ) ;
237237 } ) ;
238238 } ) ;
239239
@@ -704,7 +704,7 @@ describe('Time scale tests', function() {
704704 it ( 'should get the correct labels for ticks' , function ( ) {
705705 var labels = getLabels ( this . scale ) ;
706706
707- expect ( labels . length ) . toEqual ( 61 ) ;
707+ expect ( labels . length ) . toEqual ( 21 ) ;
708708 expect ( labels [ 0 ] ) . toEqual ( '<8:00:00>' ) ;
709709 expect ( labels [ labels . length - 1 ] ) . toEqual ( '<8:01:00>' ) ;
710710 } ) ;
@@ -717,7 +717,7 @@ describe('Time scale tests', function() {
717717 chart . update ( ) ;
718718
719719 var labels = getLabels ( this . scale ) ;
720- expect ( labels . length ) . toEqual ( 61 ) ;
720+ expect ( labels . length ) . toEqual ( 21 ) ;
721721 expect ( labels [ 0 ] ) . toEqual ( '{8:00:00}' ) ;
722722 expect ( labels [ labels . length - 1 ] ) . toEqual ( '{8:01:00}' ) ;
723723 } ) ;
@@ -765,7 +765,7 @@ describe('Time scale tests', function() {
765765 it ( 'should get the correct labels for major and minor ticks' , function ( ) {
766766 var labels = getLabels ( this . scale ) ;
767767
768- expect ( labels . length ) . toEqual ( 61 ) ;
768+ expect ( labels . length ) . toEqual ( 21 ) ;
769769 expect ( labels [ 0 ] ) . toEqual ( '[[8:00 pm]]' ) ;
770770 expect ( labels [ Math . floor ( labels . length / 2 ) ] ) . toEqual ( '(8:00:30 pm)' ) ;
771771 expect ( labels [ labels . length - 1 ] ) . toEqual ( '[[8:01 pm]]' ) ;
@@ -777,7 +777,7 @@ describe('Time scale tests', function() {
777777 chart . update ( ) ;
778778
779779 var labels = getLabels ( this . scale ) ;
780- expect ( labels . length ) . toEqual ( 61 ) ;
780+ expect ( labels . length ) . toEqual ( 21 ) ;
781781 expect ( labels [ 0 ] ) . toEqual ( '(8:00:00 pm)' ) ;
782782 expect ( labels [ labels . length - 1 ] ) . toEqual ( '(8:01:00 pm)' ) ;
783783 } ) ;
@@ -788,7 +788,7 @@ describe('Time scale tests', function() {
788788 chart . update ( ) ;
789789
790790 var labels = getLabels ( this . scale ) ;
791- expect ( labels . length ) . toEqual ( 61 ) ;
791+ expect ( labels . length ) . toEqual ( 21 ) ;
792792 expect ( labels [ 0 ] ) . toEqual ( '<8:00 pm>' ) ;
793793 expect ( labels [ labels . length - 1 ] ) . toEqual ( '<8:01 pm>' ) ;
794794 } ) ;
@@ -799,7 +799,7 @@ describe('Time scale tests', function() {
799799 chart . update ( ) ;
800800
801801 var labels = getLabels ( this . scale ) ;
802- expect ( labels . length ) . toEqual ( 61 ) ;
802+ expect ( labels . length ) . toEqual ( 21 ) ;
803803 expect ( labels [ 0 ] ) . toEqual ( '[[8:00 pm]]' ) ;
804804 expect ( labels [ Math . floor ( labels . length / 2 ) ] ) . toEqual ( '<8:00:30 pm>' ) ;
805805 expect ( labels [ labels . length - 1 ] ) . toEqual ( '[[8:01 pm]]' ) ;
@@ -1469,6 +1469,37 @@ describe('Time scale tests', function() {
14691469 expect ( scale . getPixelForValue ( '2012' ) ) . toBeCloseToPixel ( scale . left ) ;
14701470 expect ( scale . getPixelForValue ( '2051' ) ) . toBeCloseToPixel ( scale . left + scale . width ) ;
14711471 } ) ;
1472+ } ) ;
1473+ } ) ;
1474+ } ) ;
1475+
1476+ [ 'data' , 'labels' ] . forEach ( function ( source ) {
1477+ [ 'series' , 'linear' ] . forEach ( function ( distribution ) {
1478+ describe ( 'when ticks.source is "' + source + '" and distribution is "' + distribution + '"' , function ( ) {
1479+ beforeEach ( function ( ) {
1480+ this . chart = window . acquireChart ( {
1481+ type : 'line' ,
1482+ data : {
1483+ labels : [ '2017' , '2019' , '2020' , '2025' , '2042' ] ,
1484+ datasets : [ { data : [ 0 , 1 , 2 , 3 , 4 , 5 ] } ]
1485+ } ,
1486+ options : {
1487+ scales : {
1488+ xAxes : [ {
1489+ id : 'x' ,
1490+ type : 'time' ,
1491+ time : {
1492+ parser : 'YYYY'
1493+ } ,
1494+ ticks : {
1495+ source : source
1496+ } ,
1497+ distribution : distribution
1498+ } ]
1499+ }
1500+ }
1501+ } ) ;
1502+ } ) ;
14721503
14731504 it ( 'should add offset if min and max extend the labels range and offset is true' , function ( ) {
14741505 var chart = this . chart ;
@@ -1816,7 +1847,7 @@ describe('Time scale tests', function() {
18161847
18171848 var scale = chart . scales . xScale0 ;
18181849
1819- var labels = scale . _ticksToDraw . map ( function ( t ) {
1850+ var labels = scale . ticks . map ( function ( t ) {
18201851 return t . label ;
18211852 } ) ;
18221853 expect ( labels ) . toEqual ( [
0 commit comments