@@ -980,61 +980,61 @@ describe('dc.barChart', function() {
980
980
} ) ;
981
981
982
982
describe ( 'check ordering option of the x axis' , function ( ) {
983
- beforeEach ( function ( ) {
984
- var rows = [
985
- { x : 'a' , y : 1 } ,
986
- { x : 'b' , y : 3 } ,
987
- { x : 'd' , y : 4 } ,
988
- { x : 'c' , y : 2 }
989
- ] ;
990
-
991
- id = 'bar-chart' ;
992
- appendChartID ( id ) ;
993
- data = crossfilter ( rows ) ;
994
- dimension = data . dimension ( function ( d ) {
995
- return d . x ;
996
- } ) ;
997
- group = dimension . group ( ) . reduceSum ( function ( d ) {
998
- return d . y ;
999
- } ) ;
983
+ beforeEach ( function ( ) {
984
+ var rows = [
985
+ { x : 'a' , y : 1 } ,
986
+ { x : 'b' , y : 3 } ,
987
+ { x : 'd' , y : 4 } ,
988
+ { x : 'c' , y : 2 }
989
+ ] ;
1000
990
1001
- chart = dc . barChart ( '#' + id ) ;
1002
- chart . width ( 500 ) . transitionDuration ( 0 )
1003
- . x ( d3 . scale . ordinal ( ) )
1004
- . xUnits ( dc . units . ordinal )
1005
- . elasticY ( true ) . elasticX ( true )
1006
- . dimension ( dimension )
1007
- . group ( group ) ;
1008
- chart . render ( ) ;
991
+ id = 'bar-chart' ;
992
+ appendChartID ( id ) ;
993
+ data = crossfilter ( rows ) ;
994
+ dimension = data . dimension ( function ( d ) {
995
+ return d . x ;
1009
996
} ) ;
1010
-
1011
- it ( 'should be ordered by default alphabetical order' , function ( ) {
1012
- var data = chart . data ( ) [ "0" ] . values ;
1013
- var expectedData = [ "a" , "b" , "c" , "d" ] ;
1014
- expect ( data . map ( function ( d ) { return d . x ; } ) ) . toEqual ( expectedData ) ;
997
+ group = dimension . group ( ) . reduceSum ( function ( d ) {
998
+ return d . y ;
1015
999
} ) ;
1016
1000
1017
- it ( 'should be ordered by value increasing' , function ( ) {
1018
- chart . ordering ( function ( d ) { return d . data . value ; } ) ;
1019
- chart . redraw ( ) ;
1020
- expect ( xAxisText ( ) ) . toEqual ( [ "a" , "c" , "b" , "d" ] ) ;
1021
- } ) ;
1001
+ chart = dc . barChart ( '#' + id ) ;
1002
+ chart . width ( 500 ) . transitionDuration ( 0 )
1003
+ . x ( d3 . scale . ordinal ( ) )
1004
+ . xUnits ( dc . units . ordinal )
1005
+ . elasticY ( true ) . elasticX ( true )
1006
+ . dimension ( dimension )
1007
+ . group ( group ) ;
1008
+ chart . render ( ) ;
1009
+ } ) ;
1022
1010
1023
- it ( 'should be ordered by value decreasing ' , function ( ) {
1024
- chart . ordering ( function ( d ) { return - d . data . value ; } ) ;
1025
- chart . redraw ( ) ;
1026
- expect ( xAxisText ( ) ) . toEqual ( [ "d" , "b" , "c" , "a" ] ) ;
1027
- } ) ;
1011
+ it ( 'should be ordered by default alphabetical order ' , function ( ) {
1012
+ var data = chart . data ( ) [ "0" ] . values ;
1013
+ var expectedData = [ "a" , "b" , "c" , "d" ] ;
1014
+ expect ( data . map ( function ( d ) { return d . x ; } ) ) . toEqual ( expectedData ) ;
1015
+ } ) ;
1028
1016
1029
- it ( 'should be ordered by alphabetical order ' , function ( ) {
1030
- chart . ordering ( function ( d ) { return d . data . key ; } ) ;
1031
- chart . redraw ( ) ;
1032
- expect ( xAxisText ( ) ) . toEqual ( [ "a" , "b " , "c " , "d" ] ) ;
1033
- } ) ;
1017
+ it ( 'should be ordered by value increasing ' , function ( ) {
1018
+ chart . ordering ( function ( d ) { return d . data . value ; } ) ;
1019
+ chart . redraw ( ) ;
1020
+ expect ( xAxisText ( ) ) . toEqual ( [ "a" , "c " , "b " , "d" ] ) ;
1021
+ } ) ;
1034
1022
1035
- function xAxisText ( ) {
1036
- return chart . selectAll ( "g.x text" ) [ 0 ] . map ( function ( x ) { return d3 . select ( x ) . text ( ) ; } ) ;
1037
- }
1023
+ it ( 'should be ordered by value decreasing' , function ( ) {
1024
+ chart . ordering ( function ( d ) { return - d . data . value ; } ) ;
1025
+ chart . redraw ( ) ;
1026
+ expect ( xAxisText ( ) ) . toEqual ( [ "d" , "b" , "c" , "a" ] ) ;
1027
+ } ) ;
1028
+
1029
+ it ( 'should be ordered by alphabetical order' , function ( ) {
1030
+ chart . ordering ( function ( d ) { return d . data . key ; } ) ;
1031
+ chart . redraw ( ) ;
1032
+ expect ( xAxisText ( ) ) . toEqual ( [ "a" , "b" , "c" , "d" ] ) ;
1033
+ } ) ;
1034
+
1035
+ function xAxisText ( ) {
1036
+ return chart . selectAll ( "g.x text" ) [ 0 ] . map ( function ( x ) { return d3 . select ( x ) . text ( ) ; } ) ;
1037
+ }
1038
1038
} ) ;
1039
1039
1040
1040
function nthStack ( n ) {
0 commit comments