Skip to content

Commit

Permalink
HPCC-30759 Invalid DOT Syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Nov 22, 2023
1 parent 6240f56 commit efcd81c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions esp/src/src-react/util/metricGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ function decodeID(id: string): string {
return id.replace(/__(\d+)__/gm, (_match, p1) => String.fromCharCode(+p1));
}

function encodeLabel(label: string) {
return label
.split('"')
.join('\\"')
.split("\n")
.join("\\n")
;
}

export interface IScope {
__parentName?: string;
__children?: IScope[];
Expand Down Expand Up @@ -226,7 +235,7 @@ export class MetricGraph extends Graph2<IScope, IScopeEdge, IScope> {
}

vertexTpl(v: IScope, options: MetricsOptions): string {
return `"${v.id}" [id="${encodeID(v.name)}" label="${this.vertexLabel(v, options)}" shape="${shape(v.Kind)}" class="${this.vertexStatus(v)}"]`;
return `"${v.id}" [id="${encodeID(v.name)}" label="${encodeLabel(this.vertexLabel(v, options))}" shape="${shape(v.Kind)}" class="${this.vertexStatus(v)}"]`;
}

protected _dedupEdges: { [scopeName: string]: boolean } = {};
Expand Down Expand Up @@ -263,7 +272,7 @@ export class MetricGraph extends Graph2<IScope, IScopeEdge, IScope> {
if (options.ignoreGlobalStoreOutEdges && this.vertex(this._activityIndex[e.IdSource]).Kind === "22") {
return "";
}
return `"${e.IdSource}" -> "${e.IdTarget}" [id="${encodeID(e.name)}" label="${format(options.edgeTpl, { ...e, ...e.__formattedProps })}" style="${this.vertexParent(this._activityIndex[e.IdSource]) === this.vertexParent(this._activityIndex[e.IdTarget]) ? "solid" : "dashed"}" class="${this.edgeStatus(e)}"]`;
return `"${e.IdSource}" -> "${e.IdTarget}" [id="${encodeID(e.name)}" label="${encodeLabel(format(options.edgeTpl, { ...e, ...e.__formattedProps }))}" style="${this.vertexParent(this._activityIndex[e.IdSource]) === this.vertexParent(this._activityIndex[e.IdTarget]) ? "solid" : "dashed"}" class="${this.edgeStatus(e)}"]`;
}

subgraphStatus(sg: IScope): ScopeStatus {
Expand Down Expand Up @@ -294,7 +303,7 @@ subgraph cluster_${encodeID(sg.id)} {
fillcolor="white";
style="filled";
id="${encodeID(sg.name)}";
label="${format(options.subgraphTpl, sg)}";
label="${encodeLabel(format(options.subgraphTpl, sg))}";
class="${this.subgraphStatus(sg)}";
${childTpls.join("\n")}
Expand Down

0 comments on commit efcd81c

Please sign in to comment.