Bar chart

Use a bar chart to compare metrics across ranked categories with horizontal bars.

Every preview on this page is generated from the YAML shown below it using a fixed documentation dataset.

Ranked categories

Sort the metric descending to make the longest horizontal bar the leading category. This orientation works well for category labels of unequal length.

Key fields
visuals:
  categories:
    title: Top product categories
    description: Ranks product categories by revenue.
    type: bar
    query:
      type: aggregate
      dimensions:
      - category
      metrics:
      - revenue
      sort:
      - field: revenue
        direction: desc
      limit: 10
    presentation:
      type: cartesian

Stacked series

Use a second ordered dimension for status and presentation.stacking: normal to combine each status segment into one category total while preserving its composition.

Key fields
visuals:
  categories_by_status_bar:
    title: Category revenue by status
    type: bar
    presentation:
      type: cartesian
      stacking: normal
    query:
      type: aggregate
      dimensions:
      - category
      - status
      metrics:
      - revenue
      sort:
      - field: revenue
        direction: desc
      limit: 60

Alternate metric

Keep the bar contract and replace the dimension with delivery buckets to compare counts across an ordered operational grouping.

Key fields
visuals:
  delivery:
    title: Delivery speed
    description: Compares order volume across delivery-speed buckets.
    type: bar
    query:
      type: aggregate
      dimensions:
      - delivery_bucket
      metrics:
      - order_count
      sort:
      - field: delivery_bucket
        direction: asc
    presentation:
      type: cartesian

API reference

Kind: chart. Renderer: echarts. Supported result shapes: category_series_value category_value.

FieldTypeDefaultAllowed valuesDescription
query.dimensionsfield mappingGroups query results and supplies category or hierarchy labels.
query.limitintegerno limitpositive integerCaps the number of rows returned to the renderer.
query.metricsmetric mappingSelects governed semantic metrics consumed by the visual shape.
query.sortsort listOrders query results by a returned field or metric alias.
presentation.stackingstringnonenone normal percentDeclares explicit normal or 100% stacking.

Accessibility. Use a descriptive title and unit, and do not rely on color alone to distinguish series or values.