I´m trying to generate dinamically Pie Charts with a Flex repeater based on number of months I want to see.
one example of wanted result not generated dinamically:
To do so, I´ve got my Flex repeater with the path to a Pie chart
I binded my named Query with a transform on the instances of the Flexbox
def transform(self, value, quality, timestamp):
if quality.isGood() and value is not None:
py_data = system.dataset.toPyDataSet(value)
unique_months = sorted(set(row['LOC'] for row in py_data))
all_data = []
for month in unique_months:
count_zero = 0
count_one = 0
for row in py_data:
if row['LOC'] == month:
state = row['STATES']
if state == 0:
count_zero += 1
elif state == 1:
count_one += 1
data = [
{"label": "Zero Value States", "value": count_zero},
{"label": "One Value States", "value": count_one}
]
all_data.append({"data": data})
return all_data
else:
return []
wich works fine
Now I´m not sure how to bind the Pie View to this instances to see the result