fix: update legend

This commit is contained in:
Qiuxia Fan 2022-02-17 21:07:10 +08:00
parent a1001a1285
commit 7f6d63e669
3 changed files with 14 additions and 6 deletions

View File

@ -133,7 +133,7 @@ async function init() {
svg.value.call(zoom(d3, graph.value));
// legend
legend.value = graph.value.append("g").attr("class", "topo-legend");
topoLegend(legend.value, height.value, width.value);
topoLegend(legend.value, height.value, width.value, settings.value.legend);
svg.value.on("click", (event: any) => {
event.stopPropagation();
event.preventDefault();

View File

@ -236,11 +236,16 @@ async function getMetricList() {
);
}
async function setLegend() {
if (
!(legend.metric.name && legend.metric.value && legend.metric.condidtion)
) {
if (!legend.metric.name) {
return;
}
if (!legend.metric.value) {
return;
}
if (!legend.metric.condition) {
return;
}
updateSettings();
const ids = topologyStore.nodes.map((d: Node) => d.id);
const param = await useQueryTopologyMetrics([legend.metric.name], ids);

View File

@ -19,7 +19,8 @@ import icons from "@/assets/img/icons";
export default function topoLegend(
graph: any,
clientHeight: number,
clientWidth: number
clientWidth: number,
config: any
) {
for (const item of ["CUBE", "CUBEERROR"]) {
graph
@ -37,7 +38,9 @@ export default function topoLegend(
.attr("y", clientHeight - 30)
.text(() => {
return item === "CUBEERROR"
? "Unhealthy (Successful Rate < 95% and Traffic > 1 call/min)"
? config
? `Unhealthy (${config.metric.name} ${config.metric.condition} ${config.metric.value})`
: "Unhealthy"
: "Healthy";
})
.style("fill", "#efeff1")