Skip to main content

Page visualization components

Overview

Page visualization components are custom tags an admin embeds in a page's content to build dashboards and entity views.

Authoring syntax

A page stores raw content as HTML. Components appear as XML-style tags, such as <BarChart property="country" />. Every attribute value arrives as a string, so boolean values use "true" or "false" and structured values use JSON strings.

Two tags declare data without rendering anything: <Dataset> and <Query>. All other tags render UI that reads from a declared dataset by name.

A component's property attribute takes the property's internal name, not its display label. Uwazi forms the internal name by replacing each non-alphanumeric character in the label with an underscore and lower-casing the result. The label Select group becomes select_group.

A few legacy components use brace syntax, such as {media}(url), instead of an XML tag. Brace syntax doesn't rely on Markdown formatting, so it keeps working on HTML pages. The catalogue marks each legacy component.

Data declaration tags

These tags fetch data and render nothing. Other components read their results by name.

Dataset

<Dataset> declares a library search. Uwazi stores the result under name and forces limit to 0, so the result holds aggregations rather than full rows.

AttributeRequiredDefaultDescription
nameNodefaultKey that other components reference.
urlNoLibrary URL with a rison-encoded q parameter.
entityNoA sharedId that fetches one entity instead of a search.
geolocationNofalseA truthy value fetches geolocation rows for <Map>.

The url and entity attributes are mutually exclusive.

A bare <Dataset /> with no url fetches aggregations for every property across all published entities. It adds allAggregations automatically. A url query doesn't, so a custom query needs allAggregations:!t to feed the charts.

A bare <Dataset /> excludes unpublished entities. To aggregate drafts, add includeUnpublished:!t to the query, as in url="/library/?q=(allAggregations:!t,includeUnpublished:!t)". Unpublished entities never appear to anonymous visitors, whatever the query holds.

Examples:

<Dataset />
<Dataset url="a-valid-libray-url" name="dataset1" />
<Dataset entity="entityId" name="entityDataset" />
<Dataset name="dataset2" geolocation="true" />

Query

<Query> declares a call to any internal API endpoint and stores the raw response under name.

AttributeRequiredDefaultDescription
nameNodefaultKey that holds the response.
urlYesAny API endpoint path.

Example:

<Query url="users?_id=23234324" name="customQuery" />

Chart components

These components render charts. <BarChart>, <PieChart>, and <ListChart> read an aggregation from a dataset. <FreeBarChart> reads inline JSON instead.

Each aggregation chart reads a dataset declared on the same HTML page. When the dataset attribute is absent, the chart reads the dataset named default. The chart shows the loading animation until that dataset exists and resolves.

For the aggregation charts, the property names a metadata property, or a built-in aggregation. _types groups entities by template, so its bucket keys are template IDs. _published groups entities by their published state, with the keys true and false. These built-in keys also work in <Counter>. They don't apply to <FreeBarChart>, <Map>, <Value>, or <GaugeChart>, which read inline JSON, rows, or metadata instead of aggregations.

BarChart

<BarChart> renders an aggregation as a bar chart. The default render shows vertical bars in a single colour #1e1c8a, with category labels on the axis and a tooltip on hover.

A bar chart showing entity counts by category as vertical bars.
BarChart visualization
PropRequiredDefaultDescription
propertyYesThesaurus or select property to aggregate on, given as its lowercase internal name.
datasetNodefaultName of a declared dataset to read from; defaults to the dataset named default.
contextNoSystemThesaurus context ID for label lookup.
layoutNohorizontalBar orientation. horizontal (default) draws vertical bars; vertical draws horizontal bars. The value names the axis, not the bars.
colorsNo#1e1c8aComma-separated hex colours, cycled across bars.
classnameNoCSS class added to the wrapper.
excludeZeroNofalseA value of true hides zero-count buckets.
scatterNofalseA value of true renders nested values as parent - label.
maxCategoriesNo0Top-N count of categories to show, where 0 shows all.
aggregateOthersNofalseA value of true bundles the remaining categories into one "Others" bar.
shortLabelsNo{}JSON object mapping original labels to short display labels.
sortNo{}JSON object with by and order keys.
pluckCategoriesNo[]JSON array of labels to keep.

Example:

<Dataset
url="/library/?q=(allAggregations:!t,filters:(),from:0,includeUnpublished:!t,limit:1000,order:desc,sort:editDate,treatAs:number,types:!(%27685a1qw3erf45tghy50d4c69%27),unpublished:!t)"
name="dataset1"
/>
<BarChart
property="cetegories"
dataset="dataset1"
context="669w34rf56t5635ba73d11ca"
/>

