Skip to content

Show and hide parts of an SVG #23

Answered by ZuperZee
Flipparen asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @Flipparen.

I've made a repo that hides the SVG element when the value is 1.

Datasource used https://grafana.com/grafana/plugins/marcusolsson-static-datasource/

Here's a simplified version:

HTML/SVG

<svg viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
  <rect id="orange-rectangle" x="69" y="162" width="181" height="175" fill="#f80"/>
  <rect id="blue-rectangle" x="250" y="162" width="181" height="175" fill="#08f"/>
</svg>

onRender

const getMetricByName = (alias) => {
  const filteredAliasSeries = data.series.filter((series) => series.name == alias);
  if (filteredAliasSeries.length > 0) {
    return filteredAliasSeries[0].fields[1].state.calcs.last;
  }
  return

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Flipparen
Comment options

@ZuperZee
Comment options

@Flipparen
Comment options

Answer selected by ZuperZee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants