statstable
Table of statistics with sorting, search, inline bars, changes with arrows, sparklines, totals, links and a show more button, for any dashboard
The table of a dashboard: pages, campaigns, products, countries... with the numbers formatted, bars to compare a column, changes with arrows, a sparkline per row, sorting by any column, a search, totals and a show more button. It re-renders on every change of the model and keeps the sorting, the search and the expanded state.
The model is an Object with the columns and the rows:
{
columns: [
{ id: 'page', name: 'Page', type: 'text', url: 'url' },
{ id: 'views', name: 'Views', type: 'number', bar: true },
{ id: 'change', name: 'Change', type: 'delta' },
{ id: 'bounce', name: 'Bounce', type: 'percent', decimals: 1 },
{ id: 'trend', name: 'Trend', type: 'sparkline' }
],
rows: [
{ page: '/pricing', url: 'https://example.com/pricing', views: 2980, change: 2.8, bounce: 44.2, trend: [210, 230, 220] }
]
}A column has:
id {String}the property of the rowname {String}the headertype {String}text,number,percent(the value is in percent),currency,duration(the value is in seconds),delta(a change in percent with an arrow and a sign) orsparkline(an array of numbers)bar {Boolean}a bar behind the value, relative to the biggest value of the column (number types)goodup {Boolean}fordelta: a growing value is good (green arrow);falsefor metrics where less is better (defaulttrue)decimals {Number}the maximum count of decimalsurl {String}fortext: the property of the row with a link; the text opens it in a new tab (onlyhttp(s)://and relative URLs, and not withclick)align {String}leftorright; numbers are on the right by defaultsortable {Boolean}falsedisables the sorting of the column; sparklines are not sortablehidden {Boolean}hides the column
Notes:
- Clicking a header sorts by it (numbers from the biggest, texts from A) and clicking again reverses it;
aria-sorttells screen readers. Texts are sorted withIntl.Collatorin the language of the page, soéand numbers inside texts are in the right order. Empty values always go last. - The search filters the rows by the text columns. The totals are the sum of the
numberandcurrencycolumns of the filtered rows. - With
clickevery row is focusable:Enter/Spaceruns it and the arrows move between rows. - The label of the table is the content of the tag, so it can contain markup and
@(...)translations; it is the caption of the table for screen readers too.
Configuration:
label {String}the label when the content of the tag is empty (default:'')style {String}card(a box) orminimal(no box) (default:card)search {String}the placeholder of the search, example:Search pages; empty hides the search (default:'')limit {Number}the count of visible rows,0shows all of them (default:0)more {String}the text of the button that shows all the rows, example:Show all; empty hides it (default:'')less {String}the text of the button that shows onlylimitrows again; empty hides it (default:'')sort {String}the initial sorting, the id of a column andascordesc, example:views desc(default:'')totals {Boolean}a row with the totals (default:false)compact {Boolean}values from 10,000 are shortened:12.8K(default:true)currency {String}the currency code ofcurrencycolumns (default:EUR)locale {String}a language for the numbers and the sorting, example:es-ES; empty is the language of the page (default:'')
Callbacks:
click {String}link to a globalfunction(row, component), executed when the user clicks a row or pressesEnter/Spaceon it;rowis the row of the model
Runtime: jComponent v20, no dependencies.




