diff --git a/public/app/plugins/panel/icon/IconPanel.tsx b/public/app/plugins/panel/icon/IconPanel.tsx index 7e4cced6a90..896a99e65e8 100644 --- a/public/app/plugins/panel/icon/IconPanel.tsx +++ b/public/app/plugins/panel/icon/IconPanel.tsx @@ -27,11 +27,26 @@ export class IconPanel extends Component { initElement = (props: Props) => { this.element = new ElementState(iconItem, props.options.root as any); - this.element.updateSize(props.width, props.height); + this.updateSize(props); this.element.updateData(this.dims); return this.element; }; + updateSize = (props: Props) => { + const { width, height } = props; + this.element.anchor = { + top: true, + left: true, + }; + this.element.placement = { + left: 0, + top: 0, + width, + height, + }; + this.element.updateSize(width, height); + }; + dims: DimensionContext = { getColor: (color: ColorDimensionConfig) => getColorDimensionFromData(this.props.data, color), getScale: (scale: ScaleDimensionConfig) => getScaleDimensionFromData(this.props.data, scale), @@ -44,7 +59,7 @@ export class IconPanel extends Component { let changed = false; if (width !== nextProps.width || height !== nextProps.height) { - this.element.updateSize(nextProps.width, nextProps.height); + this.updateSize(nextProps); changed = true; } if (data !== nextProps.data) {