fix: update

This commit is contained in:
Fine 2023-03-15 11:12:06 +08:00
parent 9a0fe83e95
commit 17b4e9c053
2 changed files with 11 additions and 8 deletions

View File

@ -22,7 +22,15 @@ limitations under the License. -->
>
<svg :width="width - 100" :height="height" style="background-color: #fff">
<g v-for="(n, index) in topologyLayout.nodes" :key="index">
<circle class="node" r="18" stroke-width="6" stroke="#72c59f" fill="#fff" :cx="n.x" :cy="n.y" />
<circle
class="node"
r="18"
stroke-width="6"
:stroke="n.isReal ? '#72c59f' : 'red'"
fill="#fff"
:cx="n.x"
:cy="n.y"
/>
<text :x="n.x - (n.name.length * 6) / 2" :y="n.y + n.height + 12" style="pointer-events: none">
{{ n.name.length > 20 ? `${n.name.substring(0, 20)}...` : n.name }}
</text>
@ -195,8 +203,7 @@ limitations under the License. -->
levels.push(a);
}
}
const options = {};
topologyLayout.value = layout(levels, options);
topologyLayout.value = layout(levels);
}
async function init() {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import * as d3 from "d3";
export function layout(levels: any, options: any = {}) {
export function layout(levels: any) {
// precompute level depth
levels.forEach((l: any, i: any) => l.forEach((n: any) => (n.level = i)));
@ -30,10 +30,6 @@ export function layout(levels: any, options: any = {}) {
const bundle_width = 14;
const metro_d = 4;
options.c ||= 16;
const c = options.c;
options.bigc ||= node_width + c;
nodes.forEach((n: any) => (n.height = 5 * metro_d));
let x_offset = padding;