Skip to content

Price history with promotions ​

Price over time, its promotions and the real cut against the lowest price before each. Good for price trackers and checking a sale.

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: 'pricetrack',
  format: { currency: 'EUR' },
  data: [
    { date: '2026-01-01', price: 219 },
    { date: '2026-01-08', price: 221 },
    { date: '2026-01-15', price: 215 },
    { date: '2026-01-26', price: 222 },
    { date: '2026-02-03', price: 217 },
    { date: '2026-02-11', price: 172 },
    { date: '2026-02-19', price: 172 },
    { date: '2026-03-05', price: 213 },
    { date: '2026-03-16', price: 213 },
    { date: '2026-03-25', price: 217 },
    { date: '2026-04-02', price: 225 },
    { date: '2026-04-08', price: 220 },
    { date: '2026-04-19', price: 220 },
    { date: '2026-05-02', price: 245 },
    { date: '2026-05-11', price: 172 },
    { date: '2026-05-21', price: 172 },
    { date: '2026-06-03', price: 216 },
    { date: '2026-06-13', price: 219 },
    { date: '2026-06-19', price: 225 },
    { date: '2026-06-27', price: 220 },
    { date: '2026-06-30', price: 220 },
  ],
  promos: [
    { from: '2026-02-10', to: '2026-02-24', name: 'Spring sale' },
    { from: '2026-05-11', to: '2026-05-25', name: 'Summer sale' },
  ],
};

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 pricetrack takes:

/** Price of a product over time, its promotions and the reference price each one is measured against. */
interface PriceTrackSpec extends Base {
  type: 'pricetrack';
  /** Prices on the days they changed, or every day: `2026-03-01`. */
  data: { date: string; price: number }[];
  promos?: { from: string; to: string; name?: string }[];
  /** Days before a promotion where the reference price is looked for (its lowest price): 30 by default. */
  window?: number;
}

Style it

  • Colours: theme.palette, chart.setColor(name, colour), or --nervure-palette in your CSS. More
  • Marks: [data-series="name"], parts: [data-part="axes"], legend, series. What you change is kept in exports.
  • Movement: animation: false draws at once. More
  • Files: chart.download('png'), svg, csv. More

Close to it