The shortLabels object maps each full category label to a shorter label shown on the axis. The keys are the category labels as they appear on the chart. The tooltip shows the full label on hover.

<BarChart
property="measures"
context="58ada3er45te8267485450fb"
shortLabels='{"Provisional measures":"PM","Friendly settlements":"FS"}'
/>

PieChart

<PieChart> renders an aggregation as a pie or doughnut chart. The default render shows a solid pie in a yellow palette starting at #ffcc00, with a tooltip on hover and no slice labels.

A pie chart showing entity counts by category as coloured slices.
PieChart visualization
PropRequiredDefaultDescription
propertyYesThesaurus or select property to aggregate on, given as its lowercase internal name.
datasetNodefaultName of a declared dataset to read from; defaults to the dataset named default.
contextNoSystemThesaurus context ID for label lookup.
colorsNo#ffcc00,#ffd633,#ffe066,#ffeb99,#fff5ccComma-separated hex colours, cycled across slices.
classnameNoCSS class added to the wrapper.
innerRadiusNo0Donut hole radius in pixels, where 0 is a solid pie.
outerRadiusNo105Outer radius in pixels.
showLabelNofalseA value of true shows percentage labels and hides the tooltip.
scatterNofalseA value of true renders nested values as parent - label.
maxCategoriesNo0Top-N count of slices to show, where 0 shows all.
aggregateOthersNofalseA value of true bundles the remaining slices into one "Others" slice.
pluckCategoriesNo[]JSON array of labels to keep.

<PieChart> always excludes zero-count slices. It has no attribute to change this.

Example:

<Dataset
url="/library/?q=(allAggregations:!t,filters:(),from:0,includeUnpublished:!t,limit:1000,order:desc,sort:editDate,treatAs:number,types:!(%2769b85a47501qwe34rfa61372%27),unpublished:!t)"
name="dataset2"
/>
<PieChart
property="gender"
dataset="dataset2"
context="66ec1f9a01a01qw23er491802"
/>

ListChart

<ListChart> renders an aggregation as a styled bullet list. The default render shows a vertical list with a coloured square and a count beside each label.

A vertical list of categories, each with a coloured marker and its count.
ListChart visualization
PropRequiredDefaultDescription
propertyYesThesaurus or select property to aggregate on, given as its lowercase internal name.
datasetNodefaultName of a declared dataset to read from; defaults to the dataset named default.
contextNoSystemThesaurus context ID for label lookup.
colorsNo#ffcc00,#ffd633,#ffe066,#ffeb99,#fff5ccComma-separated hex colours, cycled across items.
classnameNoCSS class added to the wrapper.
excludeZeroNofalseA value of true hides zero-count items.
scatterNofalseA value of true renders nested values as parent - label.
baseUrlNoLibrary URL that turns each item into a filtered link.

Example:

<Dataset
url="/library/?q=(allAggregations:!t,filters:(),from:0,includeUnpublished:!t,limit:1000,order:desc,sort:editDate,treatAs:number,types:!(%27685a1qw1qw23er4ghy50d4c69%27),unpublished:!t)"
name="dataset1"
/>
<ListChart
property="selectgroup"
dataset="dataset1"
context="66ddfr416e5535ba73d11ca"
/>

FreeBarChart

<FreeBarChart> renders a bar chart from arbitrary JSON rather than a dataset aggregation. The default render shows vertical bars in a single colour #1e1c8a.

A bar chart showing arbitrary data as vertical bars.
FreeBarChart visualization
PropRequiredDefaultDescription
dataNoJSON array of data objects, each with a label and one or more value keys.
dataKeysNoresultsWhich value key to plot. A key name, or a JSON array of {key: button label} objects to toggle between keys.
colorsNo#1e1c8aComma-separated hex colours, cycled across bars.
classnameNoCSS class added to the wrapper.
layoutNohorizontalBar orientation. horizontal (default) draws vertical bars; vertical draws horizontal bars. The value names the axis, not the bars.
childrenNoContent rendered above the chart.

Each data object can carry several value keys beside its label. dataKeys selects which one to plot. Pass a JSON array of {key: button label} objects to plot several keys: the chart adds a toggle button per key, and selecting one switches the plotted key. The buttons appear only when the array has two or more entries.

Example:

<FreeBarChart
data='[{"label":"col1","results":3,"otherProp":5},{"label":"col2","results":4,"otherProp":2},{"label":"col3","results":6,"otherProp":2}]'
dataKeys='[{"results":"Results"},{"otherProp":"Other values"}]'
/>

