BarChart
Compares categories with vertical or horizontal bars.
When to use
- Compare categories side by side, stacked or in percent.
- For long names use horizontal bars; for time series use Trend.
Examples
Grouped bars
Loading the example
<k:BarChart label="Sales by quarter" labels="{/quarters}" unit="thousand TRY">
<k:Series name="2025" values="{/last}"/>
<k:Series name="2026" values="{/now}"/>
</k:BarChart>Horizontal, with values
Loading the example
<k:BarChart horizontal="true" showValues="true" label="Open orders by plant" labels="{/plants}" unit="orders">
<k:Series name="Open orders" values="{/open}"/>
</k:BarChart>Stacked
Loading the example
<k:BarChart stack="stacked" showValues="true" label="Shipments by channel" labels="{/quarters}" unit="tons">
<k:Series name="Road" values="{/road}"/>
<k:Series name="Sea" values="{/sea}"/>
<k:Series name="Air" values="{/air}"/>
</k:BarChart>Percent, horizontal
Loading the example
<k:BarChart stack="full" horizontal="true" label="Delivery performance" labels="{/carriers}">
<k:Series name="Late" values="{/late}"/>
<k:Series name="On time" values="{/ontime}"/>
</k:BarChart>Negative values
Loading the example
<k:BarChart showValues="true" label="Monthly net cash" labels="{/months}" unit="thousand TRY" height="220">
<k:Series name="Net cash" values="{/net}"/>
</k:BarChart>Keyboard
- ← → ↑ ↓
- Move between categories: left and right for vertical bars, up and down for horizontal bars.
- Home End
- Go to the first or last category.
- Enter
- Presses the category when barPress is set.
API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
labels | object | Category names | |
label | string | Accessible name | |
horizontal | boolean | false | Whether bars are horizontal |
stack | string | none | none (grouped), stacked or full (percent) |
height | int | 0 | Height in pixels. 0 means 260 for vertical bars and one row per category for horizontal bars |
unit | string | Unit | |
decimals | int | 0 | Decimal places |
showValues | boolean | false | Writes values at bar ends; totals when stacked. Values that do not fit are left out |
Aggregations
| Name | Type | Description |
|---|---|---|
series | Series[] | Series (up to 6). Series.kind is not used |
Events
| Name | Type | Description |
|---|---|---|
barPress | index: intlabel: stringseriesIndex: int | A bar was pressed. seriesIndex is -1 from the keyboard or between bars |
Methods
| Name | Description |
|---|---|
getBars(i: number): Bar[] | Where each bar of a category starts and ends. Stacks add positives and negatives separately. |
Series
A series of a Trend or BarChart.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
name | string | Series name | |
values | object | Array of numeric values | |
kind | string | line | For Trend: area, line, bar or ghost |