Pie chart title from Transform Script

Hello!


    if quality.isGood() and value is not None:

        py_data = system.dataset.toPyDataSet(value)
        
 
        first_month = None
        for row in py_data:
            if first_month is None or row['LOC'] < first_month:
                first_month = row['LOC']
        
        non_zero_count = 0
        zero_count = 0
        
      
        for row in py_data:
            if row['LOC'] == first_month:
                state = row['STATES']
                if state > 0:
                    non_zero_count += 1
                else:
                    zero_count += 1

    
        data = [
            {"label": "Non-Zero Percentage", "value": non_zero_count},
            {"label": "Zero Percentage", "value": zero_count}
        ]        

        title = first_month        
   
        return {"title": title, "data": data}
    else:
 
dictionary
        return {}

image

I would like to pass the title to a pie chart from a transform script...but seem is not working, it goes all together with the data.

Also I would like it to be the value of that LOC

Use system.perspective.sendMessage in your script with
payload = {"title" : title}.

Add a message handler on the chart to listen for the message.
In the message handler script,
self.props.title = payload['title']

1 Like