Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/documentation/visualizations/bar_charts.malloynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Malloy can create simple bar charts and bar charts with series breakdowns, eithe
| `.series` | Field for grouping/coloring | `# bar_chart { series=category }` |
| `.series.limit` | Max series shown (default: 20) | `# bar_chart { series.limit=5 }` |
| `.series.independent` | Independent series colors in nested charts | `# bar_chart { series.independent }` |
| `.horizontal` | Render bars horizontally (categories on y-axis) | `# bar_chart { horizontal }` |
| `.title` | Chart title | `# bar_chart { title='My Title' }` |
| `.subtitle` | Chart subtitle | `# bar_chart { subtitle='Details' }` |

Expand Down Expand Up @@ -137,6 +138,55 @@ run: flights -> {
}
>>>markdown

## Horizontal Bar Charts

Use the `horizontal` property to render bars left-to-right instead of bottom-to-top. Categories appear on the y-axis and values on the x-axis:
>>>malloy
#(docs) size=large limit=5000
# bar_chart { horizontal }
run: flights -> {
group_by: carriers.nickname
aggregate: flight_count
}
>>>markdown
Horizontal mode works with series breakdowns:
>>>malloy
#(docs) size=large limit=5000
# bar_chart { horizontal }
run: flights -> {
where: destination ? 'SFO' | 'OAK' | 'SJC'
group_by: carriers.nickname, destination
aggregate: flight_count
}
>>>markdown
And with stacked bars:
>>>malloy
#(docs) size=large limit=5000
# bar_chart.stack { horizontal }
run: flights -> {
where: destination ? 'SFO' | 'OAK' | 'SJC'
group_by: carriers.nickname, destination
aggregate: flight_count
}
>>>markdown

## Hidden Dimensions

Use `# hidden` on a dimension to exclude it from the chart's automatic channel assignment (x-axis, series) while keeping it in the query data. This is useful when you want to include a dimension for `order_by` without rendering it on the chart:
>>>malloy
#(docs) size=large limit=5000
# bar_chart
run: flights -> {
group_by:
# hidden
carrier
carriers.nickname
aggregate: flight_count
order_by: carrier
}
>>>markdown
The `carrier` code is used to control sort order, but only `nickname` appears on the chart. A hidden field with an explicit channel tag (e.g., `# hidden # x`) will still be assigned to that channel.

## Nested Bar Charts
Bar charts can be used inside of nested queries:
>>>malloy
Expand Down
17 changes: 17 additions & 0 deletions src/documentation/visualizations/charts_line_chart.malloynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ run: flights -> {
}
>>>markdown

## Hidden Dimensions

Use `# hidden` on a dimension to exclude it from automatic channel assignment while keeping it in the query data. This lets you include a dimension for `order_by` or other purposes without it appearing as an axis or series on the chart:
>>>malloy
#(docs) size=large limit=5000
# line_chart
run: flights -> {
group_by:
# hidden
dep_month is dep_time.month
departure_month is dep_time.month::string
aggregate: flight_count
order_by: dep_month
}
>>>markdown
A hidden field with an explicit channel tag (e.g., `# hidden # x`) will still be assigned to that channel.

## Line Charts nested in tables

When line charts are nested in tables the size is reduced. Nested line charts increase the density of information provided by the result.
Expand Down
Loading
Loading