This plots results by default and adds two toggle buttons, "Results" and "Other values". Selecting "Other values" re-plots the chart from the otherProp key.

Geolocation components

Map

<Map> plots entity locations from a geolocation dataset. The default render shows a map at zoom level 6, with markers and clusters for the entities that have coordinates.

A map with clustered markers for entities that have coordinates.
Map visualization
PropRequiredDefaultDescription
datasetNodefaultName of a declared geolocation dataset; defaults to the dataset named default.
classnameNoCSS class added to the wrapper.
zoomNo6Initial zoom level.
scrollZoomNoA value of true enables zooming with the scroll wheel.
showControlsNoA value of true shows the zoom controls.

A map dataset needs the geolocation attribute set to true. A bare geolocation dataset plots every published entity that has coordinates.

Example:

<Dataset
name="places"
geolocation="true"
url="ibrary/?q=(allAggregations:!t,filters:(),from:0,includeUnpublished:!t,limit:30,order:desc,sort:creationDate,treatAs:number,types:!(%2766a11652we34rfc325b8b353%27),unpublished:!t)"
/>

<map dataset="places" zoom="7" showControls="true" />

Single-value components

These components each render a single value. <Counter> and <Value> render it as inline text and show - until the value resolves. <GaugeChart> renders it as a semicircular gauge.

Counter

<Counter> renders a single aggregation count.

A single count of matching entities rendered as inline text.
Counter visualization
PropRequiredDefaultDescription
propertyNoProperty to aggregate on, given as its lowercase internal name; absent, the count uses value.
datasetNodefaultName of a declared dataset to read from; defaults to the dataset named default.
valueNoAggregation key of the option to count, such as a thesaurus value ID or a template ID rather than its label; comma-separated keys are summed.
uniqueValuesNoA value of true counts distinct non-zero buckets.

The property also accepts the built-in _types and _published aggregations, described under Charts.

Example:

<Dataset
url="/library/?q=(allAggregations:!t,filters:(),from:0,includeUnpublished:!t,limit:1000,order:desc,sort:editDate,treatAs:number,types:!(%27685a83ec533b834af50d4c69%27),unpublished:!t)"
name="dataset1"
/>

Number of entities:
<Counter
dataset="dataset1"
property="_types"
value="685a83ec533b834af50sderf4"
/>

Value

<Value> renders one metadata value or one value from the page context.

A single metadata value rendered as inline text.
Value visualization
PropRequiredDefaultDescription
propertyNoMetadata property to read from the named dataset, given as its lowercase internal name.
datasetNodefaultName of a declared dataset to read from when property is set; defaults to default.
pathNoDot path into the page context value when property is absent.

<Value> has two modes. The property mode reads a numeric value from a specific entity. The path mode reads any value from the page context.

In property mode, declare the dataset with the entity attribute. The value comes back as a number, so this mode doesn't render text values.

Example:

<Dataset entity="cvfxsqj93u" name="country" /> Country:
<Value path="country.title" />

In path mode, the dot path starts from one of the page context roots. The entityRaw, entity, entityData, and template roots exist only on an entity view page. A dataset declared by name is a root on any page.

RootHolds
entityRawThe entity as stored, before formatting.
entityThe formatted entity, with metadata keyed by property name and a value and label.
entityDataA processed view, with formatted metadata and inherited relationships.
templateThe entity's template.
Dataset nameAny dataset declared on the page, such as an entity dataset read through path.

A dataset-name root continues into that dataset's data. Root fields sit on the dataset. Metadata uses the property's internal name as its key and holds an array of value objects, so the path indexes into it.

Examples:

<Dataset entity="a1b2c3d4" name="cases" />

<Value path="cases.title" />
<Value path="cases.creationDate" />
<Value path="cases.metadata.type.0.value" />
<Value path="cases.metadata.type.0.displayValue" />
<Value path="entityRaw.title" />
<Value path="entity.metadata.type.value" />
<Value path="template.properties.4.label" />

GaugeChart

<GaugeChart> renders a single numeric metadata value as a semicircular gauge. The default render shows a half circle with a #000099 fill on a grey #ccc track, the value text in the centre, and a height of 110 pixels.

A semicircular gauge showing a single numeric value as text in the centre.
GaugeChart visualization
PropRequiredDefaultDescription
propertyYesNumeric metadata property to read the gauge value from, given as its lowercase internal name.
maxNo100Maximum scale value, applied when the attribute is absent or non-numeric.
heightNo110Gauge height in pixels, applied when the attribute is absent or non-numeric.
datasetNoDataset to read the metadata value from.
classnameNoCSS class added to the wrapper.
colorsNo#000099,#cccTwo comma-separated colours for the fill and the track.
childrenNoCentre text of the gauge; a child value component receives the dataset and property and renders the number between any prefix and suffix text.

