1- import { Graph } from '../../../src/mapboxgl/overlay/GraphThemeLayer' ;
2- import { ThemeFeature } from '../../../src/mapboxgl/overlay/theme/ThemeFeature' ;
1+ import { Graph } from '../../../src/mapboxgl/overlay/GraphThemeLayer' ;
2+ import { ThemeFeature } from '../../../src/mapboxgl/overlay/theme/ThemeFeature' ;
33import '../../resources/chinaConsumptionLevel' ;
44import mapboxgl from 'mapbox-gl' ;
55
@@ -64,13 +64,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
6464 width : 240 ,
6565 height : 100 ,
6666 codomain : [ 0 , 40000 ] , // 允许图表展示的值域范围,此范围外的数据将不制作图表
67- barStyle : { fillOpacity : 0.7 } , // 柱状图中柱条的(表示字段值的图形)样式
68- barHoverStyle : { fillOpacity : 1 } , // 柱条 hover 样式
67+ barStyle : { fillOpacity : 0.7 } , // 柱状图中柱条的(表示字段值的图形)样式
68+ barHoverStyle : { fillOpacity : 1 } , // 柱条 hover 样式
6969 xShapeBlank : [ 10 , 10 , 10 ] , // 水平方向上的空白间距参数
7070 axisYTick : 4 , // y 轴刻度数量
7171 axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] , // y 轴标签内容
7272 axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] , // x 轴标签内容
73- backgroundStyle : { fillColor : "#CCE8CF" } , // 背景样式
73+ backgroundStyle : { fillColor : "#CCE8CF" } , // 背景样式
7474 backgroundRadius : [ 5 , 5 , 5 , 5 ] , // 背景框圆角参数
7575 //阴影开关 默认是打开
7676 showShadow : true ,
@@ -151,13 +151,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
151151 width : 240 ,
152152 height : 100 ,
153153 codomain : [ 0 , 40000 ] ,
154- barStyle : { fillOpacity : 0.7 } ,
155- barHoverStyle : { fillOpacity : 1 } ,
154+ barStyle : { fillOpacity : 0.7 } ,
155+ barHoverStyle : { fillOpacity : 1 } ,
156156 xShapeBlank : [ 10 , 10 , 10 ] ,
157157 axisYTick : 4 ,
158158 axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] ,
159159 axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] ,
160- backgroundStyle : { fillColor : "#CCE8CF" } ,
160+ backgroundStyle : { fillColor : "#CCE8CF" } ,
161161 backgroundRadius : [ 5 , 5 , 5 , 5 ] ,
162162 showShadow : true ,
163163 barShadowStyle : {
@@ -223,12 +223,12 @@ describe('mapboxgl_GraphThemeLayer', () => {
223223 }
224224 } ) ;
225225 var quadrilateral , quadrilateral2 ;
226- quadrilateral = [ { "x" : 1 , "y" : 1 } , { "x" : 3 , "y" : 1 } , { "x" : 6 , "y" : 4 } , { "x" : 2 , "y" : 10 } , { "x" : 1 , "y" : 1 } ] ;
227- quadrilateral2 = [ { "x" : 1 , "y" : 1 } , { "x" : 3 , "y" : 1 } , { "x" : 6 , "y" : 4 } , { "x" : 2 , "y" : 10 } , { "x" : 1 , "y" : 1 } ] ;
226+ quadrilateral = [ { "x" : 1 , "y" : 1 } , { "x" : 3 , "y" : 1 } , { "x" : 6 , "y" : 4 } , { "x" : 2 , "y" : 10 } , { "x" : 1 , "y" : 1 } ] ;
227+ quadrilateral2 = [ { "x" : 1 , "y" : 1 } , { "x" : 3 , "y" : 1 } , { "x" : 6 , "y" : 4 } , { "x" : 2 , "y" : 10 } , { "x" : 1 , "y" : 1 } ] ;
228228 var isQuadrilateralOverLap = graphThemeLayer . isQuadrilateralOverLap ( quadrilateral , quadrilateral2 ) ;
229229 expect ( isQuadrilateralOverLap ) . toBeTruthy ( ) ;
230- var point = { "x" : 2 , "y" : 5 } ;
231- var polygon = [ { "x" : 1 , "y" : 1 } , { "x" : 3 , "y" : 1 } , { "x" : 6 , "y" : 4 } , { "x" : 2 , "y" : 10 } , { "x" : 1 , "y" : 1 } ] ;
230+ var point = { "x" : 2 , "y" : 5 } ;
231+ var polygon = [ { "x" : 1 , "y" : 1 } , { "x" : 3 , "y" : 1 } , { "x" : 6 , "y" : 4 } , { "x" : 2 , "y" : 10 } , { "x" : 1 , "y" : 1 } ] ;
232232 var isPointInPoly = graphThemeLayer . isPointInPoly ( point , polygon ) ;
233233 expect ( isPointInPoly ) . toBeTruthy ( ) ;
234234 graphThemeLayer . clear ( ) ;
@@ -245,13 +245,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
245245 width : 240 ,
246246 height : 100 ,
247247 codomain : [ 0 , 40000 ] ,
248- barStyle : { fillOpacity : 0.7 } ,
249- barHoverStyle : { fillOpacity : 1 } ,
248+ barStyle : { fillOpacity : 0.7 } ,
249+ barHoverStyle : { fillOpacity : 1 } ,
250250 xShapeBlank : [ 10 , 10 , 10 ] ,
251251 axisYTick : 4 ,
252252 axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] ,
253253 axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] ,
254- backgroundStyle : { fillColor : "#CCE8CF" } ,
254+ backgroundStyle : { fillColor : "#CCE8CF" } ,
255255 backgroundRadius : [ 5 , 5 , 5 , 5 ] ,
256256 showShadow : true ,
257257 barShadowStyle : {
@@ -279,7 +279,7 @@ describe('mapboxgl_GraphThemeLayer', () => {
279279 codomain : [ 0 , 40000 ]
280280 } ,
281281 charts : [ 1 , 2 , 3 ] ,
282- cache : { 'name' : 'ONETWO' }
282+ cache : { 'name' : 'ONETWO' }
283283 } ) ;
284284 expect ( graphThemeLayer . charts . length ) . toEqual ( 3 ) ;
285285 expect ( graphThemeLayer . cache ) . toEqual ( Object ( {
@@ -302,13 +302,14 @@ describe('mapboxgl_GraphThemeLayer', () => {
302302 codomain : [ 0 , 40000 ]
303303 } ,
304304 charts : [ 1 , 2 , 3 ] ,
305- cache : { 'name' : 'ONETWO' }
305+ cache : { 'name' : 'ONETWO' }
306306 } ) ;
307307 expect ( graphThemeLayer . visibility ) . toBeTruthy ( ) ;
308308 graphThemeLayer . setVisibility ( false ) ;
309309 expect ( graphThemeLayer . visibility ) . toBeFalsy ( ) ;
310310 } ) ;
311- xit ( 'moveTo' , ( ) => {
311+
312+ it ( 'moveTo' , ( ) => {
312313 const graphThemeLayer = new Graph ( "GraphThemeLayer" , "Bar" , {
313314 map : map ,
314315 isOverLay : false ,
@@ -319,9 +320,10 @@ describe('mapboxgl_GraphThemeLayer', () => {
319320 codomain : [ 0 , 40000 ]
320321 } ,
321322 charts : [ 1 , 2 , 3 ] ,
322- cache : { 'name' : 'ONETWO' }
323+ cache : { 'name' : 'ONETWO' }
323324 } ) ;
324- map . addLayer ( graphThemeLayer ) ;
325+ //ThemeLayer 75行已经添加过一次了
326+ // map.addLayer(graphThemeLayer);
325327 const graphThemeLayer2 = new Graph ( "GraphThemeLayer2" , "Bar" , {
326328 map : map ,
327329 isOverLay : false ,
@@ -332,13 +334,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
332334 codomain : [ 0 , 40000 ]
333335 } ,
334336 charts : [ 1 , 2 , 3 ] ,
335- cache : { 'name' : 'ONETWO' }
337+ cache : { 'name' : 'ONETWO' }
336338 } ) ;
337- map . addLayer ( graphThemeLayer2 ) ;
338- const zIndex = graphThemeLayer . div . style . zIndex ;
339- const zIndex2 = graphThemeLayer2 . div . style . zIndex ;
340- expect ( zIndex2 ) . toBeGreaterThan ( zIndex ) ;
341- graphThemeLayer . moveTo ( "graphThemeLayer2" ) ;
342- expect ( zIndex ) . toBeGreaterThan ( zIndex2 ) ;
339+ //ThemeLayer 75行已经添加过一次了
340+ // map.addLayer(graphThemeLayer2) ;
341+ //移动前,第一个layer是第一个
342+ expect ( graphThemeLayer . div . parentNode . getElementsByClassName ( "themeLayer" ) [ 0 ] . id ) . toEqual ( graphThemeLayer . id ) ;
343+ graphThemeLayer2 . moveTo ( graphThemeLayer . id ) ;
344+ expect ( graphThemeLayer . div . parentNode . getElementsByClassName ( "themeLayer" ) [ 0 ] . id ) . toEqual ( graphThemeLayer2 . id ) ;
343345 } ) ;
344346} ) ;
0 commit comments