Exchange rate board
An amount in several currencies, with the move and the path of each rate. Good for travel, payments and treasury screens.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
import 'nervure/themes';
const spec = {
type: 'fxboard',
base: 'EUR',
amount: 100,
data: [
{
code: 'USD',
name: 'US dollar',
rate: 1.038,
history: [
1.08, 1.079, 1.075, 1.075, 1.07, 1.065, 1.066, 1.067, 1.063, 1.06, 1.056, 1.052, 1.058,
1.052, 1.054, 1.048, 1.047, 1.043, 1.04, 1.043, 1.037, 1.036, 1.037, 1.037, 1.041, 1.037,
1.036, 1.036, 1.041, 1.038,
],
},
{
code: 'GBP',
name: 'Pound sterling',
rate: 0.8321,
history: [
0.8507, 0.8491, 0.8446, 0.8473, 0.8451, 0.8446, 0.8494, 0.8533, 0.8517, 0.848, 0.8506,
0.8495, 0.8492, 0.8495, 0.8478, 0.853, 0.8516, 0.8488, 0.8461, 0.8413, 0.8391, 0.8342,
0.8329, 0.8351, 0.8358, 0.8358, 0.8383, 0.8343, 0.8312, 0.8321,
],
},
{
code: 'CHF',
name: 'Swiss franc',
rate: 0.9847,
history: [
0.9531, 0.9553, 0.9595, 0.9583, 0.9625, 0.9639, 0.9652, 0.9691, 0.9672, 0.9651, 0.9707,
0.9685, 0.9718, 0.9738, 0.9784, 0.9742, 0.9696, 0.974, 0.975, 0.9807, 0.9842, 0.98, 0.9836,
0.9838, 0.9809, 0.9834, 0.983, 0.9806, 0.9859, 0.9847,
],
},
{
code: 'JPY',
name: 'Yen',
rate: 162.1,
history: [
161.1, 160.7, 161.5, 162.1, 162, 162.6, 162.6, 161.7, 160.9, 161.2, 161.2, 161.2, 161.4,
161.1, 161.2, 161.3, 161.8, 162.7, 162.4, 162.5, 161.8, 161.2, 161.7, 162, 161.6, 160.8,
161, 161.4, 161.7, 162.1,
],
},
{
code: 'TND',
name: 'Tunisian dinar',
rate: 3.436,
history: [
3.373, 3.355, 3.371, 3.374, 3.362, 3.349, 3.37, 3.387, 3.396, 3.382, 3.385, 3.404, 3.389,
3.395, 3.405, 3.408, 3.428, 3.42, 3.415, 3.434, 3.453, 3.442, 3.452, 3.446, 3.467, 3.452,
3.438, 3.42, 3.431, 3.436,
],
},
{
code: 'MAD',
name: 'Moroccan dirham',
rate: 11.26,
history: [
10.96, 10.96, 11, 11.06, 11.02, 11.03, 11.09, 11.06, 11.04, 11.1, 11.14, 11.18, 11.21,
11.23, 11.17, 11.13, 11.17, 11.2, 11.17, 11.17, 11.23, 11.27, 11.22, 11.16, 11.16, 11.15,
11.22, 11.18, 11.22, 11.26,
],
},
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type fxboard takes:
/** Exchange rates against one currency: the amount in each, its move and its recent path. */
interface FxBoardSpec extends Base {
type: 'fxboard';
/** Code of the base currency: `EUR`. */
base: string;
/** Amount converted: 1 by default. */
amount?: number;
/** Rates for one unit of the base; `history` ends with the current rate. */
data: { code: string; name?: string; rate: number; history?: number[] }[];
onItemClick?: (code: string) => void;
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More