<GaugeChart> reads the first value of the property from the single entity loaded into the named dataset. Declare the dataset with the entity attribute, since a search dataset carries no entity metadata.

Example:

<Dataset entity="f4lwed4e5qs" name="cases" />

<GaugeChart dataset="cases" property="some_number" max="100">
<Value />%
</GaugeChart>

The <Value /> child receives the gauge's dataset and property, so the centre text reads as the value between the prefix and suffix, such as Progress 64%.

Entity view components

These components read the entity currently in view. They render on entity view pages.

EntityData

<EntityData> renders the value or translated label of one property of the entity in view. The default render shows inline text.

PropRequiredDefaultDescription
value-ofConditionalProperty whose value renders.
label-ofConditionalProperty whose translated label renders.

Each tag needs exactly one of value-of or label-of. The root values for value-of are title, creationDate, and editDate; all other names resolve from entity metadata.

Examples:

<EntityData value-of="title" />
<EntityData value-of="creationDate" />
<EntityData value-of="Main Image" />
<EntityData label-of="title" />

EntitySection

<EntitySection> renders its children only when a query against the entity's metadata matches. The default render shows the children or nothing.

PropRequiredDefaultDescription
show-ifYesJSON sift.js query applied to the entity metadata.
childrenYesContent rendered when the query matches.

Examples:

<EntitySection show-if='{ "title": { "$exists": true }}'>...</EntitySection>
<EntitySection
show-if='{ "metadata.description": { "$eq": "A long description" }}'
>...</EntitySection
>
<EntitySection show-if='{ "metadata.inherited_text": { "$in": ["something"] }}'
>...</EntitySection
>

Repeat

<Repeat> renders its children once per item in an array from the page context. Each iteration sets the item as the new context.

PropRequiredDefaultDescription
pathYesDot path to the array in the current page context.
childrenYesContent repeated for each item.

Example:

<Repeat path="entityRaw.metadata.pa_s">
<li className="custom-list"><Value path="label" /></li>
</Repeat>

<EntityLink> wraps its children in a link to the entity in the current page context. It renders inside a <Repeat> block.

PropRequiredDefaultDescription
childrenNoLink label content.

Example:

<EntityLink>View case</EntityLink>

EntityInfo

<EntityInfo> renders a clickable element that opens the entity detail side panel in the library.

PropRequiredDefaultDescription
entityNoThe sharedId of the entity to open.
tagNodivHTML element type to render.
classnameNoCSS class added to the element.
childrenNoContent inside the element.

Example:

<EntityInfo entity="abc123" tag="span">Open case</EntityInfo>

ItemList

<ItemList> renders a list of entity cards. An admin authors it with the legacy {list}(url)(options) brace syntax rather than an XML tag. The brace syntax works on HTML pages.

A list of entity cards linking to entities in the library.
ItemList rendering
OptionDefaultDescription
limit6Maximum number of items to fetch.
sliderA truthy value wraps the items in a carousel of three at a time.

Example:

{list}(https://<yourdomain
>/en/library/?q=(allAggregations:!f,filters:(),from:0,includeUnpublished:!t,limit:30,order:desc,sort:creationDate,treatAs:number,types:!(%2766a1165fw3edfr5t25b8b353%27),unpublished:!f))</yourdomain
>

<SearchBox> renders a search input that submits to the library. The default render shows a single text input.

A single-line search input that submits to the library.
SearchBox rendering
PropRequiredDefaultDescription
placeholderNoPlaceholder text in the input.
classnameNoCSS class added to the wrapper.

Example:

<SearchBox placeholder="Search the collection" />

ContactForm

<ContactForm> renders a public contact form that posts to the contact endpoint. The default render shows name, email, message, and captcha fields. It accepts no author-facing attributes.

A contact form with name, email, message, and captcha fields.
ContactForm rendering

Example:

<ContactForm />

PublicForm

<PublicForm> renders a public entity submission form for one template.

A public submission form with fields for one entity template.
PublicForm rendering
PropRequiredDefaultDescription
templateYesTemplate _id the form submits to.
fileNoThe attribute's presence adds a PDF upload field.
attachmentsNoThe attribute's presence adds an attachments field.
remoteNoThe attribute's presence uses remote captcha verification.

Example:

<PublicForm template="544d7de00d342523edfr4568" file attachments />

