Code Cells: Observable JS
Observable JS is a set of enhancements to vanilla JavaScript created by Mike Bostock (also the author of D3). Observable JS is distinguished by its reactive runtime, which is especially well suited for interactive data exploration and analysis.
Learn more about using Observable JS with Quarto in the articles on Interactive Documents with Observable JS.
Overview
Cell options affect the execution and output of executable code blocks. They are specified within comments at the top of a block. For example:
```{ojs}
//| label: fig-polar
//| echo: false
//| fig-cap: "A line plot on a polar axis"
```
Attributes
label |
Unique label for code cell. Used when other code needs to refer to the cell (e.g. for cross references |
classes |
Classes to apply to cell container |
Code Output
eval |
Evaluate code cells (if
|
echo |
Include cell source code in rendered output.
|
code-fold |
Collapse code into an HTML
|
code-summary |
Summary text to use for code blocks collapsed using |
code-overflow |
Choose how to handle code overflow, when code lines are too wide for their container. One of:
|
code-line-numbers |
Include line numbers in code block output ( For revealjs output only, you can also specify a string to highlight specific lines (and/or animate between sets of highlighted lines).
|
lst-label |
Unique label for code listing (used in cross references) |
lst-cap |
Caption for code listing |
Cell Output
output |
Include the results of executing the code in the output. Possible values:
|
warning |
Include warnings in rendered output. |
error |
Include errors in the output (note that this implies that errors executing code will not halt processing of the document). |
include |
Catch all for preventing any output (code or results) from being included in output. |
panel |
Panel type for cell output ( |
output-location |
Location of output relative to the code that generated it. The possible values are as follows:
Note that this option is supported only for the |
Figures
fig-cap |
Figure caption |
fig-subcap |
Figure subcaptions |
fig-link |
Hyperlink target for the figure |
fig-align |
Figure horizontal alignment ( |
fig-alt |
Alternative text to be used in the |
fig-env |
LaTeX environment for figure output |
fig-pos |
LaTeX figure position arrangement to be used in Computational figure output that is accompanied by the code that produced it is given a default value of If |
fig-scap |
A short caption (only used in LaTeX output). A short caption is inserted in |
Tables
tbl-cap |
Table caption |
tbl-subcap |
Table subcaptions |
html-table-processing |
If |
Panel Layout
layout |
2d-array of widths where the first dimension specifies columns and the second rows. For example, to layout the first two output blocks side-by-side on the top with the third block spanning the full width below, use Use negative values to create margin. For example, to create space between the output blocks in the top row of the previous example, use |
layout-ncol |
Layout output blocks into columns |
layout-nrow |
Layout output blocks into rows |
layout-align |
Horizontal alignment for layout content ( |
layout-valign |
Vertical alignment for layout content ( |
Page Columns
column |
Page column for output |
fig-column |
Page column for figure output |
tbl-column |
Page column for table output |
cap-location |
Where to place figure and table captions ( |
fig-cap-location |
Where to place figure captions ( |
tbl-cap-location |
Where to place table captions ( |