Set static variable in essql

Hi everyone,

i have this query:

I would like to set in my plot defaultStyle{...}... the axisConfig max=10 the max value from a variable as the number from VALUE variable from query.
The 10 must not be static, it is possible?


Currently, expressions do not have a concept of "variables" built into the grammar. Each function passes its output (context) to the next function in the expression, but there isn't a way to set a "global" variable within an expression.

There also isn't yet a way to deal with context that needs to be accessed by another function later in the expression. So in your example, there is no way for the plot function to access a value from the context returned by the essql function, because the only context it receives is the output of pointseries. We've been discussing ways this could potentially be resolved in the future.

In the meantime, you could try looking at the context returned from pointseries to see if the value you need is already contained there:

essql query="SELECT foo, bar FROM baz"
| pointseries x=foo y=bar
| render as=debug

If the debug shows you the value you need, you may be able to extract it as a subexpression using the getCell function, since pointseries returns a datatable. For example, if you needed to set max to be the first row returned in the x column, you could do something like this:

essql query="SELECT foo, bar FROM baz"
| pointseries x=foo y=bar
| plot yaxis={axisConfig position=left max={getCell column=x row=0}}

Thx lekeelmers,

i tried it next time.

Can i create Doubles Bars in one Barchart, like one Bars is live Value and the other AVG Value bar. Like this screenshot: Blue is live Value and RED is AVG value of one sensor

I don't think there's a way to accomplish what you are looking for with double bars showing different values, but you might be able to do stacked bars depending on the shape of your data. See this thread for more details: Canvas: how to make stacked area chart?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.