Skip to content

Trends and Comparisons

Browse these live examples and open Code to inspect their configuration.

RendererWhen to use itConfigure on the column
sparklineRendererShow a short series in a compact cell.numeric array; minValue, maxValue
comparisonSparklineRendererCompare series using a shared vertical scale.comparisonSparkline
barChartRendererCompare a small sequence of values as bars.numeric array; minValue, maxValue
divergingBarsRendererShow positive and negative values around a baseline.divergingBars
varianceBarRendererShow a value relative to a baseline or reference.varianceBar
changeRendererShow a signed value with a direction indicator.numeric value; optional thresholds
changeBarRendererPair a change value with a magnitude bar.changeBar.format
metricTrendRendererCombine a formatted metric and a sparkline.metricTrend
heatmapRendererColor a cell according to a numeric scale.minValue, maxValue, color options
stripPlotRendererPlace individual observations on a shared domain.point array; stripPlot
splitValueRendererShow a value with a separate change or annotation.splitValue.format
rankingRendererHighlight a position or rank.ranking.format
visualCellRendererCompose 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.

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.

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),
},
};