Inserting element inside an auto panel

Hi,

I have a ‘auto’ panel with a boundary defined by a complex geometry shape

I’m programmatically adding an status indicator to this panel (inserting a ‘rectangle’ shape with panel.insertAt after finding the panel using the ‘findObject’ method on the node), and I want to fit it within the boundaries of that outer shape. It’s too complex for me to calculate exactly the boundaries and by default, the rectangle I create overlaps rather than fits within my panel.

What do I need to change to get this behavior. Here’s a quick paint drawing showing what I’m trying to do versus what I have:

It’s probably easiest to use a linear gradient Brush to fill that Shape. Calculate the fraction of the distance from the top to the bottom that you want to fill with green, and use that fraction as the middle color stop.

Example: https://gojs.net/extras/fillingShape.html

Except that you will want to swap the Spots so that the color comes from the top rather than from the bottom.

image