You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [Plugin API Reference](https://github.com/malloydata/malloy/blob/main/packages/malloy-render/docs/plugin-api-reference.md)
12
+
>>>markdown
13
+
# Using Render Tags
14
+
15
+
When Malloy runs a query, it returns two things. The *results* of the query and *metadata* about the results. The metadata are the schema for the results, including type information. Malloy also provides a mechanism to tag things in the source code and return tags with this meta data.
16
+
17
+
In Malloy, anything that can be named can be tagged. A tag starts with a `#`. Tags that start on a new line attach the tag the thing on the following line. For more details about how tagging works, see the [Tags](../language/tags.malloynb) section.
18
+
19
+
Malloy's rendering library interprets these tags to change how results are rendered.
20
+
21
+
## Tagging individual elements
22
+
In the query below, the measure `percent_of_total` is tagged as a percentage. Any time `percent_of_total` is used in a query, Malloy's rendering library will be displayed as a percentage.
23
+
>>>malloy
24
+
source: flights is duckdb.table('../data/flights.parquet') extend {
25
+
measure:
26
+
flight_count is count()
27
+
# percent
28
+
percent_of_flights is flight_count / all(flight_count)
29
+
}
30
+
>>>malloy
31
+
#(docs) size=small limit=5000
32
+
run: flights -> {
33
+
group_by: carrier
34
+
aggregate:
35
+
flight_count
36
+
percent_of_flights
37
+
}
38
+
>>>malloy
39
+
#(docs) size=small limit=5000
40
+
run: duckdb.table('../data/flights.parquet') -> {
41
+
group_by: carrier
42
+
aggregate: flight_count is count()
43
+
}
44
+
>>>markdown
45
+
46
+
Simply adding `# bar_chart` before the query tags it and tells the rendering library to show the result as a bar chart. See the docs on the [Bar Chart tag](./bar_charts.malloynb) for more information.
Copy file name to clipboardExpand all lines: src/documentation/visualizations/pivots.malloynb
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ Malloy's rederer has flexible and powerful way of pivoting data.
5
5
## Nesting first
6
6
Malloy's ability to nest queries allows you to compute two levels of queries simultaneously. The query below first groups airports by `state` and then groups by the type of facility (`fac_type`). For each state we see count of all the facilities.
0 commit comments