# Legend in Paraview Glance

**URL:** https://discourse.paraview.org/t/legend-in-paraview-glance/6714
**Category:** Web Support
**Created:** [March 16, 2021, 12:59pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714 "2021-03-16T12:59:24Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![devngc](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devngc/32/5514_2.png) [@devngc](https://discourse.paraview.org/u/devngc)
#### Post date: [March 16, 2021, 12:59pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/1 "2021-03-16T12:59:24Z")

</div>

Hi,

Is it possible to add a legend in Paraview-glance for some scalar already applied to poly data?

---

<div class="post-metadata">

### Author: ![Forrest\_Li](https://discourse.paraview.org/user_avatar/discourse.paraview.org/forrest_li/32/1935_2.png) [@Forrest\_Li](https://discourse.paraview.org/u/Forrest_Li)
#### Post date: [March 17, 2021, 7:05pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/2 "2021-03-17T19:05:58Z")

</div>

Hi, are you referring to a colorbar legend, like in ParaView? If so, that should be a reasonable addition, since we already generate a colorbar in the sidebar.

---

<div class="post-metadata">

### Author: ![devngc](https://discourse.paraview.org/user_avatar/discourse.paraview.org/devngc/32/5514_2.png) [@devngc](https://discourse.paraview.org/u/devngc)
#### Post date: [March 18, 2021, 5:27am UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/3 "2021-03-18T05:27:55Z")

</div>

Yes a colorbar legend. Yes, I am aware that there’s a legend in the sidebar but I wish if had a legend in the model space so that when one captures the model, the legend is captured with it. I believe, this is something that the whole user community will appreciate.

---

<div class="post-metadata">

### Author: ![dsanfra](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dsanfra/32/6650_2.png) [@dsanfra](https://discourse.paraview.org/u/dsanfra)
#### Post date: [June 13, 2021, 2:15am UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/4 "2021-06-13T02:15:31Z")

</div>

It would be a great feature!! +1 👍

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [June 15, 2021, 4:45pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/5 "2021-06-15T16:45:31Z")

</div>

vtk.js now support that as well, so it will be a matter to add that property to the GeometryRepresentation and expose it via proxy api and glance ui.

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [December 21, 2022, 10:54pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/6 "2022-12-21T22:54:50Z")

</div>

> [@jourdain](#):
>
> GeometryRepresentation

Hi @jourdain has there been any update on this ? I have been trying to add the vtkScalarBarActor to my glance application. Not sure how to go about it. Does it have something to do with **GeometryRepresentation** you mentioned ? Kindly shed more light.

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [December 30, 2022, 4:57pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/7 "2022-12-30T16:57:49Z")

</div>

@Forrest_Li should know more on that subject. But probably yes. The current **GeometryRepresentation** is not offering scalar bar. But on the other hand, it might be better to handle it at the application level / server manager.

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [December 30, 2022, 8:17pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/8 "2022-12-30T20:17:34Z")

</div>

Thank you @jourdain. @Forrest_Li any idea on how this could be achieved at the application level / server manager ? I was able to achieve this in vanilla.js, however, not quite sure on how to proceed in glance.

 ![vtkScalarBarActor](https://discourse.paraview.org/uploads/default/original/2X/6/6e55ad7c2c7b0ec003c3f4c3f9b0534dd62f8301.png)

---

<div class="post-metadata">

### Author: ![Forrest\_Li](https://discourse.paraview.org/user_avatar/discourse.paraview.org/forrest_li/32/1935_2.png) [@Forrest\_Li](https://discourse.paraview.org/u/Forrest_Li)
#### Post date: [January 11, 2023, 4:18pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/9 "2023-01-11T16:18:49Z")

</div>

The sure-fire way is to extend GeometryRepresentation. If you do it at the application level, you’ll need to create a scalar bar actor and add it to all of the relevant renderers.

For extending GeometryRepresentation, I would look at [this custom SliceRepresentation](https://github.com/Kitware/glance/blob/master/src/vtk/CustomSliceRepresentationProxy/index.js) implementation. For your use-case, a custom GeometryRepresentation could look like the following:

```auto
function vtkCustomGeometryRepresentation(publicAPI, model) {
  const scalarBarActor = vtkScalarBarActor.newInstance();
  model.actors.push(scalarBarActor);

  const lut = mapper.getLookupTable();
  scalarBarActor.setScalarsToColors(lut);
}

```

You will also need to update instances of GeometryRepresentationProxy in [proxy.js](https://github.com/Kitware/glance/blob/master/src/config/proxy.js) to use your custom GeometryRepresentationProxy.

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [January 11, 2023, 7:31pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/10 "2023-01-11T19:31:13Z")

</div>

> [@Forrest\_Li](#):
>
> `vtkCustomGeometryRepresentation`

Thank you @Forrest_Li. I tried the above (GeometryRepresentation), without the desired result. I think this works similar to the `setOrientationAxesVisibility` method. However there is no method definition for `setOrientationAxesVisibility` which references `[[FunctionLocation]] : OrientationMarkerWidget.js:142`  
as shown in the image

 ![setOrientationAxesVisibility](https://discourse.paraview.org/uploads/default/original/2X/8/83c637fb59ff48a794c70d196618935ade1a0861.png)  
I think there is a missing piece to the puzzle (I could be wrong though).

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [January 11, 2023, 7:33pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/11 "2023-01-11T19:33:16Z")

</div>

Simply put, I would like to know how `setOrientationAxesVisibility` references the method in line 42 of `OrientationMarkerWidget`. I think this would solve my problem

---

<div class="post-metadata">

### Author: ![Forrest\_Li](https://discourse.paraview.org/user_avatar/discourse.paraview.org/forrest_li/32/1935_2.png) [@Forrest\_Li](https://discourse.paraview.org/u/Forrest_Li)
#### Post date: [January 17, 2023, 3:13pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/12 "2023-01-17T15:13:23Z")

</div>

`setOrientationAxesVisibility` calls `setEnabled(...)` in OrientationMarkerWidget. The mapping occurs here: [vtk-js/index.js at a59102e09454fe10b962975c524a7e09f2bef2eb · Kitware/vtk-js · GitHub](https://github.com/Kitware/vtk-js/blob/a59102e09454fe10b962975c524a7e09f2bef2eb/Sources/Proxy/Core/ViewProxy/index.js#L657)

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [January 30, 2023, 12:59am UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/13 "2023-01-30T00:59:04Z")

</div>

> [@Forrest\_Li](#):
>
> `setOrientationAxesVisibility`

Thank you @Forrest_Li , any idea how this `setOrientationAxesVisibility ` method was implemented? I know we are using closures here, but can’t quite pin down where this method was defined. The mapping you provided only references `orientationAxesVisibility ` not `setOrientationAxesVisibility `.

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [January 30, 2023, 1:06am UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/14 "2023-01-30T01:06:43Z")

</div>

How would i update this instace of GR. I created the Custom GR as you suggested. This is what I have from the file `src/config/proxy.js`

 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/35ca87efa025a4c3633fe6f2b51de1cd7a628388.png)  
Also this is what my custom GR looks like.  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/b/bd89caa2c8c5d161ad21e29a810a0321e6b6b0a9.png)

---

<div class="post-metadata">

### Author: ![Forrest\_Li](https://discourse.paraview.org/user_avatar/discourse.paraview.org/forrest_li/32/1935_2.png) [@Forrest\_Li](https://discourse.paraview.org/u/Forrest_Li)
#### Post date: [January 30, 2023, 3:46pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/15 "2023-01-30T15:46:11Z")

</div>

That mapping auto-generates `setOrientationAxesVisibility` and `getOrientationAxesVisibility`. Based on the mapping definition, it will map the function `setOrientationAxeVisibility` to the function `orientationWidget.setEnabled`.

---

<div class="post-metadata">

### Author: ![Forrest\_Li](https://discourse.paraview.org/user_avatar/discourse.paraview.org/forrest_li/32/1935_2.png) [@Forrest\_Li](https://discourse.paraview.org/u/Forrest_Li)
#### Post date: [January 30, 2023, 3:50pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/16 "2023-01-30T15:50:08Z")

</div>

`vtkScalarBarRepresentationProxy.extend(publicAPI, model)` won’t work. You want to extend `GeometryRepresentationProxy` via `GeometryRepresentationProxy.extend(publicAPI, model)`.

In order to use it, you will need to change the Geometry representation to use your custom one instead of creating a new representation. I would name it `vtkScalarBarGeometryRepresentationProxy`.

```auto
Geometry: createProxyDefinition(vtkScalarBarGeometryRepresentationProxy, proxyUI.Geometry, proxyLinks.Geometry)

```

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [February 1, 2023, 5:35pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/17 "2023-02-01T17:35:42Z")

</div>

> [@Forrest\_Li](#):
>
> vtkScalarBarGeometryRepresentationProxy

Thank you so much @Forrest_Li. I did manage to get it done today.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/b/b864ea109f59adf10e55c3ca42782661aa47852d.png)

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [February 1, 2023, 5:40pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/18 "2023-02-01T17:40:50Z")

</div>

@Forrest_Li If you don’t mind, I am also trying to implement CellPicker functionality on the attached image. However I get the follwing error  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/1/19874fd6012ad6b0efcfed7e01f102fdd2bca103.png)  
at this section of the code.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/a/af8435429a8c9d3b6b8b5e6954ddbfa9d9989294.png)  
A closer look at the `pick` function shows this info  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/b/bac0303ab1adeaa9718c019dd6fb02720c518e55.png)  
Perhaps this error has something to do with the definition of this `pick` function.  
It is pertinent to know that I am extending the ViewProxy.js class

---

<div class="post-metadata">

### Author: ![Forrest\_Li](https://discourse.paraview.org/user_avatar/discourse.paraview.org/forrest_li/32/1935_2.png) [@Forrest\_Li](https://discourse.paraview.org/u/Forrest_Li)
#### Post date: [February 3, 2023, 3:50pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/19 "2023-02-03T15:50:50Z")

</div>

Not sure how the picker picked something that results in undefined. I would recommend using the pick list and only adding the actors you care about picking there.

---

<div class="post-metadata">

### Author: ![ezesiza](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ezesiza/32/10611_2.png) [@ezesiza](https://discourse.paraview.org/u/ezesiza)
#### Post date: [February 3, 2023, 4:00pm UTC](https://discourse.paraview.org/t/legend-in-paraview-glance/6714/20 "2023-02-03T16:00:20Z")

</div>

Thanks @Forrest_Li I have resolved this with the right actors as suggest. However, I can’t seem to see the sphere when I right click. Could it be that I am extending the wrong class ? I created a gist of the files I am working on at this link [Implementing CellPicker functionality in Paraview Glance · GitHub](https://gist.github.com/ezesiza/0de634cf70106ecd25cae4a604789ae2).

[Next page](https://discourse.paraview.org/t/legend-in-paraview-glance/6714.md?page=2)
