# Dynamically Change Chart Size In Vision

**URL:** <https://forum.inductiveautomation.com/t/dynamically-change-chart-size-in-vision/103661>\
**Category:** Ignition\
**Tags:** scripting, ignition81, vision\
**Created:** [March 13, 2025, 8:33pm UTC](https://forum.inductiveautomation.com/t/dynamically-change-chart-size-in-vision/103661 "2025-03-13T20:33:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Burger\_King](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@Burger\_King](https://forum.inductiveautomation.com/u/Burger_King)\
**Post date:** [March 13, 2025, 8:33pm UTC](https://forum.inductiveautomation.com/t/dynamically-change-chart-size-in-vision/103661/1 "2025-03-13T20:33:29Z")

</div>

Hello, I am trying to use a button click event to change the size of a chart. I am trying to figure out what I am doing wrong.

```python
window = system.gui.getParentWindow(event)
chart = window.getRootContainer().getComponent('chart')

if chart is None:
	print 'chart was not found'
else:
	#button text
	buttonText = event.source.text
	
	if buttonText == 'Increase Chart Size':
		print 'chart is small. making it large'
		#large
		newX = 8
		newY = 8
		newWidth = 1106
		newHeight = 568
		
		event.source.text = 'Decrease Chart Size'
	else:
		print 'chart is large. making it small'
		#small
		newX = 548
		newY = 105
		newWidth = 566
		newHeight = 471
		event.source.text = 'Increase Chart Size'
	
	
	
	chart.setSize(newWidth, newHeight)
	chart.setLocation(newX, newY)
	chart.repaint()
	print 'done'

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 13, 2025, 8:51pm UTC](https://forum.inductiveautomation.com/t/dynamically-change-chart-size-in-vision/103661/2 "2025-03-13T20:51:26Z")

</div>

You are trying to directly use Swing methods without taking into account what Swing does with Look & Feel implementations.

TL/DR: Use `system.gui.transform()`.

---

<div class="post-metadata">

**Author:** ![Burger\_King](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@Burger\_King](https://forum.inductiveautomation.com/u/Burger_King)\
**Post date:** [March 17, 2025, 3:23pm UTC](https://forum.inductiveautomation.com/t/dynamically-change-chart-size-in-vision/103661/3 "2025-03-17T15:23:11Z")

</div>

I have a chart in vision that I am trying to make larger by using a button click. When the button is clicked I want to change the charts size and position. It does work, but when the button is clicked again, I want the chart to return to its original size and position. This is where the problem lies. I cannot get the chart to return to is original position every time. The original position of the chart is on the right side but if vision is full screen then instead of the chart returning to the right side, it is in the middle. I have placed the script that I am using in the button click below. Please let me know what I can do to get the chart to return to its original position.

```python
window = system.gui.getParentWindow(event)
chart = window.getRootContainer().getComponent('chart')

buttonText = event.source.text

if buttonText == 'Increase Chart Size':
	#large
	x = 8
	y = 8
	width = 1106
	height = 568
	event.source.text = 'Decrease Chart Size'
else:
	#small
	x = 548
	y = 105
	width = 566
	height = 471
	event.source.text = 'Increase Chart Size'
system.gui.transform(component=chart, newWidth=width, newHeight=height, newX = x, newY = y)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 17, 2025, 3:29pm UTC](https://forum.inductiveautomation.com/t/dynamically-change-chart-size-in-vision/103661/4 "2025-03-17T15:29:54Z")

</div>

@Burger_King this topic is closely related enough to the original I just merged the thread.

Try specifying the "coord space" argument in your `system.gui.transform` call - you want to use the coordinate system from the designer with your hardcoded positions.

---

<div class="post-metadata">

**Author:** ![Burger\_King](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@Burger\_King](https://forum.inductiveautomation.com/u/Burger_King)\
**Post date:** [March 17, 2025, 4:10pm UTC](https://forum.inductiveautomation.com/t/dynamically-change-chart-size-in-vision/103661/5 "2025-03-17T16:10:56Z")

</div>

Thanks a lot. This worked for me.

```python
system.gui.transform(component=chart, newWidth=width, newHeight=height, newX = x, newY = y, coordspace=1)

```
