@@ -109,83 +109,91 @@ describe('openlayers_Graph', function () {
109109 } ) ;
110110
111111 it ( 'addFeatures, removeFeatures' , function ( done ) {
112- var graphThemeSource = new ol . source . Graph ( "BarThemeLayer" , "Bar" , {
113- map : map
114- } ) ;
115- graphThemeSource . themeFields = [ "CON2009" , "CON2010" , "CON2011" , "CON2012" , "CON2013" ] ;
116- graphThemeSource . chartsSetting = {
117- width : 240 ,
118- height : 100 ,
119- codomain : [ 0 , 40000 ] ,
120- barStyle : { fillOpacity : 0.7 } ,
121- barHoverStyle : { fillOpacity : 1 } ,
122- xShapeBlank : [ 10 , 10 , 10 ] ,
123- axisYTick : 4 ,
124- axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] ,
125- axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] ,
126- backgroundStyle : { fillColor : "#CCE8CF" } ,
127- backgroundRadius : [ 5 , 5 , 5 , 5 ] ,
128- showShadow : true ,
129- barShadowStyle : { shadowBlur : 8 , shadowOffsetX : 2 , shadowOffsetY : 2 , shadowColor : "rgba(100,100,100,0.8)" } ,
130- barLinearGradient : [ [ "#00FF00" , "#00CD00" ] , [ "#00CCFF" , "#5E87A2" ] , [ "#00FF66" , "#669985" ] , [ "#CCFF00" , "#94A25E" ] , [ "#FF9900" , "#A2945E" ] ]
131- } ;
132- var layer = new ol . layer . Image ( {
133- source : graphThemeSource
134- } ) ;
135- map . addLayer ( layer ) ;
136- expect ( graphThemeSource . features . length ) . toEqual ( 0 ) ;
137- var features = [ ] ;
138- for ( var i = 0 , len = chinaConsumptionLevel . length ; i < len ; i ++ ) {
139- var provinceInfo = chinaConsumptionLevel [ i ] ;
140- var geometry = new ol . geom . Point ( [ provinceInfo [ 1 ] , provinceInfo [ 2 ] ] ) ;
141- var atrributes = { } ;
142- atrributes . NAME = provinceInfo [ 0 ] ;
143- atrributes . CON2009 = provinceInfo [ 3 ] ;
144- atrributes . CON2010 = provinceInfo [ 4 ] ;
145- atrributes . CON2011 = provinceInfo [ 5 ] ;
146- atrributes . CON2012 = provinceInfo [ 6 ] ;
147- atrributes . CON2013 = provinceInfo [ 7 ] ;
148- var fea = new ol . supermap . ThemeFeature ( geometry , atrributes ) ;
149- features . push ( fea ) ;
150- }
151- graphThemeSource . addFeatures ( features ) ;
152- var LayerFeatures = graphThemeSource . features ;
153- expect ( LayerFeatures . length ) . toBeGreaterThan ( 0 ) ;
154- for ( var j = 0 ; j < LayerFeatures . length ; j ++ ) {
155- expect ( LayerFeatures [ j ] . CLASS_NAME ) . toBe ( "SuperMap.Feature.Vector" ) ;
156- expect ( LayerFeatures [ j ] . id ) . toContain ( "SuperMap.Feature" ) ;
157- expect ( LayerFeatures [ j ] . attributes ) . not . toBeNull ( ) ;
158- expect ( LayerFeatures [ j ] . geometry ) . not . toBeNull ( ) ;
159- expect ( LayerFeatures [ j ] . geometry . CLASS_NAME ) . toBe ( "SuperMap.Geometry.Point" ) ;
160- expect ( LayerFeatures [ j ] . geometry . id ) . toContain ( "SuperMap.Geometry" ) ;
161- expect ( LayerFeatures [ j ] . geometry . x ) . not . toBeNull ( ) ;
162- expect ( LayerFeatures [ j ] . geometry . y ) . not . toBeNull ( ) ;
163- }
164- expect ( LayerFeatures [ 0 ] . geometry . x ) . toEqual ( 116.407283 ) ;
165- expect ( LayerFeatures [ 0 ] . geometry . y ) . toEqual ( 39.904557 ) ;
166- expect ( LayerFeatures [ 0 ] . data ) . toEqual ( LayerFeatures [ 0 ] . attributes ) ;
167- expect ( LayerFeatures [ 0 ] . attributes ) . toEqual ( Object ( {
168- CON2009 : 22023 ,
169- CON2010 : 24982 ,
170- CON2011 : 27760 ,
171- CON2012 : 30350 ,
172- CON2013 : 33337 ,
173- NAME : "北京市"
174- } ) ) ;
175- var shape1 = graphThemeSource . getShapesByFeatureID ( ) ;
176- var shape2 = graphThemeSource . getShapesByFeatureID ( LayerFeatures [ 0 ] . id ) ;
177- expect ( shape1 . length ) . toEqual ( 17 ) ;
178- expect ( shape2 . length ) . toEqual ( 5 ) ;
179- graphThemeSource . features [ 0 ] . geometry . x = 39 ;
180- var redraw = graphThemeSource . redraw ( ) ;
181- expect ( redraw ) . toBeTruthy ( ) ;
182- expect ( graphThemeSource . features [ 0 ] . geometry . x ) . toEqual ( 39 ) ;
183- graphThemeSource . removeFeatures ( ) ;
184- expect ( graphThemeSource . features . length ) . toBeGreaterThan ( 0 ) ;
185- graphThemeSource . removeAllFeatures ( ) ;
186- expect ( graphThemeSource . features . length ) . toEqual ( 0 ) ;
187- graphThemeSource . clear ( ) ;
188- done ( ) ;
112+ setTimeout ( function ( ) {
113+ var graphThemeSource = new ol . source . Graph ( "BarThemeLayer" , "Bar" , {
114+ map : map
115+ } ) ;
116+ graphThemeSource . themeFields = [ "CON2009" , "CON2010" , "CON2011" , "CON2012" , "CON2013" ] ;
117+ graphThemeSource . chartsSetting = {
118+ width : 240 ,
119+ height : 100 ,
120+ codomain : [ 0 , 40000 ] ,
121+ barStyle : { fillOpacity : 0.7 } ,
122+ barHoverStyle : { fillOpacity : 1 } ,
123+ xShapeBlank : [ 10 , 10 , 10 ] ,
124+ axisYTick : 4 ,
125+ axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] ,
126+ axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] ,
127+ backgroundStyle : { fillColor : "#CCE8CF" } ,
128+ backgroundRadius : [ 5 , 5 , 5 , 5 ] ,
129+ showShadow : true ,
130+ barShadowStyle : {
131+ shadowBlur : 8 ,
132+ shadowOffsetX : 2 ,
133+ shadowOffsetY : 2 ,
134+ shadowColor : "rgba(100,100,100,0.8)"
135+ } ,
136+ barLinearGradient : [ [ "#00FF00" , "#00CD00" ] , [ "#00CCFF" , "#5E87A2" ] , [ "#00FF66" , "#669985" ] , [ "#CCFF00" , "#94A25E" ] , [ "#FF9900" , "#A2945E" ] ]
137+ } ;
138+ var layer = new ol . layer . Image ( {
139+ source : graphThemeSource
140+ } ) ;
141+ map . addLayer ( layer ) ;
142+ expect ( graphThemeSource . features . length ) . toEqual ( 0 ) ;
143+ var features = [ ] ;
144+ for ( var i = 0 , len = chinaConsumptionLevel . length ; i < len ; i ++ ) {
145+ var provinceInfo = chinaConsumptionLevel [ i ] ;
146+ var geometry = new ol . geom . Point ( [ provinceInfo [ 1 ] , provinceInfo [ 2 ] ] ) ;
147+ var atrributes = { } ;
148+ atrributes . NAME = provinceInfo [ 0 ] ;
149+ atrributes . CON2009 = provinceInfo [ 3 ] ;
150+ atrributes . CON2010 = provinceInfo [ 4 ] ;
151+ atrributes . CON2011 = provinceInfo [ 5 ] ;
152+ atrributes . CON2012 = provinceInfo [ 6 ] ;
153+ atrributes . CON2013 = provinceInfo [ 7 ] ;
154+ var fea = new ol . supermap . ThemeFeature ( geometry , atrributes ) ;
155+ features . push ( fea ) ;
156+ }
157+ graphThemeSource . addFeatures ( features ) ;
158+ var LayerFeatures = graphThemeSource . features ;
159+ expect ( LayerFeatures . length ) . toBeGreaterThan ( 0 ) ;
160+ for ( var j = 0 ; j < LayerFeatures . length ; j ++ ) {
161+ expect ( LayerFeatures [ j ] . CLASS_NAME ) . toBe ( "SuperMap.Feature.Vector" ) ;
162+ expect ( LayerFeatures [ j ] . id ) . toContain ( "SuperMap.Feature" ) ;
163+ expect ( LayerFeatures [ j ] . attributes ) . not . toBeNull ( ) ;
164+ expect ( LayerFeatures [ j ] . geometry ) . not . toBeNull ( ) ;
165+ expect ( LayerFeatures [ j ] . geometry . CLASS_NAME ) . toBe ( "SuperMap.Geometry.Point" ) ;
166+ expect ( LayerFeatures [ j ] . geometry . id ) . toContain ( "SuperMap.Geometry" ) ;
167+ expect ( LayerFeatures [ j ] . geometry . x ) . not . toBeNull ( ) ;
168+ expect ( LayerFeatures [ j ] . geometry . y ) . not . toBeNull ( ) ;
169+ }
170+ expect ( LayerFeatures [ 0 ] . geometry . x ) . toEqual ( 116.407283 ) ;
171+ expect ( LayerFeatures [ 0 ] . geometry . y ) . toEqual ( 39.904557 ) ;
172+ expect ( LayerFeatures [ 0 ] . data ) . toEqual ( LayerFeatures [ 0 ] . attributes ) ;
173+ expect ( LayerFeatures [ 0 ] . attributes ) . toEqual ( Object ( {
174+ CON2009 : 22023 ,
175+ CON2010 : 24982 ,
176+ CON2011 : 27760 ,
177+ CON2012 : 30350 ,
178+ CON2013 : 33337 ,
179+ NAME : "北京市"
180+ } ) ) ;
181+ var shape1 = graphThemeSource . getShapesByFeatureID ( ) ;
182+ var shape2 = graphThemeSource . getShapesByFeatureID ( LayerFeatures [ 0 ] . id ) ;
183+ expect ( shape1 . length ) . toEqual ( 17 ) ;
184+ expect ( shape2 . length ) . toEqual ( 5 ) ;
185+ graphThemeSource . features [ 0 ] . geometry . x = 39 ;
186+ var redraw = graphThemeSource . redraw ( ) ;
187+ expect ( redraw ) . toBeTruthy ( ) ;
188+ expect ( graphThemeSource . features [ 0 ] . geometry . x ) . toEqual ( 39 ) ;
189+ graphThemeSource . removeFeatures ( ) ;
190+ expect ( graphThemeSource . features . length ) . toBeGreaterThan ( 0 ) ;
191+ graphThemeSource . removeAllFeatures ( ) ;
192+ expect ( graphThemeSource . features . length ) . toEqual ( 0 ) ;
193+ graphThemeSource . clear ( ) ;
194+ done ( ) ;
195+ } , 3000 ) ;
196+
189197 } ) ;
190198
191199 it ( 'isQuadrilateralOverLap' , function ( done ) {
0 commit comments