Charts · Bars
BarChart
Pill bars, as columns or rows, with an optional second series. Family: Bars · chart 5 of 60.
| x | value | previous |
|---|---|---|
| Q1 | 42 | 35 |
| Q2 | 58 | 44 |
| Q3 | 51 | 49 |
| Q4 | 73 | 60 |
| x | value | previous |
|---|---|---|
| Q1 | 42 | 35 |
| Q2 | 58 | 44 |
| Q3 | 51 | 49 |
| Q4 | 73 | 60 |
| x | value | previous |
|---|---|---|
| Q1 | 42 | 35 |
| Q2 | 58 | 44 |
| Q3 | 51 | 49 |
| Q4 | 73 | 60 |
| x | value | previous |
|---|---|---|
| Q1 | 42 | 35 |
| Q2 | 58 | 44 |
| Q3 | 51 | 49 |
| Q4 | 73 | 60 |
Example
The chart above, in each framework. Pick a framework once and every example on the site follows it.
npm install @silverpoint/react @silverpoint/grounds @silverpoint/fontsimport '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import { BarChart } from '@silverpoint/react/bar-chart';
const data = [
{ x: 'Q1', value: 42, previous: 35 },
{ x: 'Q2', value: 58, previous: 44 },
{ x: 'Q3', value: 51, previous: 49 },
{ x: 'Q4', value: 73, previous: 60 },
];
export default function App() {
return (
<div style={{ width: 480 }}>
<BarChart
data={data}
xKey="x"
valueKey="value"
secondaryKey="previous"
title="Revenue by quarter"
/>
</div>
);
}npm install @silverpoint/vue @silverpoint/grounds @silverpoint/fonts<script setup lang="ts">
import '@silverpoint/fonts/fonts.css';
import '@silverpoint/grounds/styles.css';
import { SpBarChart } from '@silverpoint/vue/bar-chart';
const data = [
{ x: 'Q1', value: 42, previous: 35 },
{ x: 'Q2', value: 58, previous: 44 },
{ x: 'Q3', value: 51, previous: 49 },
{ x: 'Q4', value: 73, previous: 60 },
];
</script>
<template>
<div style="width: 480px">
<SpBarChart
:data="data"
x-key="x"
value-key="value"
secondary-key="previous"
title="Revenue by quarter"
/>
</div>
</template>npm install @silverpoint/angular @silverpoint/grounds @silverpoint/fonts// src/styles.css:
// @import '@silverpoint/fonts/fonts.css';
// @import '@silverpoint/grounds/styles.css';
import { Component } from '@angular/core';
import { SpBarChart } from '@silverpoint/angular/bar-chart';
@Component({
selector: 'app-root',
imports: [SpBarChart],
template: `
<div style="width: 480px">
<sp-bar-chart
[data]="data"
xKey="x"
valueKey="value"
secondaryKey="previous"
title="Revenue by quarter"
/>
</div>
`,
})
export class App {
protected readonly data = [
{ x: 'Q1', value: 42, previous: 35 },
{ x: 'Q2', value: 58, previous: 44 },
{ x: 'Q3', value: 51, previous: 49 },
{ x: 'Q4', value: 73, previous: 60 },
];
}pip install reflex-silverpoint-reactimport reflex as rx
from reflex_silverpoint_react import bar_chart
DATA = [
{"x": "Q1", "value": 42, "previous": 35},
{"x": "Q2", "value": 58, "previous": 44},
{"x": "Q3", "value": 51, "previous": 49},
{"x": "Q4", "value": 73, "previous": 60},
]
def index() -> rx.Component:
return rx.box(
bar_chart(
data=DATA,
x_key="x",
value_key="value",
secondary_key="previous",
title="Revenue by quarter",
),
width="480px",
)
app = rx.App()
app.add_page(index)Import
Each chart has its own subpath, so a bundle only carries the charts it uses. Every adapter also exports every chart from its barrel.
| Framework | Import |
|---|---|
| React | import { BarChart } from '@silverpoint/react/bar-chart'; |
| Vue | import { SpBarChart } from '@silverpoint/vue/bar-chart'; |
| Angular | import { SpBarChart } from '@silverpoint/angular/bar-chart'; // <sp-bar-chart> |
| Reflex | from reflex_silverpoint_react import bar_chart |
Props
The props BarChart adds to the ones every chart takes. Accessor props (…Key, keys, names) name fields of your rows and are ignored without data.
| React / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
xKey | x-key | x_key | Accessor<string | number> | — |
valueKey | value-key | value_key | Accessor<number | null | undefined> | — |
secondaryKey | secondary-key | secondary_key | Accessor<number | null | undefined> | — |
orientation | orientation | orientation | 'columns' | 'rows' | — |
Common props
Every chart also takes these. Framework conventions: camelCase in React and Angular, kebab-case in Vue templates, snake_case in Reflex. Read more about them.
Show the 22 common props
| React / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
data | data | data | readonly Datum[] | Rows to draw. If omitted, the demo dataset is rendered (REQ-093) and the accessor props (…_key, keys, names) are ignored. |
ground | ground | ground | GroundRef | Style ground: silverpoint or cyanotype, or a ground object. Defaults to the app provider's, or silverpoint. |
substrate | substrate | substrate | SubstrateName | Prepared substrate within the ground (REQ-046). |
mode | mode | mode | InkMode | ink by default; precision disables inking (REQ-021). |
seed | seed | seed | Seed | Seed. If omitted, it is derived from id stably (REQ-003). |
id | id | id | string | Stable identifier. If omitted, it is generated deterministically. |
height | height | height | number | Height of the drawing area in px. Width is the container's unless pinned. |
width | width | width | number | — |
chrome | chrome | chrome | 'card' | 'bare' | card draws the full frame; bare only the drawing area (REQ-095). |
hatchFill | hatch-fill | hatch_fill | 'tile' | 'per-shape' | How areas are filled (REQ-029). |
title | title | title | string | — |
badge | badge | badge | string | — |
value | value | value | string | number | — |
unit | unit | unit | string | — |
footerLeft | footer-left | footer_left | string | — |
footerRight | footer-right | footer_right | string | — |
label | label | label | string | Accessible name. If omitted, it is derived from title (REQ-120). |
description | description | description | string | Long description for screen readers (REQ-120). |
dataTable | data-table | data_table | 'visible' | 'hidden' | 'none' | Tabular alternative; hidden leaves it for assistive technology only (REQ-121). |
locale | locale | locale | string | — |
numberFormat | number-format | number_format | Intl.NumberFormatOptions | — |
className | class-name | class_name | string | — |
Events
Pointer and keyboard exploration are built in. The item under the pointer or focus is reported, and a click, Enter or Space selects it. The item is { seriesKey, index, datum, value, point: { x, y } }.
| Framework | Active item | Selection | Custom readout |
|---|---|---|---|
| React | onActiveChange | onSelect | tooltip={(item, readout) => …} |
| Vue | @active-change | @select | <template #tooltip> |
| Angular | (activeChange) | (select) | <ng-template spTooltip> |
| Reflex | on_active_change | on_select | tooltip=tooltip_template(…) |
Report it
Found something wrong with BarChart? Open an issue on GitHub — the form comes pre-filled with the chart and the version.