Chart and Visualization Features
RevoGrid supports a variety of visual renderers and chart types, enabling users to present data in visually engaging and intuitive formats. Below is a description of each available feature:
Chart Configuration API
Each chart type supports the following common configuration options:
interface ChartConfig { name: string; // Column name prop: string; // Data property name minValue?: number; // Minimum value for normalization maxValue?: number; // Maximum value for normalization thresholds?: { // Visual thresholds for value ranges value: number | string | boolean; // Threshold value className: string; // CSS class for styling }[];}
Progress Line Renderer
Displays a horizontal progress bar within a cell to visually represent a value’s progression relative to a maximum limit. Useful for showing percentages or task completion statuses.
Configuration
{ name: 'Linear', prop: 'num', minValue: 0, maxValue: 100, thresholds: [ { value: 90, className: 'high' }, { value: 50, className: 'medium' }, { value: 0, className: 'low' } ], cellTemplate: progressLineRenderer}
Progress Line with Value Renderer
Combines the progress line visualization with a numerical value label, offering both a visual and textual representation of the data.
Configuration
{ name: 'Linear with Value', prop: 'num', minValue: 0, maxValue: 40, thresholds: [ { value: 90, className: 'high' }, { value: 30, className: 'medium' }, { value: 0, className: 'low' } ], cellTemplate: progressLineWithValueRenderer}
Sparkline Renderer
Renders mini inline charts directly within cells to display trends or patterns in data over time, ideal for quick overviews of performance metrics.
Configuration
{ name: 'Sparkline', prop: 'trend', minValue: 0, maxValue: 100, cellTemplate: sparklineRenderer}
Bar Chart Renderer
Generates horizontal or vertical bar charts inside cells to compare values across categories, making it perfect for categorical or segmented data.
Configuration
{ name: 'Bars', prop: 'trend', minValue: 0, maxValue: 100, cellTemplate: barChartRenderer}
Timeline Renderer
Visualizes timelines within cells, enabling users to see task durations or event periods in an intuitive linear format.
Configuration
{ name: 'Timeline', prop: 'timeline', timelineRange: { start: 0, end: 100 }, cellTemplate: timelineRenderer}
Rating Star Renderer
Renders star icons to represent ratings, making it ideal for reviews or score-based data.
Configuration
{ name: 'Rating', prop: 'rating', maxStars: 5, cellTemplate: ratingStarRenderer}
Badge Renderer
Displays badges with customizable colors and text to highlight categorical or status-based data.
Configuration
{ name: 'Badge', prop: 'status', badgeStyles: { Active: { backgroundColor: '#008620', color: '#fff' }, Pending: { backgroundColor: '#ff9800', color: '#fff' }, Completed: { backgroundColor: '#0068ba', color: '#fff' }, Failed: { backgroundColor: '#f44336', color: '#fff' } }, cellTemplate: badgeRenderer}
Change Renderer
Highlights changes in data with visual cues such as arrows or color-coded indicators, helping users track trends or differences over time.
Configuration
{ name: 'Change', prop: 'num', cellTemplate: changeRenderer}
Thumbs Renderer
Displays thumbs-up or thumbs-down icons to indicate approvals, votes, or boolean-like states in a simple and user-friendly format.
Configuration
{ name: 'Thumbs', prop: 'thumbs', cellTemplate: thumbsRenderer}
Pie Chart Renderer
Renders pie charts inside cells to display proportional data distribution, ideal for visualizing parts of a whole within a dataset.
Configuration
{ name: 'Pie', prop: 'trend', cellTemplate: pieChartRenderer}
Source code
Source code
import { defineCustomElements } from '@revolist/revogrid/loader';import { columnWithCharts } from './columns';import { currentTheme } from '../composables/useRandomData';import { makeCharts } from '../composables/makeData';
defineCustomElements();
const { isDark } = currentTheme();
export function load(parentSelector: string, type: keyof typeof columnWithCharts) { const grid = document.createElement('revo-grid'); grid.className = 'rounded-lg overflow-hidden'; grid.range = true; grid.source = makeCharts(100);
grid.columns = [columnWithCharts[type]];
grid.plugins = []; grid.additionalData = { stretch: 'all', }; grid.theme = isDark() ? 'darkCompact' : 'compact'; grid.hideAttribution = true; document.querySelector(parentSelector)?.appendChild(grid);}
<template> <VGrid :key="type" class="rounded-lg overflow-hidden" range :theme="isDark ? 'darkCompact' : 'compact'" :columns="columns" :source="rows" hide-attribution :additionalData="additionalData" :plugins="plugins" resize /></template>
<script setup lang="ts">import { ref, type PropType } from 'vue';import { currentThemeVue } from '../composables/useRandomData';import { type ColumnRegular, type DataType, VGrid } from '@revolist/vue3-datagrid';import { ColumnStretchPlugin,} from '@revolist/revogrid-pro';
import { columnWithCharts } from './columns';const { isDark } = currentThemeVue();
const props = defineProps({ rows: { type: Array as PropType<DataType[]>, default: () => [], required: false }, type: { type: String as PropType<keyof typeof columnWithCharts>, default: 'Linear' as keyof typeof columnWithCharts, required: false, },});
const columns = ref<ColumnRegular[]>([ columnWithCharts[props.type],]);
const plugins = [ColumnStretchPlugin];const additionalData = { stretch: 'all',};
</script>
import { useState, useMemo, useRef } from 'react';import { RevoGrid, type DataType, type ColumnRegular } from '@revolist/react-datagrid';import { currentTheme } from '../composables/useRandomData';import { makeCharts } from '../composables/makeData';import { columnWithCharts } from './columns';import React from 'react';
const { isDark } = currentTheme();
const Charts = ({ type = 'Linear' }) => { const gridRef = useRef<HTMLRevoGridElement>(null); const [source] = useState<DataType[]>(makeCharts(100));
const columns: ColumnRegular[] = useMemo( () => [columnWithCharts[type]], [] );
const theme = isDark() ? 'darkCompact' : 'compact';
return ( <RevoGrid ref={gridRef} className="rounded-lg overflow-hidden" range columns={columns} source={source} hide-attribution theme={theme} resize /> );}
export default Charts;
// @ts-ignoreimport { Component, ViewEncapsulation, Input } from '@angular/core';import { RevoGrid } from '@revolist/angular-datagrid';import { columnWithCharts } from './columns';import { currentTheme } from '../composables/useRandomData';import { makeCharts } from '../composables/makeData';
@Component({ selector: 'charts-grid', standalone: true, imports: [RevoGrid], template: ` <revo-grid class="rounded-lg overflow-hidden" [range]="true" [theme]="theme" [columns]="columns" [source]="rows" [hideAttribution]="true" [resize]="true" style="height: 400px; width: 800px" ></revo-grid> `, encapsulation: ViewEncapsulation.None,})export class ChartsGridComponent { @Input() type: keyof typeof columnWithCharts = 'Linear'; // Default to 'Linear' theme = currentTheme().isDark() ? 'darkCompact' : 'compact';
columns = [ columnWithCharts[this.type], ];
rows = makeCharts(100);}
import type { ColumnRegular } from '@revolist/revogrid';import { badgeRenderer, barChartRenderer, progressLineRenderer, progressLineWithValueRenderer, ratingStarRenderer, sparklineRenderer, timelineRenderer, changeRenderer, thumbsRenderer, pieChartRenderer,} from '@revolist/revogrid-pro';
export const columnWithCharts: Record< 'Linear' | 'LinearWithValue' | 'Sparkline' | 'Bars' | 'Timeline' | 'Rating' | 'Badge' | 'Change' | 'Thumbs' | 'Pie', ColumnRegular> = { Linear: { name: 'Linear', prop: 'num', minValue: 0, maxValue: 100, thresholds: [ { value: 90, className: 'high' }, { value: 50, className: 'medium' }, { value: 0, className: 'low' }, ], cellTemplate: progressLineRenderer, },
LinearWithValue: { name: 'Linear with Value', prop: 'num', minValue: 0, maxValue: 40, thresholds: [ { value: 90, className: 'high' }, { value: 30, className: 'medium' }, { value: 0, className: 'low' }, ], cellTemplate: progressLineWithValueRenderer, },
Sparkline: { name: 'Sparkline', prop: 'trend', minValue: 0, // Optional: Provide min value for normalization maxValue: 100, // Optional: Provide max value for normalization cellTemplate: sparklineRenderer, },
Bars: { name: 'Bars', prop: 'trend', minValue: 0, // Optional: Provide min value for normalization maxValue: 100, // Optional: Provide max value for normalization cellTemplate: barChartRenderer, }, Timeline: { name: 'Timeline', prop: 'timeline', cellTemplate: timelineRenderer, timelineRange: { start: 0, end: 100 }, // Define the total timeline range }, Rating: { name: 'Rating', prop: 'rating', cellTemplate: ratingStarRenderer, maxStars: 5, }, Badge: { name: 'Badge', prop: 'status', cellTemplate: badgeRenderer, badgeStyles: { Active: { backgroundColor: '#008620', color: '#fff' }, Pending: { backgroundColor: '#ff9800', color: '#fff' }, Completed: { backgroundColor: '#0068ba', color: '#fff' }, Failed: { backgroundColor: '#f44336', color: '#fff' }, }, }, Change: { name: 'Change', prop: 'num', cellTemplate: changeRenderer, }, Thumbs: { name: 'Thumbs', prop: 'thumbs', cellTemplate: thumbsRenderer, }, Pie: { name: 'Pie', prop: 'trend', cellTemplate: pieChartRenderer, },};
[ { "num": 102, "trend": [ 63, 81, 90, 9, 13 ], "status": "Completed", "rating": 1, "timeline": [ { "start": 3, "end": 18, "label": "coniecto solutio" }, { "start": 35, "end": 58, "label": "vesper spectaculum" } ] }]