Skip to content

Commit c7e30b2

Browse files
committed
feat: frequency file add handle
1 parent b296ae2 commit c7e30b2

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { IApi } from '@umijs/max';
44
export default (api: IApi) => {
55
api.modifyHTML(($) => {
66
$('head').append([
7+
// 添加 cesium-navigation-es JS 文件
8+
`<script src="/public/js/CesiumNavigation.umd.js" charset="utf-8"></script>`,
79
// 缩小的 turf 文件,并将其包含在脚本标记中
810
`<script src="/public/js/turf.min.js" charset="utf-8"></script>`,
911
// html2canvas 文件vs, 并将其包含在脚本标记中

src/pages/Feature/D3/Frequency.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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]);

src/pages/Feature/Map/Cesium/HaiAirPosture.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ const HaiAirPosture = () => {
1414
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1515
const [data, setData] = useState([]);
1616
Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;
17+
// setTimeout(() => {
18+
// let CesiumNavigation = window.CesiumNavigation;
19+
// console.log('CesiumNavigation:', window);
20+
21+
// }, 1000);
1722

1823
// NOTE 添加图标
1924
const handleIcon = (viewer: any) => {

0 commit comments

Comments
 (0)