User interface programming / Web components |
Web components are usually complex widgets displaying detailed information, such as charts, graphs, or calendars. Such widgets are generally resizeable. Therefore, the WEBCOMPONENT form item must be large and stretchable.
<meta name='viewport' content='initial-scale=1.0, maximum-scale=1.0' />
LAYOUT GRID { <GROUP g1 > [f1 ][f2 ] [f3 ] ... < > [f5 ] [ ] [ ] [ ] } END
In the ATTRIBUTES section, use the SIZEPOLICY, SCROLLBARS and STRETCH attributes, to define the sizing policy of a web component field:
WEBCOMPONENT f5 = FORMONLY.mymap, SIZEPOLICY = FIXED, STRETCH = BOTH;
By default, the WEBCOMPONENT widget gets the size of the form item (like SIZEPOLICY=FIXED). When SIZEPOLICY=INITIAL, the web component is scaled to the right size after the first webpage is loaded and stays at that size. When SIZEPOLICY=DYNAMIC, the web component is resized after each load of a new webpage so that no scrollbars should appear.
LAYOUT STACK GROUP (TEXT="Chart example") COMBOBOX FORMONLY.chart_type, NOT NULL, INITIALIZER=chart_type_init; WEBCOMPONENT FORMONLY.chart, COMPONENTTYPE = "chartjs", STYLE="regular"; END END END
By default, the WEBCOMPONENT widget size will adapt to the content of the web component: It will stretch vertically to the appropriate size, in order to show the complete web component content.
To limit the size of the WEBCOMPONENT widget, you can use the HEIGHT attribute in the form definition:
WEBCOMPONENT FORMONLY.chart, HEIGHT = 5, -- 5 lines ...
<body> <canvas id="myChart" height="100px" />