Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Charts

Compare records with bar, line, treemap and flat gauge charts.

avonni-avonnivisualization-bar avonni-avonnivisualization-line avonni-avonnivisualization-treemap avonni-avonnivisualization-flat-gauge

Overview

Use the Avonni Visualization charts to turn records into a bar, line, treemap or flat gauge chart. Your LWC supplies records and fields; the chart groups and measures those records. Fetch Salesforce data in your LWC before passing it to a chart.

Component
Tag
What it draws

Bar

avonni-avonnivisualization-bar

Bars, columns and pyramids, plain or stacked.

Line

avonni-avonnivisualization-line

Lines, areas, and combos of bars, lines and dots.

Treemap

avonni-avonnivisualization-treemap

Nested rectangles sized by a measure.

Flat Gauge

avonni-avonnivisualization-flat-gauge

One value on a continuous, stepped or tiered track.


Use Case Examples

Example 1: Revenue by region, legend in your own order

Scenario: A sales operations lead wants a treemap of revenue by region. The legend should list the regions in the order the business reads them, West first, Pacific last.

<!-- revenueByRegion.html -->
<template>
    <avonni-avonnivisualization-treemap
        title="Revenue by Region"
        records={records}
        fields={fields}
        group-by={groupBy}
        segment-size={segmentSize}
        legend-order={legendOrder}
        legend-position="bottom"
        show-labels
        show-values
        auto-fit
    ></avonni-avonnivisualization-treemap>
</template>
// revenueByRegion.js
import { LightningElement } from 'lwc';

export default class RevenueByRegion extends LightningElement {
    records = [
        { region: 'West', revenue: 91000 },
        { region: 'Northeast', revenue: 78000 },
        { region: 'Southeast', revenue: 64000 },
        { region: 'Midwest', revenue: 52000 },
        { region: 'Southwest', revenue: 38000 },
        { region: 'Pacific', revenue: 27000 }
    ];

    fields = [
        { name: 'region', type: 'text' },
        { name: 'revenue', type: 'number' }
    ];

    // Each rectangle is a region.
    groupBy = [{ field: 'region' }];

    // Each rectangle's size is the sum of revenue.
    segmentSize = [{ field: 'revenue', measures: 'sum' }];

    // Legend order: West, Midwest, Northeast, Southeast, Southwest, Pacific.
    legendOrder = ['West', 'Midwest', 'Northeast', 'Southeast', 'Southwest', 'Pacific'];
}
A treemap of revenue by region with the legend listing West, Midwest, Northeast, Southeast, Southwest, Pacific.
Item Order sets the legend sequence.

Result: A treemap with one rectangle per region, sized by revenue. The legend under it reads West, Midwest, Northeast, Southeast, Southwest, Pacific, whatever the order of the records or the size of each rectangle. The legend header reads "Revenue-sum": a measure without a label shows in the legend as <field>-<operation>.

Example 2: Pipeline by lead source and stage

Scenario: Show the pipeline amount per lead source, with each bar split by stage.

A stacked horizontal bar chart of pipeline amount per lead source, split by stage.
A stacked bar per lead source, split by stage.

Result: One horizontal bar per lead source, each split into its stages. The bars are sorted alphabetically, not in record order. Hovering a segment shows its amount and its share of the bar. With bar-segments, the legend lists every lead source and stage pair, such as "Email Campaign - Closed Won".

Example 3: Revenue against a target

Scenario: Plot monthly revenue and draw the target as a dashed line.

A line chart of monthly revenue with a dashed target line.
Revenue against a dashed target line.

Result: A line for revenue and a dashed line for the target, with a point on each month. The legend reads "Revenue-sum" and "Target-sum": a measure shows in the legend as its field and its operation joined by a hyphen.

Example 4: Team score against a target

Scenario: Show the average deal score of a team on a gauge from 0 to 100, with the 75 target marked.

A flat gauge from 0 to 100 filled to the average score with a red Target marker at 75.
A flat gauge with a target marker at 75.

Result: A track from 0 to 100 filled up to the average score, 70 with these six records, with a red marker at 75 labeled Target.


Item Order

