f2e814bf by lihua

桑基图大数据量下查看

1 parent 100fa19a
1 <template> 1 <template>
2 <div ref="containerRef" class='canvas-wrapper'> 2 <div ref="mainRef" class='canvas-wrapper'>
3 <div ref="containerRef" class='canvas-wrapper-content'>
3 4
4 </div> 5 </div>
6 </div>
5 </template> 7 </template>
6 8
7 <script lang="ts" setup name="topbar"> 9 <script lang="ts" setup name="topbar">
...@@ -78,6 +80,11 @@ const sankeyInstance: any = ref(); ...@@ -78,6 +80,11 @@ const sankeyInstance: any = ref();
78 const containerRef = ref(); 80 const containerRef = ref();
79 81
80 const setChartsOption = () => { 82 const setChartsOption = () => {
83 if (props.names.length > 250) {
84 containerRef.value.style.height = (props.names.length * 3.5) + 'px';
85 } else {
86 containerRef.value.style.height = '100%';
87 }
81 88
82 let option = { 89 let option = {
83 tooltip: { 90 tooltip: {
...@@ -94,7 +101,7 @@ const setChartsOption = () => { ...@@ -94,7 +101,7 @@ const setChartsOption = () => {
94 { 101 {
95 type: 'sankey', 102 type: 'sankey',
96 top: 60, 103 top: 60,
97 bottom: 20, 104 bottom: 40,
98 draggable: false, 105 draggable: false,
99 left: 50, 106 left: 50,
100 emphasis: { 107 emphasis: {
...@@ -112,7 +119,7 @@ const setChartsOption = () => { ...@@ -112,7 +119,7 @@ const setChartsOption = () => {
112 return { 119 return {
113 ...n, 120 ...n,
114 label: { 121 label: {
115 width: 97, 122 width: props.names.length > 300 ? 86 : 97,
116 overflow: 'breakAll' 123 overflow: 'breakAll'
117 } 124 }
118 } 125 }
...@@ -135,6 +142,11 @@ const resizeObserver = ref(); ...@@ -135,6 +142,11 @@ const resizeObserver = ref();
135 142
136 const observeResize = () => { 143 const observeResize = () => {
137 window.addEventListener('resize', (e) => { 144 window.addEventListener('resize', (e) => {
145 if (props.names.length > 250) {
146 containerRef.value.style.height = (props.names.length * 3.5) + 'px';
147 } else {
148 containerRef.value.style.height = '100%';
149 }
138 sankeyInstance.value?.resize(); 150 sankeyInstance.value?.resize();
139 }); 151 });
140 } 152 }
...@@ -154,5 +166,12 @@ onMounted(() => { ...@@ -154,5 +166,12 @@ onMounted(() => {
154 width: 100%; 166 width: 100%;
155 height: 100%; 167 height: 100%;
156 position: relative; 168 position: relative;
169 overflow-y: auto;
170 overflow-x: hidden;
171 }
172
173 .canvas-wrapper-content {
174 width: 100%;
175 height: 100%;
157 } 176 }
158 </style> 177 </style>
...\ No newline at end of file ...\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!