The Canvas expression

Behind each element or component you use in the interface, there is a Canvas expression that defines how that component is constructed. If we take the donut chart we just created and click on the Expression editor button, we will see the expression syntax behind our element:

Notice that the expression is composed of multiple layers, separated by the | character, which chains functions together, just like Linux/Unix. Let's decompose it to understand how the expression syntax works:

  • On the top, the opening function is filterswhich collects element filters on the workpad, usually to provide them to a data source. An example element filter on the workpad is a time picker.
  • The demodata function is the data source that's used in the pie chart. Again, because we haven't hooked up the element to any real data yet, the element defaults to using demo data. By the way, if you were remove the entire subsequent expression after demodata and click the Run button, you would get a data table of the raw demo data. You can then put it back if you did indeed remove it. 
  • The pointseries function prepares the data so that it can be passed to a charting element.
  • The pie function uses the pointseries to build a pie chart (again, a pie with a hole is a donut).
  • Finally, the render function renders the entire expression.

Not only is the expression automatically generated for you as you build your workpad with the UI, but you can also directly write your own. We will see how to do that later on in this chapter.

The full documentation for Canvas can be found at https://www.elastic.co/guide/en/kibana/current/canvas.html.

Also, notice that, within the expression, there are attributes for some of the functions:

filters
| demodata
| pointseries color="state" size="max(price)"
| pie hole=25 labels=true legend=false
| render

These attributes directly correspond to the options that are set using the UI controls. So, for example, if the Inner radius control is changed to 50, the value of the hole property in the expression would follow suit. Likewise, if you manually edited the value of hole in the expression, the value on the slider control would change as well (but only when you click the Run button). In other words, the expression and the UI controls are meant to be in sync.

We will now see how Canvas' UI elements and expressions will allow us to build a custom view from information in the ML results index.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.135.67