By default, the chart decides the order of the legend entries. Item Order (legend-order) lets you list the entries yourself, so the same categories always read in the same sequence.

  • Write the entries as they appear in the legend, for example the region names in Example 1.

  • Entries you leave out of the list appear after the listed ones, in their usual order.

  • Entries in the list that match nothing in the chart are ignored.

  • When legend-order is set, legend-reverse-ordering is ignored.

  • The order applies to the legend. It does not move bars, lines, rectangles or colors.

legend-order accepts an array of strings, a JSON array string or a comma separated string. Blank entries are dropped and the others are trimmed.

With this value, the legend lists West, Midwest and Northeast first, then the remaining regions in their usual order.

If you are not sure how a legend entry is spelled, show the legend once without legend-order and copy the labels from it. When a legend entry combines two values, the order list has to use the combined label.


Specifications

The charts do not fire custom events.

Attributes shared by all four charts

Name
Description
Type
Default
Required

auto-fit

If present, the chart fits the size of its container.

Boolean

false

custom-palette

Hex color codes of the chart series, as #RRGGBB or #RRGGBBAA. They are applied in order and repeat once exhausted. Unrecognized values are dropped. When at least one color is left, they take precedence over palette.

String[]

[]

fields

Description of the columns of records. Each field has a name and a type (for example text, number or date), and optionally a label.

Object[]

[]

Yes

legend-order

Order of the legend entries, as the labels appear in the legend. Entries that are not listed follow in their usual order. See Item Order above.

String[]

[]

legend-position

Position of the legend. Valid values include top, left, bottom and right.

String

"right" ("bottom" for the Treemap)

legend-reverse-ordering

If present, the order of the legend is reversed. Ignored when legend-order is set.

Boolean

false

palette

Color palette of the chart. Valid values include aurora, nightfall, wildflowers, sunrise, bluegrass, ocean, heat, dusk, pond, watermelon, fire, water, lake, mineral and extension.

String

"aurora"

records

The data to display in the chart.

Object[]

Yes

show-legend

If present, the legend is displayed.

Boolean

true

show-legend-header

If present, the header of the legend is displayed.

Boolean

true

show-legend-inside-chart-area

If present, the legend is displayed inside the chart area.

Boolean

false

subtitle

Subtitle of the chart.

String

subtitle-font-size

Font size of the subtitle.

String

"12"

title

Title of the chart.

String

title-alignment

Alignment of the title. Valid values include left, center and right.

String

"left"

title-font-size

Font size of the title.

String

"14"

tooltip-show-dimensions

If present, the dimensions of each section are displayed in the tooltip.

Boolean

false

tooltip-show-measures

If present, the values of the measures of each section are displayed in the tooltip.

Boolean

false

tooltip-show-percentage

If present, the percentage of each section is displayed in the tooltip.

Boolean

false

Each chart also accepts trellis, trellis-type, trellis-size-ratio, trellis-show-grid-lines, trellis-flip-labels and charts-per-line to split one chart into a grid of smaller ones. trellis-type accepts horizontal, vertical, matrix and wrap (default horizontal), and charts-per-line defaults to 3.

Bar attributes

avonni-avonnivisualization-bar

Name
Description
Type
Default
Required

axis-mode

How the measures share the axes. Valid values include single-axis, dual-axis and small-multiples.

String

"single-axis"

bar-length

The measure that sets the length of each bar. Each entry has a field and a measures value. Valid measures include sum, count, average, maximum, minimum, unique, median, first and last.

Object[]

[]

Yes

bar-segments

The field used to split each bar into segments.

Object[]

[]

bars

The field that sets the categories, one bar per value. For a date field, add a group such as year, quarter, month, week or day.

Object[]

[]

Yes

hide-x-axis

If present, the horizontal axis is hidden.

Boolean

false

hide-x-title

If present, the title of the horizontal axis is hidden.

Boolean

false

hide-y-axis

If present, the vertical axis is hidden.

Boolean

false

hide-y-title

If present, the title of the vertical axis is hidden.

Boolean

false

normalize-values

If present, stacked bars show each segment as a percentage of its bar instead of its raw value.

Boolean

false

show-values

If present, the value of each bar is displayed.

Boolean

false

type