MarkdownMedia

<MarkdownMedia> renders a video or audio player with optional time links. An admin authors it with the legacy {media}, {vimeo}, or {youtube} brace syntax rather than an XML tag. The brace syntax works on HTML pages.

A media player with playback controls for an embedded video.
MarkdownMedia player rendering
PropRequiredDefaultDescription
configYesThe (url, jsonOptions) string parsed for the URL and time links.
compactNofalseA value of true sets the player height to fill its container.

Example:

youtube}(https://www.youtube.com/watch?v=K8yRxMLSFQA)

Slideshow

<Slideshow> renders an image gallery from its child elements. The default render shows one slide at a time with auto-play on and navigation arrows off.

An image gallery showing one slide at a time.
Slideshow rendering
PropRequiredDefaultDescription
childrenYesChild elements, each rendered as a slide.
autoPlayNotrueAutoplay flag, on by default; see the note on turning it off.
showNavNofalseShows the previous and next arrows when set.
showFullscreenButtonNofalseShows the full-screen button when set.
showPlayButtonNofalseShows the play and pause button when set.
classnameNoCSS class added to the gallery.

The four boolean flags pass to the gallery without conversion. Any non-empty value, including false, enables a flag. An empty value, such as autoPlay="", or an omitted attribute disables it. Because autoPlay defaults to on, autoPlay="" is the only way to stop auto-play.

Every child node becomes a slide, including white-space. Place the image tags with no spaces or newlines between them, or the gaps render as blank slides.

Example:

<Slideshow showNav="true" autoPlay=""
><img src="/api/files/image-1.jpg" /><img src="/api/files/image-2.jpg" /><img
src="/api/files/image-3.jpg"
/></Slideshow>

<Link> renders a navigation link to an internal path or external URL.

A navigation link rendered as clickable text.
Link rendering
PropRequiredDefaultDescription
toYesDestination path or URL.
childrenNoLink content.

Example:

<Link to="/library">Browse the library</Link>

Icon

<Icon> renders a FontAwesome icon.

The fontawosme icon users rendered inline.
Icon rendering
PropRequiredDefaultDescription
iconYesFontAwesome icon name.

Example:

<Icon icon="users" />

Dataset query reference

Each visualization component reads from a dataset through one key. The key sets the data shape the component expects.

ComponentReadsReturns
MaprowsEntity rows for map markers.
BarChart, PieChart, ListChartaggregationsBuckets for the named property.
CounteraggregationsA single count over the named bucket keys.
Value, GaugeChartmetadataOne numeric metadata value.

A <Counter> with value="id1,id2" sums the counts of both buckets. Missing keys add 0.

A missing dataset returns an undefined value. Charts and the map show a loading spinner, and <Counter> and <Value> show -.

Runtime updates

Page JavaScript updates an existing dataset at runtime through window.updatePageDatasets. It only updates datasets already declared in the content, and ignores unknown names.

window.updatePageDatasets('default', {
rows: [],
totalRows: 292,
aggregations: { all: { tipo: { buckets: [] } } },
});

Dynamic property interpolation

Entity view pages support ${...} expressions in the raw content. Uwazi replaces each expression before it renders the page.

PatternResolves to
${entity.title}The entity title.
${entity.sharedId}The entity shared ID.
${entity.metadata.prop}The first value of the property.
${entity.metadata.prop.value}The first value of the property.
${entity.metadata.prop.displayValue}The first display value of the property.
${entity.metadata.prop[N].displayValue}The display value at index N.
${template.name}The template name.
${template.properties.N.label}The label of the property at index N.

Uwazi leaves an unresolvable expression in place and reports it in the page errors.

Errors and edge cases

The table lists the conditions that affect how components render.

ConditionResult
Dataset is missing or still loadingCharts and the map show a spinner; <Counter> and <Value> show -.
Dataset matches only unpublished entities for an anonymous visitorThe aggregation is empty, so a chart renders no bars.
<EntityData> sets both value-of and label-ofThe component renders nothing and logs an error.
<EntityData> sets neither attributeThe component renders nothing and logs an error.
<EntityData value-of> names a property that does not existThe component renders nothing and logs an error.
<EntitySection show-if> holds invalid JSONThe component renders nothing and logs an error.
<PublicForm template> names a template that does not existThe component fails with "The template is not valid".
An unsupported tag appears in admin contentUwazi renders an "Invalid tag" error block.
A ${...} expression cannot resolveUwazi keeps the text in place and reports a page error.
warning

Component errors appear only to signed-in admins and editors, never to public visitors, so a broken component on a public page stays silent.