# Creating Dynamic Pens in Perspective PowerChart

**URL:** <https://forum.inductiveautomation.com/t/creating-dynamic-pens-in-perspective-powerchart/69060>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 26, 2023, 9:31pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-pens-in-perspective-powerchart/69060 "2023-01-26T21:31:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Czipo](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@Justin\_Czipo](https://forum.inductiveautomation.com/u/Justin_Czipo)\
**Post date:** [January 26, 2023, 9:31pm UTC](https://forum.inductiveautomation.com/t/creating-dynamic-pens-in-perspective-powerchart/69060/1 "2023-01-26T21:31:01Z")

</div>

I am passing a dataset of tags into a view containing a PowerChart component. In the custom view properties, I am taking the dataset and creating the pens dataset. This custom property is then bound to the props.pens of the PowerChart. My pens are trending, however no matter how many pens I select to trend they are all the same color. Below is my script to create the pens dataset:

```auto
def transform(self, value, quality, timestamp):
	import random
	def rgb_to_hex(r, g, b):
		return('{:X}{:X}{:X}').format(r, g, b)
	
	type = 'line'
	interpolation = 'curveLinear'
	breakLine = True
	pens = []	
	for val in value:
		r = random.randint(16,255)
		g = random.randint(16,255)
		b = random.randint(16,255)
		stroke = {"color": rgb_to_hex(r, g, b)}
		normal = {"stroke":stroke}
		styles = {"normal":normal}
		data = {}
		display = {"type":type,"interpolation":interpolation,"breakLine":breakLine,"styles":styles}
		name = val[val.rfind('/')+1:]
		data.update({"source":val,"aggregateMode":'default'})
		pens.append({"display":display,"data":data,"name":name})
	return pens

```
