Welcome to Knowage Q&A, where you can ask questions and receive answers from other members of the community.
0 votes
1 view

In a Custom Chart Widget, I need to get cockpit variables, and also if possible to set cockpit variables.

Can someone give me some hint, (using variablesController or any available attribute/function), to access cockpit variable in javascript from widget,

This is not documented for use in custom widget, but I suppose it's possible, just matter to find the right attributes/functions available in the document window object !

Thanks in advance for suggestions !

Environment Knowage version 7.4.5, with Docker, on macos
in Cockpit, Dashboard and Console by (670 points)
just to be updated...

waiting for help !
Eheh, leave me the time to answer ;)

1 Answer

+1 vote

Dear alalng,

you are right, they are accessible from within the cockpit but the information is a little hidden inside the documentation.
If you search "variables" paragraph in this documentation chapter  you should see how to reach them.

However you can just use the datastore.variables object to get the needed variable value.

Example:
var myCustomValue = datastore.variables.myCustomValue.

Hope it helps.

Regards

Davide

by (11.3k points)
Regarding setting the variables I suggest you this chapter:
https://knowage-suite.readthedocs.io/en/7.4/functionalities-guide/cockpit/index.html?highlight=variables#variables

Variables are not made to be modified during the execution but to be spreadily shared between the same cockpit.

Regards
Thanks a lot @redjaw, for your clear answer !
...