@@ -97,6 +97,9 @@ const Frequency = () => {
9797 // 创建主组用于内容绘制
9898 const mainGroup = svg . append ( 'g' ) . attr ( 'transform' , `translate(${ margin . left } ,${ margin . top } )` ) ;
9999
100+ // 将频率标记组添加到最底层
101+ const frequencyMarkerGroup = svg . append ( 'g' ) . attr ( 'class' , 'frequency-markers' ) . style ( 'pointer-events' , 'none' ) ;
102+
100103 // 创建等距比例尺
101104 const xScale : any = d3
102105 . scalePoint ( )
@@ -557,6 +560,57 @@ const Frequency = () => {
557560 return leftPos + ( rightPos - leftPos ) * progress ;
558561 } ;
559562
563+ // const targetFrequencyRange = [1000000, 140000000];
564+ const targetFrequencyRange : any = [ ] ;
565+
566+ // 如果是第一个类型组,添加频率标记
567+ if ( targetFrequencyRange . length > 0 ) {
568+ const startX = getXPosition ( targetFrequencyRange [ 0 ] ) ;
569+ const endX = getXPosition ( targetFrequencyRange [ 1 ] ) ;
570+
571+ if ( startX !== null && endX !== null ) {
572+ // 添加范围背景
573+ frequencyMarkerGroup
574+ . append ( 'rect' )
575+ . attr ( 'x' , startX ) // 从顶部开始
576+ . attr ( 'y' , 0 ) // 从顶部开始
577+ . attr ( 'width' , endX - startX ) // 到底部结束
578+ . attr ( 'height' , totalHeight - margin . bottom ) // 到底部结束
579+ . attr ( 'fill' , 'green' )
580+ . attr ( 'opacity' , 0.1 )
581+ . style ( 'pointer-events' , 'none' ) ;
582+
583+ // 添加标记线
584+ [ startX , endX ] . forEach ( ( x ) => {
585+ frequencyMarkerGroup
586+ . append ( 'line' )
587+ . attr ( 'x1' , x ) // 从顶部开始
588+ . attr ( 'y1' , 0 ) // 从顶部开始
589+ . attr ( 'x2' , x ) // 到底部结束
590+ . attr ( 'y2' , totalHeight - margin . bottom ) // 到底部结束
591+ . attr ( 'stroke' , 'green' )
592+ . attr ( 'stroke-width' , 2 )
593+ . style ( 'pointer-events' , 'none' ) ;
594+ } ) ;
595+
596+ // // 添加频率标签
597+ // [
598+ // { x: startX, freq: targetFrequencyRange[0], align: 'start' },
599+ // { x: endX, freq: targetFrequencyRange[1], align: 'end' }
600+ // ].forEach(({ x, freq, align }) => {
601+ // mainGroup
602+ // .append('text')
603+ // .attr('x', x)
604+ // .attr('y', -margin.top - 10)
605+ // .attr('text-anchor', align)
606+ // .attr('fill', 'green')
607+ // .attr('font-size', '12px')
608+ // .text(formatFrequency(freq))
609+ // .style('pointer-events', 'none');
610+ // });
611+ }
612+ }
613+
560614 // 绘制频率块
561615 typeData . ranges . forEach ( ( freq : any , i : any ) => {
562616 const startX = getXPosition ( freq . range [ 0 ] ) ;
0 commit comments