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:
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