Hello.
I am learning Perspective, to build dashboards for a factory setting.
I often find myself wanting to create a flex repeater, where the elements in the flex repeater depend on parameters of a view.
Eg, I have a parameterized view which takes in a list of machine names (it is further embedded into a larger dashboard). This view includes a chart of machine performance, as well as some KPIs. These KPI labels are created as a flex repeater. Each KPI label view takes a machine name as an input, and displays the boxed percentage.
However, going from the list of strings I pass into the parameterized view, to the list of objects required in the flex repeater, is a bit of a hassle. Right now, I have the current setup:
The "instances" prop on my flex repeater is bound with the expression
runScript("perspective_functions.list_to_list_of_dicts", 50000,{view.params.machine_names}, "machine_name")
and the associated script is
def list_to_list_of_dicts(list_of_items, key_name) :
out_list = []
for item in list_of_items :
out_list.append({
key_name: item
})
return out_list
However, this feels a bit bulky -- I'm not sure how much to worry about the performance impacts of these scripts (although I've mitigated this somewhat by having them call only rarely -- the machines should be constant over a session)
Is there a clever way I can do this solely within the expression language, without having to resort to scripting?