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' ;
3
3
import '../../resources/chinaConsumptionLevel' ;
4
4
import mapboxgl from 'mapbox-gl' ;
5
5
@@ -64,13 +64,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
64
64
width : 240 ,
65
65
height : 100 ,
66
66
codomain : [ 0 , 40000 ] , // 允许图表展示的值域范围,此范围外的数据将不制作图表
67
- barStyle : { fillOpacity : 0.7 } , // 柱状图中柱条的(表示字段值的图形)样式
68
- barHoverStyle : { fillOpacity : 1 } , // 柱条 hover 样式
67
+ barStyle : { fillOpacity : 0.7 } , // 柱状图中柱条的(表示字段值的图形)样式
68
+ barHoverStyle : { fillOpacity : 1 } , // 柱条 hover 样式
69
69
xShapeBlank : [ 10 , 10 , 10 ] , // 水平方向上的空白间距参数
70
70
axisYTick : 4 , // y 轴刻度数量
71
71
axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] , // y 轴标签内容
72
72
axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] , // x 轴标签内容
73
- backgroundStyle : { fillColor : "#CCE8CF" } , // 背景样式
73
+ backgroundStyle : { fillColor : "#CCE8CF" } , // 背景样式
74
74
backgroundRadius : [ 5 , 5 , 5 , 5 ] , // 背景框圆角参数
75
75
//阴影开关 默认是打开
76
76
showShadow : true ,
@@ -151,13 +151,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
151
151
width : 240 ,
152
152
height : 100 ,
153
153
codomain : [ 0 , 40000 ] ,
154
- barStyle : { fillOpacity : 0.7 } ,
155
- barHoverStyle : { fillOpacity : 1 } ,
154
+ barStyle : { fillOpacity : 0.7 } ,
155
+ barHoverStyle : { fillOpacity : 1 } ,
156
156
xShapeBlank : [ 10 , 10 , 10 ] ,
157
157
axisYTick : 4 ,
158
158
axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] ,
159
159
axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] ,
160
- backgroundStyle : { fillColor : "#CCE8CF" } ,
160
+ backgroundStyle : { fillColor : "#CCE8CF" } ,
161
161
backgroundRadius : [ 5 , 5 , 5 , 5 ] ,
162
162
showShadow : true ,
163
163
barShadowStyle : {
@@ -223,12 +223,12 @@ describe('mapboxgl_GraphThemeLayer', () => {
223
223
}
224
224
} ) ;
225
225
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 } ] ;
228
228
var isQuadrilateralOverLap = graphThemeLayer . isQuadrilateralOverLap ( quadrilateral , quadrilateral2 ) ;
229
229
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 } ] ;
232
232
var isPointInPoly = graphThemeLayer . isPointInPoly ( point , polygon ) ;
233
233
expect ( isPointInPoly ) . toBeTruthy ( ) ;
234
234
graphThemeLayer . clear ( ) ;
@@ -245,13 +245,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
245
245
width : 240 ,
246
246
height : 100 ,
247
247
codomain : [ 0 , 40000 ] ,
248
- barStyle : { fillOpacity : 0.7 } ,
249
- barHoverStyle : { fillOpacity : 1 } ,
248
+ barStyle : { fillOpacity : 0.7 } ,
249
+ barHoverStyle : { fillOpacity : 1 } ,
250
250
xShapeBlank : [ 10 , 10 , 10 ] ,
251
251
axisYTick : 4 ,
252
252
axisYLabels : [ "4万" , "3万" , "2万" , "1万" , "0" ] ,
253
253
axisXLabels : [ "09年" , "10年" , "11年" , "12年" , "13年" ] ,
254
- backgroundStyle : { fillColor : "#CCE8CF" } ,
254
+ backgroundStyle : { fillColor : "#CCE8CF" } ,
255
255
backgroundRadius : [ 5 , 5 , 5 , 5 ] ,
256
256
showShadow : true ,
257
257
barShadowStyle : {
@@ -279,7 +279,7 @@ describe('mapboxgl_GraphThemeLayer', () => {
279
279
codomain : [ 0 , 40000 ]
280
280
} ,
281
281
charts : [ 1 , 2 , 3 ] ,
282
- cache : { 'name' : 'ONETWO' }
282
+ cache : { 'name' : 'ONETWO' }
283
283
} ) ;
284
284
expect ( graphThemeLayer . charts . length ) . toEqual ( 3 ) ;
285
285
expect ( graphThemeLayer . cache ) . toEqual ( Object ( {
@@ -302,13 +302,14 @@ describe('mapboxgl_GraphThemeLayer', () => {
302
302
codomain : [ 0 , 40000 ]
303
303
} ,
304
304
charts : [ 1 , 2 , 3 ] ,
305
- cache : { 'name' : 'ONETWO' }
305
+ cache : { 'name' : 'ONETWO' }
306
306
} ) ;
307
307
expect ( graphThemeLayer . visibility ) . toBeTruthy ( ) ;
308
308
graphThemeLayer . setVisibility ( false ) ;
309
309
expect ( graphThemeLayer . visibility ) . toBeFalsy ( ) ;
310
310
} ) ;
311
- xit ( 'moveTo' , ( ) => {
311
+
312
+ it ( 'moveTo' , ( ) => {
312
313
const graphThemeLayer = new Graph ( "GraphThemeLayer" , "Bar" , {
313
314
map : map ,
314
315
isOverLay : false ,
@@ -319,9 +320,10 @@ describe('mapboxgl_GraphThemeLayer', () => {
319
320
codomain : [ 0 , 40000 ]
320
321
} ,
321
322
charts : [ 1 , 2 , 3 ] ,
322
- cache : { 'name' : 'ONETWO' }
323
+ cache : { 'name' : 'ONETWO' }
323
324
} ) ;
324
- map . addLayer ( graphThemeLayer ) ;
325
+ //ThemeLayer 75行已经添加过一次了
326
+ // map.addLayer(graphThemeLayer);
325
327
const graphThemeLayer2 = new Graph ( "GraphThemeLayer2" , "Bar" , {
326
328
map : map ,
327
329
isOverLay : false ,
@@ -332,13 +334,13 @@ describe('mapboxgl_GraphThemeLayer', () => {
332
334
codomain : [ 0 , 40000 ]
333
335
} ,
334
336
charts : [ 1 , 2 , 3 ] ,
335
- cache : { 'name' : 'ONETWO' }
337
+ cache : { 'name' : 'ONETWO' }
336
338
} ) ;
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 ) ;
343
345
} ) ;
344
346
} ) ;
0 commit comments