Type of the chart. Valid values include bar, stacked-bar, column, stacked-column, pyramid and stacked-pyramid.

String

"bar"

use-log-scale

If present, the measure axis uses a logarithmic scale.

Boolean

false

x-title

Title of the horizontal axis.

String

y-title

Title of the vertical axis.

String

Line attributes

avonni-avonnivisualization-line

Name
Description
Type
Default
Required

axis-mode

How the measures share the axes. Valid values include single-axis, dual-axis and small-multiples.

String

"single-axis"

dashed-lines

Lines to draw dashed, as the measure field and its measure joined by a hyphen, for example target-sum.

String[]

[]

fill-area

If present, the area under each line is filled.

Boolean

false

fill-opacity

Opacity of the filled area.

Number

1

hide-x-axis

If present, the horizontal axis is hidden.

Boolean

false

hide-x-title

If present, the title of the horizontal axis is hidden.

Boolean

false

hide-y-axis

If present, the vertical axis is hidden.

Boolean

false

hide-y-title

If present, the title of the vertical axis is hidden.

Boolean

false

lines

The field used to split the data into one line per value. Only one field is used.

Object[]

[]

series

For a combo chart, which measures are drawn as bar, line or dot. An object with a bar, a line and a dot array of measure identifiers such as revenue-sum.

Object

show-measure-title

If present, the title of each measure is displayed. It is hidden when the chart is too small.

Boolean

false

show-points

If present, a point is drawn on each value of a line.

Boolean

false

show-value-as

How the values are printed on the chart. Valid values include none, compact-number and percentage.

String

"none"

show-values-in-chart-bars

If present, the values are printed on the bars of a combo chart.

Boolean

false

show-values-in-chart-lines

If present, the values are printed on the lines.

Boolean

false

type

Type of the chart. Valid values include line, combo, parallel-coordinates and metrics-radar.

String

"line"

use-log-scale

If present, the measure axis uses a logarithmic scale.

Boolean

false

x-axis

The field drawn on the horizontal axis. For a date field, add a group such as month, and displayFullMonthLabel to print full month names.

Object[]

[]

Yes

x-title

Title of the horizontal axis.

String

y-axis

The measures drawn on the vertical axis. Each entry has a field and a measures value.

Object[]

[]

Yes

y-title

Title of the vertical axis.

String

Treemap attributes

avonni-avonnivisualization-treemap

Name
Description
Type
Default
Required

combine-max

When combine-small-groups is present, the maximum percentage an item can have to be combined with the others.

Number

1

combine-small-groups

If present, the items with a low percentage are combined into one.

Boolean

false

group-by

The fields that set the categories of the rectangles. Use two fields to nest rectangles. For a date field, add a group.

Object[]

Yes

segment-size

The measure that sets the size of each rectangle. Each entry has a field and a measures value, and can have a formatStyle and a multiplier.

Object[]

Yes

show-labels

If present, the label of each item is displayed.

Boolean

false

show-percentages

If present, the percentage of each item is displayed.

Boolean

false

show-total

If present, the total is displayed at the top of the treemap.

Boolean

false

show-values

If present, the value of each item is displayed.

Boolean

false

total-font-size

Font size of the total.

String

"auto"

Flat Gauge attributes

avonni-avonnivisualization-flat-gauge

Name
Description
Type
Default
Required

discrete-steps

Number of steps of the track when flat-gauge-type is discrete.

Number

5

flat-gauge-tiers

For a tiered gauge, the colored tiers of the track. Each tier has a percentage and a color.

Object[]

[]

flat-gauge-type

Type of the track. Valid values include continuous, discrete and tiered.

String

"continuous"

max-range

Value at the end of the track.

Number

100

min-range

Value at the start of the track.

Number

0

reference-lines

Markers drawn on the track, for example a target. Each has a label, a value and a color.

Object[]

[]

show-max-range

If present, the maximum value of the track is displayed.

Boolean

false

show-min-range

If present, the minimum value of the track is displayed.

Boolean

false

show-value-as

How the value is printed. Valid values include an empty string, number, compact-number and percentage.

String

"number"

value

The measure displayed by the gauge. Each entry has a field and a measures value.

Object[]

[]

Yes

Last updated

Was this helpful?