Skip to content

[nad-viewer] create style and footer for legends generated from metadata#436

Open
CBiasuzzi wants to merge 2 commits into
mainfrom
fix_nad_legend_creation_from_meta_style_footer
Open

[nad-viewer] create style and footer for legends generated from metadata#436
CBiasuzzi wants to merge 2 commits into
mainfrom
fix_nad_legend_creation_from_meta_style_footer

Conversation

@CBiasuzzi

Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?

Fixes #435

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
@sonarqubecloud

Copy link
Copy Markdown

@CBiasuzzi
CBiasuzzi marked this pull request as ready for review July 22, 2026 19:27
y: 0,
};
const busNodes: BusNodeMetadata[] = [busNode(0, '400 kV', 'background:red; fill:red; stroke:black;')];
const legendBox = nadViewer['createLegendBox'](textNode, busNodes, node);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createLegendBox is private. Do we need a public constructor, or is it usual in typescript to test private methods like that ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems it is an acceptable way to test a private method (note also that the very same approach is already used by PR 430 )

Comment on lines +1890 to +1892
node.legendFooter?.forEach((footer) => {
newDivElement.appendChild(this.createTextHeader(footer));
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same thing as for legendHeader a bit above, line 1866
Could we make an helper function for that maybe ? If it's only in two places, maybe not needed, but if it's in other places it would be good.
Also, I think you should put this part just after the legendHeader (and not after the loop on busNodes)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback.

It’s only used in those two places, I think it’s probably not worth extracting a helper for just those two lines that are involved.

Why shouldn’t I put the footer after the loop on the nodes? A footer belongs at the bottom, don't you think?
(see also this example: https://github.com/powsybl/powsybl-diagram/blob/main/network-area-diagram/src/test/resources/custom_label_provider.svg )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[nad-viewer] Voltage level legends not fully created from metadata (style, footer)

2 participants