Hi,
I’m working on a widget and code is much smaller when using the oh-context with functions. They work in the separate widget but not when you include the widget on a page in grid layout. Looking at browser console the functions are defined on startup but can’t be found when it’s time to use them. Am I doing something wrong or is this just not possible?
grid layout page
config:
colNum: 8
fixedType: grid
...
blocks: []
grid:
- component: oh-grid-item
config:
...
slots:
default:
- component: widget:lineChart
config:
lineChart widget:
...
slots:
default:
- component: oh-context
config:
constants:
myUnit: "=(props.unit) ? props.unit : (props.average) ?
items[props.average].unit : (props.current) ?
items[props.current].unit : '' "
functions:
axisLow: "=(x) => (x=='W' ? -4000 : x=='°C' ? -100 : x=='%' ? 0 : -10000)"
axisMediumLow: "=(x) => (x=='W' ? 0 : x=='°C' ? 15 : x=='%' ? 20 : 0)"
axisMediumHigh: "=(x) => (x=='W' ? 1000 : x=='°C' ? 25 : x=='%' ? 80 : 1000)"
axisHigh: "=(x) => (x=='W' ? 4000 : x=='°C' ? 100 : x=='%' ? 100 : 10000)"
slots:
default:
- component: oh-chart
...
visualMap:
- component: oh-chart-visualmap
config:
pieces:
- color: rgba(80, 200, 90,0.6)
max: = fn.axisMediumLow(const.myUnit)
min: = fn.axisLow(const.myUnit)
- color: rgba(80,90,200,0.6)
max: = fn.axisMediumHigh(const.myUnit)
min: = fn.axisMediumLow(const.myUnit)
- color: rgba(200, 80, 90,0.6)
max: = fn.axisHigh(const.myUnit)
min: = fn.axisMediumHigh(const.myUnit)
...