Trends and Comparisons
Browse these live examples and open Code to inspect their configuration.
Trends and comparisons
Section titled “Trends and comparisons”| Renderer | When to use it | Configure on the column |
|---|---|---|
sparklineRenderer | Show a short series in a compact cell. | numeric array; minValue, maxValue |
comparisonSparklineRenderer | Compare series using a shared vertical scale. | comparisonSparkline |
barChartRenderer | Compare a small sequence of values as bars. | numeric array; minValue, maxValue |
divergingBarsRenderer | Show positive and negative values around a baseline. | divergingBars |
varianceBarRenderer | Show a value relative to a baseline or reference. | varianceBar |
changeRenderer | Show a signed value with a direction indicator. | numeric value; optional thresholds |
changeBarRenderer | Pair a change value with a magnitude bar. | changeBar.format |
metricTrendRenderer | Combine a formatted metric and a sparkline. | metricTrend |
heatmapRenderer | Color a cell according to a numeric scale. | minValue, maxValue, color options |
stripPlotRenderer | Place individual observations on a shared domain. | point array; stripPlot |
splitValueRenderer | Show a value with a separate change or annotation. | splitValue.format |
rankingRenderer | Highlight a position or rank. | ranking.format |
visualCellRenderer | Compose a labeled axis and vertical ranges across columns. | visualCell.format |
The range-and-axis example uses a summary visual for the tick labels and a range visual for each brand. Supply positions in percentages using one shared data domain; the three range values represent the low, median, and high positions. Keep numeric values in the source for sorting and filtering.
Summary charts above a grid
Section titled “Summary charts above a grid”Compose a MetricPanel and MetricTile from @revolist/ui with Pro’s dot histogram and segmented summary. Bind them to visible grid rows, and supply your own aggregation, labels and formatting. Filter the example or edit a cell to update both charts; hover or focus a dot to inspect its value.
import { createMetricPanelElement, createMetricTileElement, releaseMetricElement } from '@revolist/ui/native';import { bindGridSummary, createCompactNumberFormatter, createDotHistogramElement, createSegmentedSummaryElement, releaseSummaryChartElement } from '@revolist/revogrid-pro';import '@revolist/ui/styles.css';import '@revolist/revogrid-pro/styles.css';
const grid = document.querySelector('revo-grid')!; // An initialized grid.const host = document.querySelector('#summary')!;const currency = createCompactNumberFormatter('en-US', { style: 'currency', currency: 'EUR' });let cleanup = () => {};const binding = bindGridSummary<{ revenue: number; screen: string }>(grid, { update(rows) { cleanup(); const values = rows.map(row => Number(row.revenue)).filter(Number.isFinite); const yes = rows.filter(row => row.screen === 'Yes').length; const panel = createMetricPanelElement(document, { label: 'Company overview' }); const tile = createMetricTileElement(document, { label: 'Revenue', value: currency(values.reduce((a, b) => a + b, 0)) }); const histogram = createDotHistogramElement(document, { values, label: 'Revenue distribution', locale: 'en-US', numberFormat: { style: 'currency', currency: 'EUR' }, }); const breakdown = createSegmentedSummaryElement(document, { label: `${yes} of ${rows.length} companies screened`, parts: [ { label: 'Yes', value: yes, color: 'var(--rv-ui-success)' }, { label: 'Other', value: rows.length - yes, color: 'var(--rv-ui-border-strong)' }, ], }); const screen = createMetricTileElement(document, { label: 'Screen', value: `${yes} of ${rows.length}` }); for (const [metric, chart] of [[screen, breakdown], [tile, histogram]]) { const extra = document.createElement('dd'); extra.className = 'rv-metric-tile__extra'; extra.append(chart); metric.append(extra); panel.querySelector('.rv-metric-panel')!.append(metric); } host.replaceChildren(panel); cleanup = () => { releaseSummaryChartElement(breakdown); releaseSummaryChartElement(histogram); releaseMetricElement(screen); releaseMetricElement(tile); releaseMetricElement(panel); }; },});// On unmount: binding.destroy(); cleanup();The binding follows source changes, edits, sorting and filters on the chosen row source. For a programmatic mutation that does not emit a grid event, call await binding.refresh(). Destroy the binding when the view is removed. Histogram axis labels use compact locale-aware formatting by default; pass formatValue for custom labels.
Labeled diverging scorecards
Section titled “Labeled diverging scorecards”Set divergingBars.scale to an asymmetric domain and provide localized tick labels to show grid lines and a labeled zero baseline. highlightIndex emphasizes a particular bar, with separate colors for positive and negative values. Set text to a callback returning a localized summary for rows that should not draw a chart; return undefined for ordinary chart rows. Set the grid row height to fit the scale.
const column = { prop: 'monthlyGap', cellTemplate: divergingBarsRenderer, divergingBars: { label: 'Monthly gap to target', highlightIndex: 11, scale: { min: -2, max: 1, ticks: [ { value: 1, label: '+1' }, { value: 0, label: '0' }, { value: -1, label: '-1' }, { value: -2, label: '-2' }, ], }, text: (_value, row) => (row.metAllMonths ? 'Met all 12 months' : undefined), },};