I am having problems trying to trigger a data source through a button event to load different data to a chart.how to reference the time chart component and fill it according to the button clicked
It's not clear what your "Week" button is supposed to do. If the Configure Script Action screen grab is the button event then it just runs the same query every time.
What are you hoping it will do?
Shouldn't the query be modified with a parameter?
Instead of getting and setting the data from the button, you can bind the chart's data to the named query, set it not poll, and use the button instead to refresh the chart's data binding (chart.refreshBinding('props.data')
). Not always what you want, but sounds like it's what you might be after here. Not sure why you're getting the variable error though.. Can you paste the actual error with full context?
Hi.
Each button should update the graph with a different query, per day, per week and per month,
they are two tables with completely different structures, that's why I don't use the parameter, I will use it when filtering the 4 options that I have on the left side.
Hi.
the button actually goes in the top menu, I have the structure defined as shown on the left side, i check the documentation:
https://docs.inductiveautomation.com/display/DOC81/Perspective+Component+Methods
this is the error that I get:
line 3, in runAction NameError: global name variable is not defined ignition
I will try to do what you said
Oh, so you just typed that self.getSibling
part, you didn't use the property selector to select it? If the chart and button components are in different views, then you can't get object references to the other. You'll need to send a message to the other view using system.perspective.sendMessage
, and have a message handler on a component in your other view to then modify the chart
Both are inside the same view but in different containers
In the screen grab you posted it shows them in the same container. Now you're saying that they are in different containers. The same code will not work in both structures.
Show the actual structure and code that is producing this error, and if you didn't use the property selector to get the correct path to the component, do that.
I refer to the FlexContainers, in the same way I could already make the change, now I will only configure a script that receives a parameter and can update the graph.
def runAction(self, event):
self.view.getChild("root/CenterFlexContent/FlexContainer_1/MainTimeSeriesChart").props.title.text = 'Weekly OEE'
data = system.db.runNamedQuery("WeekOEE")
self.view.getChild("root/CenterFlexContent/FlexContainer_1/MainTimeSeriesChart").props.series[0].data = data
Tank you.
When posting code, select the code and use the </> button to format it. Hit the pencil icon below your post and try it out.
I’m sorry, but this doesn’t make any since to me.
Is this script that you provided also resulting in an error? If so what is the full error trace?
No, this script works fine.