@@ -2028,6 +2028,101 @@ describe('WebMapV3 - _createLayerLegendList', () => {
20282028 expect ( linearLegend . styleGroup [ 0 ] . style . colors ) . toEqual ( [ '#FF0000' , '#0000FF' ] ) ;
20292029 } ) ;
20302030
2031+ it ( 'should create gradient legend for column source and target colors' , ( ) => {
2032+ const { instance } = createTestContext ( ) ;
2033+ // Column symbols contain symbolId, not the style.paint used by line/fill symbols.
2034+ spyOn ( instance , '_getImageIdFromValue' ) . and . callThrough ( ) ;
2035+ const layer = { id : 'column1' , title : 'Column' , type : 'point-extrusion' } ;
2036+ const styleSetting = {
2037+ type : 'column' ,
2038+ color : { type : 'simple' , value : '#EE4D5A' } ,
2039+ sourceColor : { type : 'simple' , value : '#4A90E2' } ,
2040+ targetColor : { type : 'simple' , value : '#7ED321' } ,
2041+ size : { type : 'simple' , value : 12 } ,
2042+ opacity : { type : 'simple' , value : 1 } ,
2043+ shape : { type : 'simple' , value : 'cylinder' }
2044+ } ;
2045+
2046+ const result = instance . _createLayerLegendList ( layer , styleSetting ) ;
2047+ const colorLegend = result . find ( ( item ) => item . styleField === 'color' ) ;
2048+
2049+ expect ( result ) . toHaveLength ( 2 ) ;
2050+ expect ( result . some ( ( item ) => ! item . styleField ) ) . toBe ( true ) ;
2051+ expect ( colorLegend ) . toBeDefined ( ) ;
2052+ expect ( colorLegend . styleGroup ) . toHaveLength ( 1 ) ;
2053+ expect ( colorLegend . styleGroup [ 0 ] . style . colors ) . toEqual ( [
2054+ { key : 'sourceColor' , value : '#4A90E2' } ,
2055+ { key : 'targetColor' , value : '#7ED321' }
2056+ ] ) ;
2057+ expect ( instance . _getImageIdFromValue ) . not . toHaveBeenCalled ( ) ;
2058+ } ) ;
2059+
2060+ it ( 'should keep the column gradient legend when size is data driven' , ( ) => {
2061+ const { instance } = createTestContext ( ) ;
2062+ const layer = { id : 'column3' , title : 'Column' , type : 'point-extrusion' } ;
2063+ const styleSetting = {
2064+ type : 'column' ,
2065+ color : { type : 'simple' , value : 'rgba(34,3,6,1)' } ,
2066+ sourceColor : { type : 'simple' , value : '#D53E4F' } ,
2067+ targetColor : { type : 'simple' , value : '#3288BD' } ,
2068+ size : {
2069+ type : 'unique' ,
2070+ field : [ 'smpid' ] ,
2071+ defaultValue : 12 ,
2072+ values : [
2073+ { key : 1 , value : 1 } ,
2074+ { key : 136 , value : 136 }
2075+ ] ,
2076+ interpolateInfo : { type : 'linear' }
2077+ } ,
2078+ opacity : { type : 'simple' , value : 0.9 } ,
2079+ shape : { type : 'simple' , value : 'cylinder' }
2080+ } ;
2081+
2082+ const result = instance . _createLayerLegendList ( layer , styleSetting ) ;
2083+ const colorLegend = result . find ( ( item ) => item . styleField === 'color' ) ;
2084+ const sizeLegend = result . find ( ( item ) => item . styleField === 'size' ) ;
2085+
2086+ expect ( colorLegend ) . toBeDefined ( ) ;
2087+ expect ( colorLegend . styleGroup [ 0 ] . style . colors ) . toEqual ( [
2088+ { key : 'sourceColor' , value : '#D53E4F' } ,
2089+ { key : 'targetColor' , value : '#3288BD' }
2090+ ] ) ;
2091+ expect ( sizeLegend ) . toBeDefined ( ) ;
2092+ } ) ;
2093+
2094+ it ( 'should expose data driven column shapes as symbolsContent legends' , ( ) => {
2095+ const { instance } = createTestContext ( ) ;
2096+ const layer = { id : 'column2' , title : 'Column' , type : 'point-extrusion' } ;
2097+ const styleSetting = {
2098+ type : 'column' ,
2099+ color : { type : 'simple' , value : '#4A90E2' } ,
2100+ size : { type : 'simple' , value : 12 } ,
2101+ opacity : { type : 'simple' , value : 1 } ,
2102+ shape : {
2103+ type : 'unique' ,
2104+ field : [ 'TYPE' ] ,
2105+ values : [
2106+ { key : 'A' , value : 'triangleColumn' } ,
2107+ { key : 'B' , value : 'squareColumn' }
2108+ ] ,
2109+ defaultValue : 'cylinder' ,
2110+ interpolateInfo : { type : 'custom' }
2111+ }
2112+ } ;
2113+
2114+ const normalized = instance . _normalizeColumnStyleSetting ( styleSetting ) ;
2115+ expect ( normalized . symbolsContent . values . map ( ( item ) => item . value . symbolId ) ) . toEqual ( [ 'triangle' , 'rectangle' ] ) ;
2116+ expect ( normalized . symbolsContent . defaultValue ) . toEqual ( { symbolId : 'circle' } ) ;
2117+
2118+ const result = instance . _createLayerLegendList ( layer , styleSetting ) ;
2119+ const symbolLegend = result . find ( ( item ) => item . styleField === 'symbolsContent' ) ;
2120+ expect ( symbolLegend ) . toBeDefined ( ) ;
2121+ expect ( symbolLegend . themeField ) . toBe ( 'TYPE' ) ;
2122+ expect ( symbolLegend . styleGroup ) . toHaveLength ( 3 ) ;
2123+ expect ( symbolLegend . styleGroup . map ( ( item ) => item . fieldValue ) ) . toEqual ( [ 'A' , 'B' , null ] ) ;
2124+ } ) ;
2125+
20312126 it ( 'should create range style groups for non-color data driven field' , ( ) => {
20322127 const { instance } = createTestContext ( ) ;
20332128 const layer = { id : 'l1' , title : 'Layer' , type : 'circle' } ;
0 commit comments