mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 18:45:23 +00:00
update graph
This commit is contained in:
parent
39cedf1ddb
commit
7dfc87324d
@ -35,8 +35,8 @@ export default (d3: any, graph: any, funcs: any, tip: any) => {
|
|||||||
});
|
});
|
||||||
nodeEnter
|
nodeEnter
|
||||||
.append("image")
|
.append("image")
|
||||||
.attr("width", 40)
|
.attr("width", 35)
|
||||||
.attr("height", 40)
|
.attr("height", 35)
|
||||||
.attr("x", (d: any) => d.x)
|
.attr("x", (d: any) => d.x)
|
||||||
.attr("y", (d: any) => d.y)
|
.attr("y", (d: any) => d.y)
|
||||||
.attr("style", "cursor: move;")
|
.attr("style", "cursor: move;")
|
||||||
@ -46,9 +46,9 @@ export default (d3: any, graph: any, funcs: any, tip: any) => {
|
|||||||
.attr("fill", "#000")
|
.attr("fill", "#000")
|
||||||
.attr("text-anchor", "middle")
|
.attr("text-anchor", "middle")
|
||||||
.attr("x", (d: any) => d.x + 15)
|
.attr("x", (d: any) => d.x + 15)
|
||||||
.attr("y", (d: any) => d.y + 50)
|
.attr("y", (d: any) => d.y + 42)
|
||||||
.text((d: { name: string }) =>
|
.text((d: { name: string }) =>
|
||||||
d.name.length > 20 ? `${d.name.substring(0, 20)}...` : d.name
|
d.name.length > 10 ? `${d.name.substring(0, 10)}...` : d.name
|
||||||
);
|
);
|
||||||
return nodeEnter;
|
return nodeEnter;
|
||||||
};
|
};
|
||||||
|
@ -35,6 +35,7 @@ import { ElMessage } from "element-plus";
|
|||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import { useNetworkProfilingStore } from "@/store/modules/network-profiling";
|
import { useNetworkProfilingStore } from "@/store/modules/network-profiling";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import d3tip from "d3-tip";
|
import d3tip from "d3-tip";
|
||||||
import {
|
import {
|
||||||
linkElement,
|
linkElement,
|
||||||
@ -60,6 +61,7 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
|
const selectorStore = useSelectorStore();
|
||||||
const networkProfilingStore = useNetworkProfilingStore();
|
const networkProfilingStore = useNetworkProfilingStore();
|
||||||
const height = ref<number>(100);
|
const height = ref<number>(100);
|
||||||
const width = ref<number>(100);
|
const width = ref<number>(100);
|
||||||
@ -104,7 +106,7 @@ function drawGraph() {
|
|||||||
graph.value = svg.value
|
graph.value = svg.value
|
||||||
.append("g")
|
.append("g")
|
||||||
.attr("class", "svg-graph")
|
.attr("class", "svg-graph")
|
||||||
.attr("transform", `translate(200, 200)`);
|
.attr("transform", `translate(300, 300)`);
|
||||||
graph.value.call(tip.value);
|
graph.value.call(tip.value);
|
||||||
node.value = graph.value.append("g").selectAll(".topo-node");
|
node.value = graph.value.append("g").selectAll(".topo-node");
|
||||||
link.value = graph.value.append("g").selectAll(".topo-line");
|
link.value = graph.value.append("g").selectAll(".topo-line");
|
||||||
@ -132,7 +134,7 @@ function hexGrid(n = 1, radius = 1, origin = [0, 0]) {
|
|||||||
// y = 0 yn = 1
|
// y = 0 yn = 1
|
||||||
for (y; y <= yn; y++) {
|
for (y; y <= yn; y++) {
|
||||||
p = gLayout.axialToPixel(x, y);
|
p = gLayout.axialToPixel(x, y);
|
||||||
pos.push(...p);
|
pos.push(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
@ -159,7 +161,7 @@ function update() {
|
|||||||
const p = {
|
const p = {
|
||||||
hexagonParam: [27, 0.04, 5, 0.04, 0],
|
hexagonParam: [27, 0.04, 5, 0.04, 0],
|
||||||
count: 1,
|
count: 1,
|
||||||
radius: obj.width / 5, // layout hexagons radius
|
radius: 300, // layout hexagons radius
|
||||||
};
|
};
|
||||||
const polygon = createPolygon(p.radius, 6, 0);
|
const polygon = createPolygon(p.radius, 6, 0);
|
||||||
const origin = [0, 0];
|
const origin = [0, 0];
|
||||||
@ -175,13 +177,36 @@ function update() {
|
|||||||
.attr("stroke", "#ccc")
|
.attr("stroke", "#ccc")
|
||||||
.attr("stroke-width", 2)
|
.attr("stroke-width", 2)
|
||||||
.style("fill", "none");
|
.style("fill", "none");
|
||||||
const centers = hexGrid(p.count, 50, origin); // cube centers
|
const centers = hexGrid(p.count, 100, origin); // cube centers
|
||||||
const pos = hexGrid(p.count, 50, [p.radius * 2 + 20.0]); // cube centers
|
const cubeCenters = [];
|
||||||
// console.log(centers);
|
for (let i = 0; i < centers.length; i++) {
|
||||||
const nodeArr = networkProfilingStore.nodes;
|
// const polygon = createPolygon(90, 6, 0);
|
||||||
for (let v = 0; v < 7; v++) {
|
// const vertices: any = []; // a hexagon vertices
|
||||||
const x = origin[0] + centers[v * 2];
|
// for (let v = 0; v < polygon.length; v++) {
|
||||||
const y = origin[1] + centers[v * 2 + 1];
|
// vertices.push([
|
||||||
|
// centers[i][0] + polygon[v][0],
|
||||||
|
// centers[i][1] + polygon[v][1],
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
// const linePath = d3.line();
|
||||||
|
// linePath.curve(d3.curveLinearClosed);
|
||||||
|
// graph.value
|
||||||
|
// .append("path")
|
||||||
|
// .attr("d", linePath(vertices))
|
||||||
|
// .attr("stroke", "#ccc")
|
||||||
|
// .attr("stroke-width", 1)
|
||||||
|
// .style("fill", "none");
|
||||||
|
const c = hexGrid(p.count, 25, centers[i]);
|
||||||
|
cubeCenters.push(...c);
|
||||||
|
}
|
||||||
|
shuffleArray(cubeCenters);
|
||||||
|
const pos = hexGrid(p.count, 30, [p.radius * 2 + 20]); // cube centers
|
||||||
|
const nodeArr = networkProfilingStore.nodes.filter(
|
||||||
|
(d: ProcessNode) => d.serviceInstanceId === selectorStore.currentPod.id
|
||||||
|
);
|
||||||
|
for (let v = 0; v < nodeArr.length; v++) {
|
||||||
|
const x = cubeCenters[v][0];
|
||||||
|
const y = cubeCenters[v][1];
|
||||||
nodeArr[v].x = x;
|
nodeArr[v].x = x;
|
||||||
nodeArr[v].y = y;
|
nodeArr[v].y = y;
|
||||||
}
|
}
|
||||||
@ -200,6 +225,13 @@ function update() {
|
|||||||
).merge(node.value);
|
).merge(node.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shuffleArray(array: number[][]) {
|
||||||
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[array[i], array[j]] = [array[j], array[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleLinkClick(event: any, d: Call) {
|
function handleLinkClick(event: any, d: Call) {
|
||||||
if (
|
if (
|
||||||
d.source.layer !== dashboardStore.layerId ||
|
d.source.layer !== dashboardStore.layerId ||
|
||||||
|
@ -173,7 +173,7 @@ async function fetchTasks() {
|
|||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.profile-task-list {
|
.profile-task-list {
|
||||||
width: 300px;
|
width: 280px;
|
||||||
height: calc(100% - 10px);
|
height: calc(100% - 10px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
|
Loading…
Reference in New Issue
Block a user