# nervure > Animated SVG charts, maps, diagrams and dashboards for every JavaScript framework. 214 charts (199 types), no dependency, MIT license. By Ali Ben Macha. Install: `npm install nervure`. Use: `import { createChart } from 'nervure'; createChart(element, spec, options)`. The element must have a height. A spec is one object with a `type`. Options: `theme`, `locale`, `animation` (false, or `{ speed, duration, delay, stagger, easing, effect, start }`), `toolbar` (export menu). Types: xy, pie, radar, gauge, scatter, heatmap, timeline, treemap, pack, funnel, waterfall, tree, candlestick, ohlc, heikinashi, renko, violin, beeswarm, ridgeline, histogram, errorbar, boxplot, hexbin, lollipop, dumbbell, bullet, slope, bump, pareto, likert, population, marimekko, pictogram, waffle, progress, bars3d, stream, horizon, parallel, kpi, rose, radialbar, polar, chord, liquid, thermometer, speedometer, venn, sankey, arc, network, pipeline, tunnel, sunburst, icicle, dendrogram, flowchart, orgchart, mindmap, sequence, er, quadrant, fishbone, cycle, triangle, steps, events, hexmap, ternary, calendar, punchcard, wordcloud, triangles, pitch, circuit, barrace, ranking, podium, bracket, body, organ, ecg, floorplan, building, tables, parliament, map. - [Everything in one file](https://nervurejs.github.io/llms-full.txt) - [Gallery with code](https://nervurejs.github.io/charts/) - [Frameworks](https://nervurejs.github.io/guide/frameworks): React, Next.js, Vue, Nuxt, Svelte, Angular, web component - [Symfony and Laravel](https://nervurejs.github.io/guide/symfony-laravel) - [CDN](https://nervurejs.github.io/guide/cdn) - [Size and lazy loading](https://nervurejs.github.io/guide/size) - [CSS](https://nervurejs.github.io/guide/css), [colours](https://nervurejs.github.io/guide/colours), [animation](https://nervurejs.github.io/guide/animation), [export](https://nervurejs.github.io/guide/export) - [Live data](https://nervurejs.github.io/guide/live): polling, server-sent events, WebSocket; [server side](https://nervurejs.github.io/guide/server) - [Maps of every country](https://nervurejs.github.io/maps/), [dashboards](https://nervurejs.github.io/guide/dashboards) - [API, every field](https://nervurejs.github.io/api) - [Comparison with other libraries](https://nervurejs.github.io/compare/) - [MCP server, skill and plugin](https://nervurejs.github.io/ai/): `npx -y nervure` - [Source](https://github.com/nervurejs/nervure) # Charts ## Lines and bars - [Line chart](https://nervurejs.github.io/charts/line-chart): Values that follow one another, joined by a line. Trends over time, two or three series compared. - [Area chart](https://nervurejs.github.io/charts/area-chart): A line filled down to zero. One quantity whose total matters as much as its shape. - [Step line](https://nervurejs.github.io/charts/step-line): A line that jumps from one value to the next. Prices, rates and stock levels that stay still between two changes. - [Range band](https://nervurejs.github.io/charts/range-band): The space between a low and a high series. Forecasts with their uncertainty, daily low and high. - [Bar chart](https://nervurejs.github.io/charts/bar-chart): One bar for each category. Comparing amounts side by side. - [Horizontal bar chart](https://nervurejs.github.io/charts/horizontal-bar-chart): Bars that run to the right, with their names on the left. Rankings, and names too long for the bottom of a chart. - [Grouped bar chart](https://nervurejs.github.io/charts/grouped-bar-chart): Several bars for each category. Comparing two or three series category by category. - [Stacked bar chart](https://nervurejs.github.io/charts/stacked-bar-chart): Parts piled up into a total. A total and what it is made of. - [Mixed chart with two axes](https://nervurejs.github.io/charts/mixed-chart-with-two-axes): Bars on one scale and a line on another. An amount and a rate in the same picture. - [Logarithmic chart](https://nervurejs.github.io/charts/logarithmic-chart): A scale where each step multiplies by ten. Growth, and values that differ by thousands. - [Sparkline](https://nervurejs.github.io/charts/sparkline): A line without axes, as small as a word. A trend inside a table or beside a figure. - [100 % stacked bar chart](https://nervurejs.github.io/charts/100-stacked-bar-chart): Bars of the same height, split into shares. How a mix changes from one category to the next, whatever the totals. - [Stacked bars in groups](https://nervurejs.github.io/charts/stacked-bars-in-groups): Several stacks side by side in each category. Two totals and their parts, compared category by category. - [Line chart with point styles](https://nervurejs.github.io/charts/line-chart-with-point-styles): Lines whose points have their own shapes. Series told apart without colour: printed in grey, or for readers who do not see every colour. - [Small multiples](https://nervurejs.github.io/charts/small-multiples): The same small chart for each group, on one scale. Comparing the shape of many series without a tangle of lines. ## Shares - [Pie chart](https://nervurejs.github.io/charts/pie-chart): Slices of a whole. Two to five shares that add up to a total. - [Donut chart](https://nervurejs.github.io/charts/donut-chart): A pie with room for a figure in the middle. Shares, with their total in the hole. - [Treemap](https://nervurejs.github.io/charts/treemap): Rectangles as large as their value. Many shares in little room. - [Packed bubbles](https://nervurejs.github.io/charts/packed-bubbles): Circles gathered around the largest. Shares when their order matters more than their exact size. - [Waffle chart](https://nervurejs.github.io/charts/waffle-chart): A hundred small squares shared between categories. Percentages that everybody can count. - [Marimekko chart](https://nervurejs.github.io/charts/marimekko-chart): Stacked columns as wide as their total. Market size and market share together. - [Sunburst chart](https://nervurejs.github.io/charts/sunburst-chart): Rings of slices, from the centre to the leaves. A hierarchy and the weight of each branch. - [Icicle chart](https://nervurejs.github.io/charts/icicle-chart): A hierarchy in columns of blocks. Deep hierarchies, with names that can be read. - [Venn diagram](https://nervurejs.github.io/charts/venn-diagram): Circles that overlap as much as their sets. What two or three groups have in common. - [Pictogram](https://nervurejs.github.io/charts/pictogram): Small figures, each worth the same amount. Numbers of people or things, for a wide audience. - [Circle packing](https://nervurejs.github.io/charts/circle-packing): Circles inside circles; a click zooms into a group. A hierarchy of sizes, explored level by level. ## Finance - [Candlestick chart](https://nervurejs.github.io/charts/candlestick-chart): Open, high, low and close of each period, with volume and moving averages. Stock, currency and crypto prices. - [OHLC bar chart](https://nervurejs.github.io/charts/ohlc-bar-chart): The four prices of a period on a thin bar. Prices over many periods, with less ink than candles. - [Heikin-Ashi chart](https://nervurejs.github.io/charts/heikin-ashi-chart): Candles smoothed by the ones before them. Reading a trend without its noise. - [Kagi chart](https://nervurejs.github.io/charts/kagi-chart): A line that turns only when prices come back far enough; thick above the last high, thin below the last low. Trends and reversals of a price, without the noise of small moves. - [Renko chart](https://nervurejs.github.io/charts/renko-chart): A brick each time the price moves by a fixed amount. Price moves, whatever the time they take. - [Point and figure chart](https://nervurejs.github.io/charts/point-and-figure-chart): Columns of X while the price rises by a box, of O while it falls; a new column after a move back of several boxes. Support, resistance and breakouts, without time or small moves. - [Market depth chart](https://nervurejs.github.io/charts/market-depth-chart): Bids and asks added up from the mid price outwards, as two steps. Order books: where buyers and sellers wait, and how thin the market is. - [Volume profile](https://nervurejs.github.io/charts/volume-profile): Prices with the volume traded at each level on the side, and the busiest level marked. Finding the prices where most of the trading happened. - [Drawdown chart](https://nervurejs.github.io/charts/drawdown-chart): How far a price or a portfolio stands below its last peak, with the deepest fall marked. The risk of a fund or a strategy, and how long it took to recover. - [Monthly returns](https://nervurejs.github.io/charts/monthly-returns): Years by months, green above zero and red below, with the return of each year. Performance reports of a fund, a portfolio or a strategy. ## Distribution - [Histogram](https://nervurejs.github.io/charts/histogram): How many values fall in each interval, with their density. The shape of a large sample. - [Box plot](https://nervurejs.github.io/charts/box-plot): Median, quartiles, whiskers and outliers. Comparing several samples at a glance. - [Violin plot](https://nervurejs.github.io/charts/violin-plot): The density of each sample, mirrored. Samples with more than one peak. - [Beeswarm plot](https://nervurejs.github.io/charts/beeswarm-plot): Every value as a point, none over another. Small samples, where each value counts. - [Ridgeline plot](https://nervurejs.github.io/charts/ridgeline-plot): Densities one above the other. How a distribution changes between groups or months. - [Error bars](https://nervurejs.github.io/charts/error-bars): A value and its interval. Measures with their uncertainty. - [Hexagonal bins](https://nervurejs.github.io/charts/hexagonal-bins): A cloud of points counted in hexagons. Thousands of points that would cover one another. - [Scatter and bubble chart](https://nervurejs.github.io/charts/scatter-and-bubble-chart): Points on two axes, with a size and a group. The link between two measures. - [Ternary plot](https://nervurejs.github.io/charts/ternary-plot): Three shares of a whole, in a triangle. Mixtures: soils, alloys, votes between three parties. - [Barcode plot](https://nervurejs.github.io/charts/barcode-plot): One thin tick for each value, a row for each group. Where values gather and where they are rare, in little room. - [Density plot](https://nervurejs.github.io/charts/density-plot): Smooth curves of where the values gather, one per group. Comparing the shape of two or three samples on one axis. - [Cumulative distribution](https://nervurejs.github.io/charts/cumulative-distribution): For each value, the share of the sample at or below it. Reading medians and percentiles, and comparing samples without bins. - [Q-Q plot](https://nervurejs.github.io/charts/q-q-plot): Sorted values against those of a normal distribution, with the line they would follow. Checking whether a sample is normal, skewed or has heavy tails. - [Raincloud plot](https://nervurejs.github.io/charts/raincloud-plot): Half a violin, a box and every value, for each group. Showing the shape, the summary and the raw data at once. - [Dot plot](https://nervurejs.github.io/charts/dot-plot): Each value as a dot, piled up in stacks. Small samples, where people should count the values. - [Strip plot](https://nervurejs.github.io/charts/strip-plot): Every value of each category, spread a little sideways, with the median. Small samples per group, without hiding a single value. - [Density contours](https://nervurejs.github.io/charts/density-contours): Lines around the places where points crowd together. Clouds of many points, and finding their centres. - [Regression line](https://nervurejs.github.io/charts/regression-line): Points with the line that fits them best, its band of confidence and R². Showing how much one measure follows another. - [Fan chart](https://nervurejs.github.io/charts/fan-chart): A history, then a forecast whose bands widen with time. Forecasts of sales, prices or rates, with how sure they are. - [Bubble chart](https://nervurejs.github.io/charts/bubble-chart): Points on two axes, sized by a third value, with names and groups. Comparing a few items on three measures at once. ## Comparison - [Lollipop chart](https://nervurejs.github.io/charts/lollipop-chart): A thin stem and a dot. Many categories with close values. - [Dumbbell chart](https://nervurejs.github.io/charts/dumbbell-chart): Two values joined by a line. Before and after, men and women, plan and result. - [Bullet chart](https://nervurejs.github.io/charts/bullet-chart): A value, its target and bands of quality. Goals, in the room of a line of text. - [Slope chart](https://nervurejs.github.io/charts/slope-chart): Two columns joined by straight lines. What rose and what fell between two dates. - [Bump chart](https://nervurejs.github.io/charts/bump-chart): Ranks over time. Who overtook whom. - [Pareto chart](https://nervurejs.github.io/charts/pareto-chart): Bars from the largest, and their running share. Finding the few causes of most problems. - [Likert chart](https://nervurejs.github.io/charts/likert-chart): Answers on both sides of a middle. Surveys with a scale of agreement. - [Population pyramid](https://nervurejs.github.io/charts/population-pyramid): Two sets of bars back to back. Ages of men and women, imports and exports. - [Progress bars](https://nervurejs.github.io/charts/progress-bars): How much of each goal is done. Tasks, quotas and levels. - [Parallel coordinates](https://nervurejs.github.io/charts/parallel-coordinates): One line for each item, across several axes. Comparing items on many measures. - [Waterfall chart](https://nervurejs.github.io/charts/waterfall-chart): Gains and losses between two totals. Explaining a profit, a budget or a head count. - [Key figure](https://nervurejs.github.io/charts/key-figure): A figure, its change and its trend. The top of a dashboard. - [Diverging bar chart](https://nervurejs.github.io/charts/diverging-bar-chart): Bars that go left or right of a middle. Gains and losses, above and below a target, agree and disagree. - [Range bar chart](https://nervurejs.github.io/charts/range-bar-chart): A floating bar from the lowest to the highest value, with a mark for today. Temperatures, prices and salaries: a span and where we stand in it. - [Cleveland dot plot](https://nervurejs.github.io/charts/cleveland-dot-plot): One or two dots for each row, sorted. Ranking many items, or showing before and after with less ink than bars. - [Scorecard](https://nervurejs.github.io/charts/scorecard): Names, figures, bars and arrows in a table. A short list of results and how each one changed. - [Nested bar chart](https://nervurejs.github.io/charts/nested-bar-chart): A narrow bar for the result inside a wide one for the target. Actual against plan, month by month. ## Time - [Stream graph](https://nervurejs.github.io/charts/stream-graph): Layers that swell and shrink around a middle. How a mix changes over time. - [Horizon chart](https://nervurejs.github.io/charts/horizon-chart): Many long series, each in a thin folded strip. Dozens of series on one screen. - [Calendar heatmap](https://nervurejs.github.io/charts/calendar-heatmap): A square for each day. Habits and activity over a year. - [Gantt chart](https://nervurejs.github.io/charts/gantt-chart): Bars on a calendar. Plans, phases and bookings. - [Event timeline](https://nervurejs.github.io/charts/event-timeline): Dates along a line. A history in a few moments. - [Time spiral](https://nervurejs.github.io/charts/time-spiral): One turn for each year, so that the same months line up. Seasons and cycles over several years. - [Gantt chart with dependencies](https://nervurejs.github.io/charts/gantt-chart-with-dependencies): Tasks on a calendar, arrows to the tasks that wait for them, milestones, progress and today. Project plans where the order of the work matters. - [Milestone timeline](https://nervurejs.github.io/charts/milestone-timeline): Dates down a line, with a card on one side then the other. The story of a project or a company, in a few steps. - [24-hour clock chart](https://nervurejs.github.io/charts/24-hour-clock-chart): A bar for each hour around a clock face, with a second series beside it. When things happen in a day: visits, calls, energy use. - [Weather forecast](https://nervurejs.github.io/charts/weather-forecast): Days or hours with a drawn sky, the highs and lows, and the chance of rain. Forecasts, and the weather of an event or a trip. - [Moon phases](https://nervurejs.github.io/charts/moon-phases): A month of drawn moons, computed from the dates, with the new and full moons. Calendars, tides, gardening, night events. ## Circles and gauges - [Radar chart](https://nervurejs.github.io/charts/radar-chart): Several criteria around a centre. Profiles of two or three items. - [Nightingale rose chart](https://nervurejs.github.io/charts/nightingale-rose-chart): Petals of the same angle, as large as their value. Months, directions, and other things that turn. - [Radial bar chart](https://nervurejs.github.io/charts/radial-bar-chart): Bars bent around a circle. A few percentages, with style. - [Polar chart](https://nervurejs.github.io/charts/polar-chart): A line around a dial. Hours of the day, directions of the wind. - [Chord diagram](https://nervurejs.github.io/charts/chord-diagram): Ribbons between the arcs of a circle. Exchanges between places, in both directions. - [Gauge chart](https://nervurejs.github.io/charts/gauge-chart): One value on a half circle, with a target. A single goal. - [Speedometer chart](https://nervurejs.github.io/charts/speedometer-chart): A needle over coloured zones. A value that is good, fair or bad. - [Liquid gauge](https://nervurejs.github.io/charts/liquid-gauge): A vessel that fills, with a moving surface. Levels: tanks, batteries, goals. - [Thermometer chart](https://nervurejs.github.io/charts/thermometer-chart): A column that rises in a tube. Temperatures and fundraising. - [Circular bar chart](https://nervurejs.github.io/charts/circular-bar-chart): Bars that radiate from a ring. Many categories, with style, when a ranking is not the point. - [Battery level](https://nervurejs.github.io/charts/battery-level): Batteries filled to their charge, red when low, with a bolt when they charge. Devices, vehicles and stocks that run down. ## Flows and networks - [Sankey diagram](https://nervurejs.github.io/charts/sankey-diagram): Ribbons as wide as what flows through them. Money, energy or visitors from step to step. - [Pipe chart](https://nervurejs.github.io/charts/pipe-chart): Pipes that narrow, leaks included, with a moving flow. A process that loses something on the way. - [Funnel chart](https://nervurejs.github.io/charts/funnel-chart): Steps that shrink, with the share that remains. Conversion rates. - [Tunnel chart](https://nervurejs.github.io/charts/tunnel-chart): Steps seen one inside the other. A funnel in little height. - [Network graph](https://nervurejs.github.io/charts/network-graph): Nodes spread by forces, and their links. Who is linked to whom. - [Arc diagram](https://nervurejs.github.io/charts/arc-diagram): Names on a line, joined by arcs. Links between things that have an order. - [Alluvial diagram](https://nervurejs.github.io/charts/alluvial-diagram): Stages in columns, and ribbons that show how the same items change category. Customers moving between plans, voters between parties, from year to year. - [Adjacency matrix](https://nervurejs.github.io/charts/adjacency-matrix): A network as a grid: a coloured cell for each link. Dense networks, where lines would tangle. ## Diagrams - [Flowchart](https://nervurejs.github.io/charts/flowchart): Boxes and arrows, laid out for you. Processes and decisions. - [Organisation chart](https://nervurejs.github.io/charts/organisation-chart): People or teams from the top down; branches fold. Who works with whom. - [Mind map](https://nervurejs.github.io/charts/mind-map): Ideas that branch from a centre. Plans, lessons, notes of a meeting. - [Sequence diagram](https://nervurejs.github.io/charts/sequence-diagram): Messages between actors, in order. Describing an exchange between programs. - [Entity relationship diagram](https://nervurejs.github.io/charts/entity-relationship-diagram): Tables, their fields and their links. Documenting a database. - [Radial tree](https://nervurejs.github.io/charts/radial-tree): A hierarchy around its root; branches fold. Wide trees in a square room. - [Dendrogram](https://nervurejs.github.io/charts/dendrogram): A hierarchy from left to right. Classifications and families. - [Quadrant chart](https://nervurejs.github.io/charts/quadrant-chart): Four zones and the points that fall in them. Priorities, SWOT, effort against value. - [Fishbone diagram](https://nervurejs.github.io/charts/fishbone-diagram): Causes along the bones of a problem. Finding why something went wrong. - [Cycle diagram](https://nervurejs.github.io/charts/cycle-diagram): Steps that come back to the first. Plan, do, check, act. - [Pyramid diagram](https://nervurejs.github.io/charts/pyramid-diagram): Levels of a triangle. Needs, strategies, layers of a system. - [Kanban board](https://nervurejs.github.io/charts/kanban-board): Columns of cards, with the work allowed in each column. Where the work stands, and where it piles up. - [Step diagram](https://nervurejs.github.io/charts/step-diagram): Arrows one after the other, done or to do. Where you are in a process. - [Tidy tree](https://nervurejs.github.io/charts/tidy-tree): A hierarchy from left to right, packed close; branches fold. Large trees, opened one branch at a time. - [Swimlane diagram](https://nervurejs.github.io/charts/swimlane-diagram): Steps in the band of the person who does them, joined by arrows. Who does what, and when the work changes hands. - [Customer journey map](https://nervurejs.github.io/charts/customer-journey-map): Stages, what the customer meets, and how they feel at each step. Finding where customers are let down. - [Pyramid of levels](https://nervurejs.github.io/charts/pyramid-of-levels): Levels from a narrow top to a wide base, with their value and share. Customer levels, sales stages, needs. - [Decision tree](https://nervurejs.github.io/charts/decision-tree): Choices, chances and outcomes, with the best path in bold. Comparing options whose result is uncertain. - [Product roadmap](https://nervurejs.github.io/charts/product-roadmap): Work on periods, by theme and by status, with today marked. Sharing what is done, under way and planned. - [SWOT analysis](https://nervurejs.github.io/charts/swot-analysis): Strengths, weaknesses, opportunities and threats in four boxes. A strategy meeting, a plan, a pitch. - [Work breakdown structure](https://nervurejs.github.io/charts/work-breakdown-structure): A project cut into parts and sub-parts, with their codes. Planning a project and sharing out the work. ## Grids - [Heatmap](https://nervurejs.github.io/charts/heatmap): A colour for each row and column. Days and hours, products and regions. - [Punch card](https://nervurejs.github.io/charts/punch-card): A circle for each row and column. When things happen. - [Hexagon map](https://nervurejs.github.io/charts/hexagon-map): Hexagons as tiles, with their value. Maps where each place counts the same. - [Triangle grid](https://nervurejs.github.io/charts/triangle-grid): Triangles up and down, as dark as their value. Many small values, as a pattern. - [Word cloud](https://nervurejs.github.io/charts/word-cloud): Words as large as their weight. A first look at a text. - [Bubble matrix](https://nervurejs.github.io/charts/bubble-matrix): Circles as large as their value, in rows and columns. Two dimensions crossed, when sizes speak better than colours. ## Sport - [Football pitch and line-up](https://nervurejs.github.io/charts/football-pitch-and-line-up): Two teams on a ground, by formation, and the path of the ball. Handball and basketball too. Line-ups, tactics and match reports. - [Race circuit](https://nervurejs.github.io/charts/race-circuit): Runners that move along a track, with their gaps. Motor races, running, cycling, sales contests. - [Tournament bracket](https://nervurejs.github.io/charts/tournament-bracket): Matches round after round, to the final. Cups and knock-out games. - [Podium](https://nervurejs.github.io/charts/podium): First, second and third, with pictures. Results and prizes. - [Top 5, top 10](https://nervurejs.github.io/charts/top-5-top-10): A ranking with pictures, figures and changes of rank. Best players, products, advisers. - [Bar chart race](https://nervurejs.github.io/charts/bar-chart-race): Bars that overtake one another year after year. How a ranking changed over time. - [League table](https://nervurejs.github.io/charts/league-table): Rank, games, goals, points and the last results of each team, with the zones of the table. Championships, leagues and sales contests. - [Football shot map](https://nervurejs.github.io/charts/football-shot-map): Shots on half a pitch, each circle as large as its chance of a goal, filled when it went in. Match reports, scouting and finishing. - [Pass network](https://nervurejs.github.io/charts/pass-network): Players at their average place on the pitch, joined by lines as thick as the passes between them. How a team builds its play, and who links it. - [Player heat map](https://nervurejs.github.io/charts/player-heat-map): Where one player touched the ball, warmer where he was most often, with his share in each third. Roles and positions of a player in a match. - [Basketball shot chart](https://nervurejs.github.io/charts/basketball-shot-chart): Shots on half a court, made or missed, with the success in the paint, in mid-range and from three. Where a player or a team scores best. - [Tennis scoreboard](https://nervurejs.github.io/charts/tennis-scoreboard): Games of each set, tie-breaks, the server and the winner, then the statistics of both players face to face. Match results and reports. - [Tennis serve map](https://nervurejs.github.io/charts/tennis-serve-map): Where the serves landed in the service boxes: aces, points won and lost, faults, wide, body or T. How a player serves and where to stand to return. - [Swimming race](https://nervurejs.github.io/charts/swimming-race): One lane for each swimmer, the time of each length, the final time, places and gaps. Swimming results, heats and finals. - [Athletics track race](https://nervurejs.github.io/charts/athletics-track-race): A track seen from above with its staggered starts, the runners on their lanes and the results in the middle. Sprints and middle-distance races. - [Cycling stage profile](https://nervurejs.github.io/charts/cycling-stage-profile): The height of a stage along its length, with its climbs by category, its sprints and its feed zones. Race books, previews and route plans. - [Golf scorecard](https://nervurejs.github.io/charts/golf-scorecard): Strokes on each hole against the par, birdies in circles and bogeys in squares, with the totals. Rounds, tournaments and friendly games. - [Running splits](https://nervurejs.github.io/charts/running-splits): The pace of each kilometre against a target: faster above the line, slower under it, with both halves. Marathons, races and training runs. - [Match timeline](https://nervurejs.github.io/charts/match-timeline): Goals, cards and changes minute by minute, one team above the line and the other under it. Match reports and live pages. - [Pizza chart](https://nervurejs.github.io/charts/pizza-chart): One slice for each figure of a player, as long as his percentile among his peers, coloured by group. Scouting and comparing a player with others in his role. - [Team stats face-off](https://nervurejs.github.io/charts/team-stats-face-off): Two teams face to face, figure by figure, each bar as long as its share. Match statistics: possession, shots, fouls. - [Win probability](https://nervurejs.github.io/charts/win-probability): The chances of a home win, a draw and an away win as the match goes on, with its goals. Match stories and the turning points of a game. - [Fight scorecard](https://nervurejs.github.io/charts/fight-scorecard): The cards of the judges round by round, the totals and the decision. Boxing, kickboxing and fights decided on points. - [Chess evaluation](https://nervurejs.github.io/charts/chess-evaluation): Who is better move after move, white under the curve and black above, with the mistakes and blunders. Reviewing a game of chess. - [Medal table](https://nervurejs.github.io/charts/medal-table): Gold, silver and bronze of each country or club, sorted as in the games. Games, championships and tournaments. ## Health - [Human body](https://nervurejs.github.io/charts/human-body): Figures on the organs of a body. Check-ups and lessons. It explains; it is not a medical tool. - [Organ](https://nervurejs.github.io/charts/organ): A heart that beats, lungs that breathe, with a figure. Vital signs and lessons. - [Heartbeat trace](https://nervurejs.github.io/charts/heartbeat-trace): A trace on paper, at the rate you give. Heart rates, and live signals. - [Activity rings](https://nervurejs.github.io/charts/activity-rings): Rings that close when a goal is reached, with a second lap beyond it. Daily goals: moving, exercise, steps, sales. - [Sleep stages](https://nervurejs.github.io/charts/sleep-stages): The stages of a night as steps, with the time spent in each. Sleep trackers and health reports. - [Blood pressure chart](https://nervurejs.github.io/charts/blood-pressure-chart): Readings on the grid of blood pressure categories, from normal to crisis. Home monitoring, check-ups and patient apps. - [Glucose curve](https://nervurejs.github.io/charts/glucose-curve): Blood sugar over a day, the target range, the meals and the time spent in range. Diabetes diaries and sensor apps. - [Heart rate zones](https://nervurejs.github.io/charts/heart-rate-zones): A heart rate trace over coloured zones, and the time spent in each one. Workouts, running and cycling apps. - [BMI scale](https://nervurejs.github.io/charts/bmi-scale): Body mass index on the scale of its categories, with the change since last time. Check-ups, weight programmes and wellness apps. - [Growth chart](https://nervurejs.github.io/charts/growth-chart): The height or weight of a child among percentile curves. Paediatric visits and child health records. - [Vaccination schedule](https://nervurejs.github.io/charts/vaccination-schedule): Doses by age, given, late or to come, and today. Child health records and clinics. - [Medication tracker](https://nervurejs.github.io/charts/medication-tracker): A week of doses, one pill a day for each medicine and time, taken or missed. Treatment follow-up, care homes and patient apps. - [Pain scale](https://nervurejs.github.io/charts/pain-scale): A score from 0 to 10 on a row of faces. Consultations, nursing notes and recovery diaries. - [Mood tracker](https://nervurejs.github.io/charts/mood-tracker): Mood day after day, as faces on five levels. Wellness and mental health diaries. - [Temperature chart](https://nervurejs.github.io/charts/temperature-chart): Body temperature, the fever line and the doses given. Hospital wards, children at home, care notes. - [Oxygen saturation](https://nervurejs.github.io/charts/oxygen-saturation): Saturation over a night, its bands, its drops and its lowest value. Sleep studies, oximeters and remote care. - [Step counter](https://nervurejs.github.io/charts/step-counter): Steps a day against a goal, with the days reached and the streak. Activity trackers and wellness challenges. - [Nutrition breakdown](https://nervurejs.github.io/charts/nutrition-breakdown): Calories by nutrient in a ring, and grams against a goal. Diet apps, meal plans and nutrition advice. - [Cycle wheel](https://nervurejs.github.io/charts/cycle-wheel): The days of a cycle in a wheel: period, fertile window, ovulation and today. Cycle tracking and health education. - [Bed occupancy](https://nervurejs.github.io/charts/bed-occupancy): The beds of each ward, occupied, reserved, free or closed, and the rate. Hospital capacity and daily huddles. - [Emergency triage](https://nervurejs.github.io/charts/emergency-triage): Patients waiting at each triage level, and their wait against its target. Emergency room screens and reports. - [Epidemic curve](https://nervurejs.github.io/charts/epidemic-curve): New cases a day, their moving average, the waves and the peak. Public health reports and outbreak follow-up. - [Dental chart](https://nervurejs.github.io/charts/dental-chart): The 32 teeth in two arches, numbered, by state. Dental records and treatment plans. - [Audiogram](https://nervurejs.github.io/charts/audiogram): The softest sound heard at each pitch, by ear, over the bands of hearing loss. Hearing tests and audiology reports. - [Lab results](https://nervurejs.github.io/charts/lab-results): Results against their reference ranges, flagged high or low, with the last value. Blood tests and patient portals. ## Places - [Floor plan](https://nervurejs.github.io/charts/floor-plan): The rooms of a home, at scale, with their area. Real estate, offices and shops. - [Building](https://nervurejs.github.io/charts/building): Floors and units, by state. Homes for sale, hotel rooms, beds, parking. - [Table plan](https://nervurejs.github.io/charts/table-plan): Tables of a room and their seats, by state. Restaurants, weddings, classrooms. - [Parliament chart](https://nervurejs.github.io/charts/parliament-chart): Seats in half circles. Elections, votes, boards. - [Seat map](https://nervurejs.github.io/charts/seat-map): Seats of a plane, a cinema or a theatre, by state and price. Booking seats and showing what is left. - [Elevation profile](https://nervurejs.github.io/charts/elevation-profile): The height of a route along its length, coloured by slope, with its peaks and passes. Hikes, bike rides, races and roads. - [Transit map](https://nervurejs.github.io/charts/transit-map): Lines through their stations on a clean grid, with the interchanges where they meet. Metro, tram and bus networks, and any map of lines and stops. - [Departures board](https://nervurejs.github.io/charts/departures-board): Times, destinations, platforms and delays, on a board that flips row by row. Stations, airports, bus stops and any screen of what leaves next. - [Stadium seating](https://nervurejs.github.io/charts/stadium-seating): The sections of a stadium around its field, coloured by the share of seats sold. Ticket sales for matches, concerts and shows. - [Car park](https://nervurejs.github.io/charts/car-park): Spaces seen from above, free or taken, with charging and accessible bays. Car parks, garages and any count of free spaces. - [Warehouse racks](https://nervurejs.github.io/charts/warehouse-racks): Racks seen from the aisle, each bin filled as much as it is. Stock, storage space and picking. - [Room bookings](https://nervurejs.github.io/charts/room-bookings): Meeting rooms over a day: bookings, free time and the share of the day taken. Offices, coworking spaces, schools and hospitals. - [Queues at counters](https://nervurejs.github.io/charts/queues-at-counters): People waiting at each counter, and how long it will take. Shops, banks, offices, airports and help desks. - [Lift traffic](https://nervurejs.github.io/charts/lift-traffic): The floors of a building, where each lift is, and the trips going up and down from each floor. Office towers, hotels and hospitals. - [Property card](https://nervurejs.github.io/charts/property-card): A home with its price, area and rooms, and its price per m² against the places around. Real estate listings, valuations and reports. - [Neighbourhood flower](https://nervurejs.github.io/charts/neighbourhood-flower): One petal for each kind of place nearby, as long as its score, with the walk to the nearest. Comparing where to live, and real estate listings. - [Skyline](https://nervurejs.github.io/charts/skyline): Values drawn as the buildings of a city, each as tall as its value. Rankings of towns, towers and districts, for a wide audience. - [Bus line strip](https://nervurejs.github.io/charts/bus-line-strip): The stops of one line in a row, the load on board between them, and where the bus is. Bus and tram lines, school runs and deliveries. - [Exhibition hall](https://nervurejs.github.io/charts/exhibition-hall): The stands of a hall to scale, sold, free or reserved, with the doors. Trade fairs, markets and events. - [Marina](https://nervurejs.github.io/charts/marina): Pontoons, berths and the boats moored in them, as long as they are. Ports, marinas, and any count of free berths. - [Energy label](https://nervurejs.github.io/charts/energy-label): Classes A to G, where a home stands on them, and its greenhouse gas beside. Real estate listings, building audits and renovation plans. - [Travel time rings](https://nervurejs.github.io/charts/travel-time-rings): Rings of minutes around a starting point, and the places each one reaches. Commutes, where to live, and the reach of a shop or a station. - [Route steps](https://nervurejs.github.io/charts/route-steps): The steps of a way on foot, a turn and a distance each, and where you are. Stations, airports, hospitals and campuses. - [Train crowding](https://nervurejs.github.io/charts/train-crowding): The cars of a train along its platform, by how full they are, and where to wait. Station screens and travel apps. - [Train graph](https://nervurejs.github.io/charts/train-graph): Stations down the side and time across: one line for each train, steep when it is fast. Timetables, and where trains meet or overtake. ## Maps - [Dorling cartogram](https://nervurejs.github.io/charts/dorling-cartogram): Each place becomes a circle as large as its value, near its true position, none over another. Populations, votes and sales by country, where large places would hide small ones. - [Proportional symbol map](https://nervurejs.github.io/charts/proportional-symbol-map): Circles as large as their value, on a pale map. Amounts by city or by site. - [Globe](https://nervurejs.github.io/charts/globe): The Earth as a ball that turns when you drag it, with values, points and routes. Flights, trade and anything seen from far away. - [Choropleth map](https://nervurejs.github.io/charts/choropleth-map): Each region as dark as its value, with a colour scale and a zoom. Rates and densities by country, region or department. - [Flow map](https://nervurejs.github.io/charts/flow-map): Curved arrows from place to place, as wide as their volume. Trade, migrations, deliveries and travel between places. - [Spike map](https://nervurejs.github.io/charts/spike-map): A spike at each place, as tall as its value. Populations and amounts by place, without hiding the map. - [Dot density map](https://nervurejs.github.io/charts/dot-density-map): Dots scattered inside each region, one dot for a given number, a colour for each group. How people or things spread over a land, and how groups mix. - [Hexbin map](https://nervurejs.github.io/charts/hexbin-map): Hexagons over the map, as dark as the number of points inside. Thousands of places, where single dots would pile up. - [Pin map](https://nervurejs.github.io/charts/pin-map): Pins that gather into numbered circles when close; a circle opens on zoom, a pin opens a card. Shops, agencies and sites to find on a map. - [Pie chart map](https://nervurejs.github.io/charts/pie-chart-map): A small pie at each place, as large as its total, cut by its parts. The mix of each place: energy, votes, sales by product. ## 3D - [3D bar chart](https://nervurejs.github.io/charts/3d-bar-chart): Isometric columns on a floor of rows and columns. A few values on two dimensions, when the picture has to strike. - [3D column chart](https://nervurejs.github.io/charts/3d-column-chart): Columns standing on a floor, the series side by side, with a grid on the back walls; drag to turn it. A cover page or a slide, with few categories and few series. - [3D cylinder chart](https://nervurejs.github.io/charts/3d-cylinder-chart): Round columns on a floor, side by side in each category. The same as columns, when round shapes suit the subject better. - [3D cone chart](https://nervurejs.github.io/charts/3d-cone-chart): Cones as high as their value, one for each category. A handful of values shown as peaks. - [3D stacked column chart](https://nervurejs.github.io/charts/3d-stacked-column-chart): Parts piled up into a column for each category. A total and what it is made of, on a cover page. - [3D 100 % stacked chart](https://nervurejs.github.io/charts/3d-100-stacked-chart): Round columns of the same height, cut into shares. How a mix changes from one category to the next, whatever the totals. - [3D pie chart](https://nervurejs.github.io/charts/3d-pie-chart): A pie with a thickness, seen from above, a slice pulled out. Two to five shares, when one of them has to stand out. - [3D donut chart](https://nervurejs.github.io/charts/3d-donut-chart): A ring with a thickness, seen from above. Shares, in a picture that has to strike more than inform. - [3D area chart](https://nervurejs.github.io/charts/3d-area-chart): Several series as ribbons, one behind the other. Three or four series over time, each with its own shape. - [3D surface](https://nervurejs.github.io/charts/3d-surface): A grid of heights drawn as a surface, coloured by height, that turns when dragged. A value that depends on two others: terrain, a response surface, a yield by price and volume. - [3D wireframe](https://nervurejs.github.io/charts/3d-wireframe): The same surface as a mesh of lines, the far side hidden. A light picture of a surface, printed or in a report. - [3D scatter plot](https://nervurejs.github.io/charts/3d-scatter-plot): Points in a box with three axes, sized by a fourth value, with lines down to the floor. Clusters on three measures, explored by turning the box. - [3D pyramid](https://nervurejs.github.io/charts/3d-pyramid): A pyramid cut into layers as high as their value, the first one at the top. Levels of a hierarchy or of a population. - [3D funnel](https://nervurejs.github.io/charts/3d-funnel): Round layers as wide as their value, from the first step to the last. A sales or sign-up funnel, on a slide. - [3D prism map](https://nervurejs.github.io/charts/3d-prism-map): Each place raised as high as its value, coloured by it too. Amounts by region, when a striking picture matters more than exact reading. - [3D bubble chart](https://nervurejs.github.io/charts/3d-bubble-chart): Bubbles in a box with three axes, as large as a fourth value, shaded like balls, with their shadows on the floor. Four measures at once, explored by turning the box. - [3D layered area chart](https://nervurejs.github.io/charts/3d-layered-area-chart): Each series as a solid layer filled down to the floor, one behind the other. Two to four series over time, on a cover page. - [3D stacked area chart](https://nervurejs.github.io/charts/3d-stacked-area-chart): The series piled up into one solid block, each layer on the one below. A total over time and what it is made of. - [3D line chart](https://nervurejs.github.io/charts/3d-line-chart): A path through a box with three axes, with balls at its points and its shadow on the floor. A trajectory: a flight, a walk, a value that moves on three measures. - [3D histogram](https://nervurejs.github.io/charts/3d-histogram): Columns on a grid of two kinds of categories, as high as their count and coloured by it. How a population spreads over two groupings: age and income, size and price. - [3D waterfall chart](https://nervurejs.github.io/charts/3d-waterfall-chart): Blocks that rise and fall from one total to the next. A bridge from one figure to another, on a slide. - [3D gauge](https://nervurejs.github.io/charts/3d-gauge): A dial with a thick ring, a bevel, coloured bands, a target and a needle. One figure against its range, on a cover or a dashboard that has to strike. - [3D tank chart](https://nervurejs.github.io/charts/3d-tank-chart): Glass tanks side by side, each filled up to its value. Levels and capacities: stocks, budgets used, reservoirs. - [3D cone chart](https://nervurejs.github.io/charts/3d-cone-chart): A cone cut into slices whose volume follows their value, the first one at the top. Levels of a hierarchy, when a round shape suits the subject. - [3D polar area chart](https://nervurejs.github.io/charts/3d-polar-area-chart): Wedges of the same angle around a centre, as wide and as high as their value. Values over the months or the directions of a compass. - [3D heatmap](https://nervurejs.github.io/charts/3d-heatmap): Raised tiles on a grid, each one as high and as dark as its value, with a colour scale. Activity by day and hour, when the peaks have to stand out. - [3D globe](https://nervurejs.github.io/charts/3d-globe): Bars standing on a globe at their places, as high as their value; drag to turn the Earth. Figures by city or site around the world, on a cover or a slide. - [3D building](https://nervurejs.github.io/charts/3d-building): A building whose floors are coloured by their value, the ground floor first. Occupancy, energy or rent floor by floor, for real estate. - [3D treemap](https://nervurejs.github.io/charts/3d-treemap): Treemap tiles raised as high as their value, or as a second value. Shares of a whole, when the picture has to strike. - [3D flow](https://nervurejs.github.io/charts/3d-flow): A Sankey diagram lying on a floor: blocks for the stages, thick ribbons for the flows. Where visitors, money or goods go, stage after stage. - [3D radar](https://nervurejs.github.io/charts/3d-radar): Radar polygons of several series raised as plates, one above the other. A few profiles over five to eight measures, year after year. - [3D progress tubes](https://nervurejs.github.io/charts/3d-progress-tubes): Glass tubes filled up to their value, a ring at their target. Progress towards goals, on a dashboard or a slide. - [3D pictorial chart](https://nervurejs.github.io/charts/3d-pictorial-chart): Units counted with 3D houses, cubes or trees, one lane for each item. Counts people grasp at once: homes sold, cars, trees planted. - [3D pictorial chart, cars](https://nervurejs.github.io/charts/3d-pictorial-chart-cars): The same lanes of icons, counted with cars. A fleet or sales by kind of vehicle. - [3D candlesticks](https://nervurejs.github.io/charts/3d-candlesticks): Candlesticks as boxes, as deep as their volume. Prices and volumes of a few weeks, in one picture. - [3D timeline](https://nervurejs.github.io/charts/3d-timeline): Events on posts along a road that goes away from the eye. A roadmap or the story of a project, on a slide. - [3D calendar wall](https://nervurejs.github.io/charts/3d-calendar-wall): A calendar heatmap as an isometric wall: one block for each day, as high as its value. Activity day by day over months, in the style of a contributions graph. ## Weather - [Meteogram](https://nervurejs.github.io/charts/meteogram): Temperature, rain and wind on one time axis: a line, bars and an arrow for each step. Forecasts for a place over a few days, the way weather services draw them. - [Wind rose](https://nervurejs.github.io/charts/wind-rose): How often the wind blows from each direction, petals split by speed, with the calm in the middle. Airports, wind farms, sailing, building sites: where the wind comes from and how strong. - [Sun path](https://nervurejs.github.io/charts/sun-path): The arc of the sun over a day, sunrise, sunset and twilights, the moon, and where the sun stands now. Daylight of a place and a date: gardens, photography, solar panels, events outdoors. - [Barometer](https://nervurejs.github.io/charts/barometer): Air pressure on the dial of a barometer, with the reading of a few hours before and the tendency. Weather stations, and telling whether the weather is about to change. ## Nature - [Tree rings](https://nervurejs.github.io/charts/tree-rings): The rings of a trunk, one a year, as wide as the growth of that year, with dry years pointed at. Climate history, forests, and any yearly growth told as a living thing. - [River level](https://nervurejs.github.io/charts/river-level): The height of a river over time, its flood levels as bands, the peak and the forecast. Flood warnings, rivers, reservoirs and tides. - [Air quality index](https://nervurejs.github.io/charts/air-quality-index): An index on its coloured bands, and the pollutants that make it. Cities, schools, health apps: is the air good today, and why not. - [Species count](https://nervurejs.github.io/charts/species-count): Rows of small animals, one for a number counted, with the change since the last survey. Bird counts, biodiversity surveys and reports for a wide audience. ## Electricity - [Load curve](https://nervurejs.github.io/charts/load-curve): Power used over a day, the peak hours shaded, and the price on a second scale. Grids, factories and buildings: when power is used, and what it costs then. - [Generation mix](https://nervurejs.github.io/charts/generation-mix): What makes the power of a grid over a day, source by source, with the demand on top. Grid operators, energy news, and how much of the power is low-carbon. - [Power plant board](https://nervurejs.github.io/charts/power-plant-board): Each unit as a tile: its state, what it gives and its capacity, and the totals. Control rooms and dashboards of producers. - [Electricity meter](https://nervurejs.github.io/charts/electricity-meter): The index of a meter on rolling digits, what was used since a reading, and its registers. Energy apps and bills: what a home or a site used. - [Tariff clock](https://nervurejs.github.io/charts/tariff-clock): A 24-hour dial of the tariff periods and their price, the use of each hour inside, and the hour now. Choosing when to run machines, charge a car or heat water. ## Nuclear - [Reactor panel](https://nervurejs.github.io/charts/reactor-panel): A reactor with its control rods and fuel, and its power, temperature and pressure beside. Teaching, simulators and plant dashboards. - [Dose rate dial](https://nervurejs.github.io/charts/dose-rate-dial): A dose rate of radiation on a logarithmic dial with its bands, and the dose added up against its limit. Radiation monitoring, labs, hospitals and the public around a site. - [Reactor fleet](https://nervurejs.github.io/charts/reactor-fleet): Reactors over weeks: running, refuelling, stopped, and the power the fleet has left. Planning outages and following the availability of a fleet. ## Oil and gas - [Crude oil spread](https://nervurejs.github.io/charts/crude-oil-spread): Two crude oil prices and the gap between them, as a band and as bars. Energy markets, trading desks and reports on oil. - [Tank farm](https://nervurejs.github.io/charts/tank-farm): Storage tanks in 3D, each filled to its level, as wide as its capacity. Depots, terminals and refineries: what is stored and where there is room. - [Refinery yields](https://nervurejs.github.io/charts/refinery-yields): A distillation column and the products drawn off it, light at the top, as thick as their share. What a barrel of crude becomes, for teaching and refinery reports. - [Gas storage](https://nervurejs.github.io/charts/gas-storage): How full the gas storage is over the year, against the range of past years and a target. Following the filling before winter, for a country or a site. - [Degree days](https://nervurejs.github.io/charts/degree-days): Heating degree days against the normal, with the gas used each month. Energy bills and building management: was it colder, or did we use more? ## Transport - [Delay heat strip](https://nervurejs.github.io/charts/delay-heat-strip): Lines down the side and hours across, each cell coloured by the average delay, with the share on time. Punctuality of a network by hour or by day, and where the rush hours hurt. - [Mode share](https://nervurejs.github.io/charts/mode-share): How people travel, split by mode with an icon for each, against a target or another year. Mobility plans, commuter surveys and city reports. - [Door-to-door journeys](https://nervurejs.github.io/charts/door-to-door-journeys): Several ways of making one trip, their legs to scale, with the time, cost and CO₂ of each. Comparing the metro, the bus, the bike and the car for the same trip. ## Cars - [Car dashboard](https://nervurejs.github.io/charts/car-dashboard): Speed and engine speed on two dials, the gear, fuel or battery, temperature and range. Telematics, driving simulators and fleet screens. - [EV charging session](https://nervurejs.github.io/charts/ev-charging-session): State of charge and charging power over a session, the energy added and when 80 % is reached. Charging apps, fleet reports and charger tests. - [Car service log](https://nervurejs.github.io/charts/car-service-log): Work done and to come along the odometer, and how far the next one is. Maintenance books, fleets and used car listings. ## Real estate - [Price per m² ladder](https://nervurejs.github.io/charts/price-per-m-ladder): Districts placed on one ladder by their price per m², their range beside, and a home placed on it. Valuations, listings and market reports. - [Rental yield grid](https://nervurejs.github.io/charts/rental-yield-grid): The yield of a rental for a range of prices and rents, the home studied ringed. Choosing a buy-to-let and how much to offer. - [3D building lots](https://nervurejs.github.io/charts/3d-building-lots): A building in 3D, its lots coloured by sale state, that turns when dragged. New-build programmes, sales offices and lettings. ## Financing - [Loan amortization](https://nervurejs.github.io/charts/loan-amortization): Principal, interest and insurance of each year of a loan, and what is left to pay. Mortgage and car loan simulators. - [Debt ratio gauge](https://nervurejs.github.io/charts/debt-ratio-gauge): Monthly charges against income on a dial with an example limit, and the income cut into its parts. Loan applications and budget advice. - [Borrowing capacity](https://nervurejs.github.io/charts/borrowing-capacity): How much one can borrow over 10 to 25 years, with the deposit and the price aimed at. Mortgage simulators and home buying plans. ## Crypto - [Halving and supply](https://nervurejs.github.io/charts/halving-and-supply): Coins issued against the cap, the reward of each era, and the blocks left to the next halving. Explaining the supply of a coin with halvings. - [Volatility cone](https://nervurejs.github.io/charts/volatility-cone): The range of past volatility over several windows, and where it stands now. Judging if a market is calm or wild against its own past. - [Crypto wallet](https://nervurejs.github.io/charts/crypto-wallet): What each coin is worth and its share, its move over a day, and the whole on a ring. Portfolio apps and wallet summaries. ## Money - [Compound savings](https://nervurejs.github.io/charts/compound-savings): What was put in and what the interest added, year by year, with a goal. Savings plans, pension and education funds. - [Budget envelopes](https://nervurejs.github.io/charts/budget-envelopes): One envelope for each kind of spending, filled as the money goes, with the pace of the month. Household budgets and team expense limits. - [Exchange rate board](https://nervurejs.github.io/charts/exchange-rate-board): An amount in several currencies, with the move and the path of each rate. Travel, payments and treasury screens. ## Products - [Product comparison matrix](https://nervurejs.github.io/charts/product-comparison-matrix): Products side by side, feature by feature, the best of each row marked. Shops, buying guides and product pages. - [Star ratings](https://nervurejs.github.io/charts/star-ratings): The average in stars, how many gave each number, and scores by aspect. Reviews on product pages and in shop reports. - [Price history with promotions](https://nervurejs.github.io/charts/price-history-with-promotions): Price over time, its promotions and the real cut against the lowest price before each. Price trackers and checking a sale. - [Stock level and reorder point](https://nervurejs.github.io/charts/stock-level-and-reorder-point): Stock over time against its reorder point and safety stock, with orders and their lead time. Inventory, purchasing and shop dashboards. # 3D charts Thirty chart types draw solids with a thickness: `pie3d`, `donut3d`, `columns3d`, `stacked3d`, `ribbon3d`, `area3d`, `surface3d`, `scatter3d`, `bubbles3d`, `line3d`, `histogram3d`, `heatmap3d`, `waterfall3d`, `gauge3d`, `cylinder3d`, `pyramid3d`, `funnel3d`, `cone3d`, `polar3d`, `map3d`, `globe3d`, `building3d`, `treemap3d`, `flow3d`, `radar3d`, `progress3d`, `pictorial3d`, `candles3d`, `timeline3d` and `wall3d`. They are plain SVG (no WebGL, no canvas), so they export to SVG and PNG, take the theme and the palette, have tooltips, a legend and keyboard reading like every other chart. `bars3d` is the older isometric chart of the main file. ## Load them The 3D types are a separate entry, so they do not grow the main file (about 35 kB gzipped for all thirty): ```ts import { createChart } from 'nervure'; import 'nervure/3d'; // registers the 3D types createChart(host, { type: 'pie3d', data: [{ name: 'Rent', value: 42 }, { name: 'Food', value: 30 }] }); ``` In a page without a bundler, load the browser file after the main one: ```html ``` `nervure/lazy` knows them too: `createChart` from `nervure/lazy` fetches the code of a 3D type the first time it is drawn. ## The view and turning it Every 3D chart takes a `view`, in degrees: `azimuth` turns around the vertical axis, `elevation` goes from the floor (0) to straight above (90). Each type has a default that shows it well. ```ts { type: 'surface3d', z, view: { azimuth: 60, elevation: 35 }, rotate: true } ``` With `rotate: true`: - a drag on the chart turns it (left and right around, up and down in height); - a button in the top right corner takes the focus with Tab; the arrow keys turn the view by steps, Enter or Home goes back to `view`. Each step draws the chart again from the new eye, so the labels, the tooltips and the order in which the faces cover one another stay right; nothing is a CSS transform. Turning keeps the size of the drawing, so nothing jumps. `chart.update(spec)` goes back to the view of the spec. The faces take the colour of their series in the light: tops lighter, sides darker. This works in the light and dark themes and with your palette (colours written as `#rgb`, `#rrggbb` or `rgb()`; other colours are drawn flat). With reduced motion, the charts appear at once, as every other chart does. ## The types | Type | Data | Options | |---|---|---| | `pie3d`, `donut3d` | `data: { name, value }[]` | `explode` (names or indexes), `depth`, `hole` (donut), `labels`, `legend` | | `columns3d` | `categories`, `series: { name, data }[]` | `shape: 'box' \| 'cylinder' \| 'cone' \| 'pyramid'`, `width`, `min`, `max` | | `stacked3d` | `categories`, `series` | `percent`, `shape: 'box' \| 'cylinder'` | | `ribbon3d` | `categories`, `series` | `thickness`, `curve: 'smooth'` | | `surface3d` | `z: number[][]`, `x`, `y` names | `colors`, `wireframe`, `titles` | | `scatter3d` | `series: { name, data: { x, y, z, size? }[] }[]` | `drops`, `radius`, `titles` | | `pyramid3d` | `data` (first at the top) | `sizing: 'value' \| 'equal'`, `shape: 'square' \| 'round'`, `gap` | | `funnel3d` | `data` (first at the top) | `shape`, `gap` | | `map3d` | `geo` (GeoJSON or TopoJSON), `values` by id | `key`, `nameKey`, `color`, `height` | | `bubbles3d` | `series: { name, data: { x, y, z, size }[] }[]` | `radius`, `shadows`, `titles` | | `area3d` | `categories`, `series` | `stacked`, `percent`, `thickness`, `min`, `max` | | `line3d` | `series: { name, data: { x, y, z, label? }[] }[]` (points in their order) | `markers`, `shadow`, `drops`, `titles` | | `histogram3d` | `z: number[][]`, `x`, `y` names | `colors`, `width`, `titles` | | `heatmap3d` | `columns`, `rows`, `values: number[][]` | `colors`, `height` | | `waterfall3d` | `data: { name, value, total? }[]` | `up`, `down`, `totalColor`, `width`, `connectors` | | `gauge3d` | `value` | `min`, `max`, `bands: { to, color }[]`, `target`, `name`, `unit`, `color` | | `cylinder3d` | `data: { name, value, max? }[]` | `max` (size of the tanks), `unit` | | `cone3d` | `data` (first at the top) | `sizing: 'volume' \| 'height' \| 'equal'`, `apex: 'top' \| 'bottom'`, `gap` | | `polar3d` | `data` | `radius: 'value' \| 'equal'`, `height`, `labels`, `legend` | | `globe3d` | `data: { name, lon, lat, value }[]` | `geo` (land), `shape: 'bar' \| 'spike'`, `height`, `color` | | `building3d` | `data` (the ground floor first; `value` may be null) | `colors`, `min`, `max`, `footprint`, `windows` | | `treemap3d` | `data: { name, value, height? }[]` | `height`, `legend` | | `flow3d` | `links: { source, target, value }[]` | `colors` by node | | `radar3d` | `axes`, `series` | `max`, `legend` | | `progress3d` | `data: { name, value, target?, max? }[]` | `max` | | `pictorial3d` | `data` | `icon: 'cube' \| 'house' \| 'car' \| 'tree' \| 'cylinder'`, `unit`, `perRow` | | `candles3d` | `data: { label, open, high, low, close, volume? }[]` | `up`, `down` | | `timeline3d` | `events: { label, date?, text? }[]` | `color` (of the road) | | `wall3d` | `data: { date: 'YYYY-MM-DD', value }[]` | `colors`, `weekStart` | A few notes on the newer types: - `area3d` fills each series down to the floor, as a solid layer behind the one before (the first series at the back); `stacked: true` piles the series into one block, `percent: true` makes every category 100 % high. `ribbon3d` draws the same data as thinner ribbons. - `bubbles3d` is `scatter3d` with a fourth value: the area of each ball follows its `size`, and its shadow on the floor tells where it stands. - `line3d` joins the points of each series in their order, a path through space, and draws it again on the floor; the pieces of the path and the balls are sorted by depth, so a path that crosses itself is drawn right. - `histogram3d` and `heatmap3d` take a grid of values: the first is a city of columns with an axis of heights, the second a flat grid of tiles with a colour scale, for when the colour matters more than the height. - `waterfall3d` reads `data` like the flat `waterfall`: a step adds its value to the running total, a `total` stands from the floor; the tooltips give the change and the running total. - `gauge3d` is a dial lying on a table: tilt it with `view.elevation` (90 shows it flat, from above). - `cylinder3d` fills a glass tank for each item; the tooltip gives the share of the tank and its size. - `cone3d` cuts a cone into slices; by default each slice holds a share of its volume as large as its value, so the slices near the point are taller. - `polar3d` gives each item a wedge of the same angle, as high as its value and with an area that follows it (`radius: 'equal'` keeps them all as wide). Every field is on the page of each chart in the [gallery](/charts/#three-d). ### Globes, buildings and other pictures - **`globe3d`** stands a bar (or a spike with `shape: 'spike'`) on each place, as high as its value, on a globe seen from far away. Without a `view`, the eye faces the middle of the places; drag it, or use the arrow keys of the turn button, to turn the Earth. `geo` draws the land (the `world` or `continents` file of `loadMap`); without it the globe has a grid of meridians and parallels only. Bars behind the Earth stay hidden, except where they stand out of its rim. - **`building3d`** colours each floor of a building by its value — occupancy, energy, rent — with windows on its walls and the names of the floors on the right. The first item is the ground floor. - **`treemap3d`** lays the tiles of a treemap on a floor and raises them, by their value or by a second value, `height` (the growth of a shop, its margin). - **`flow3d`** is a Sankey diagram lying on a table: a block for each node, the stages from left to right, the flows as thick ribbons as wide as their value. - **`radar3d`** raises the polygon of each series as a plate, the first one at the bottom; the dots on the plates are read with the keyboard. - **`progress3d`** fills a glass tube for each item up to its value, out of its own `max` or the common one; a dark ring marks its `target`. - **`pictorial3d`** counts units with icons in one lane for each item: `1 icon = 10` is written in the corner, and the last icon is cut to the share left over. The unit is chosen so that the longest lane holds at most 40 icons, unless `unit` says otherwise. - **`candles3d`** draws each candlestick as a box, as deep as its volume, with the prices on the back walls. - **`timeline3d`** puts events on posts along a road that goes away from the eye, the first one in front; a `date` places them, else they are evenly spaced. - **`wall3d`** is a calendar heatmap built as a wall of blocks, one for each day, weeks along the width and days of the week across. ## When 3D is a bad idea Most of the time. A 3D chart is harder to read than the flat one it comes from: - **Lengths and angles lie.** A slice at the front of a 3D pie looks larger than the same slice at the back; a column far away seems shorter. Readers compare shapes, not numbers. - **Things hide each other.** A tall column, ribbon or region covers what stands behind it. Turning helps, but a printed page or a screenshot cannot turn. - **The axes are hard to follow.** Reading a height against a grid on the back wall is slow and inaccurate. So prefer the flat charts — `xy` bars, `pie`, `heatmap`, `scatter`, `map` — to report figures, and keep 3D for a cover, a slide or a picture meant to strike, with few categories and the figures in the tooltips or in a table (`table: 'toggle'`). Two cases where 3D earns its place: a **surface** of a value that depends on two others, which a flat heatmap shows less naturally, and a **3D scatter** explored by turning it, to see clusters on three measures. The keyboard, the screen reader text and the CSV, Markdown and table exports carry the exact figures whatever the picture shows. ## Size The charts stay readable at 300 px wide; below 150 px the axes and labels give way, and below 110 px high the legend too, and only the drawing is kept. # Accessibility - Each chart is an image with a text: its `title` and `description`, or a summary of the data. Write your own `description` for what the chart shows. - Points, items and tree nodes that can be clicked take the focus and answer to Enter and Space. - Charts do not move for people who ask for reduced motion. - Text in shapes is black or white, whichever reads better. - Colour is not always enough: add labels, or a table beside the chart. ## Keyboard Tab reaches the chart. Then: | Key | Does | |---|---| | ← → | previous or next mark of the series | | ↑ ↓ | the same place in the previous or next series | | Home, End | first or last mark of the series | | Enter, Space | what a click on the mark does | | Escape | leaves the marks | The mark gets a ring and its tooltip, and a live region says it to screen readers: `Sales, Mar: 30`. Lines, bars, areas, scatter points, pie slices, treemaps and most charts that show one shape by value map to their marks. The others are read row by row from their table, with nothing drawn. Rings and tooltips do not move, so they suit readers who ask for reduced motion. Click the chart or reach it with Tab, then use the arrows. `keyboard: false` turns this off, for a sparkline in a list for example. ## Data table ```ts createChart(host, spec, { table: true }); // under the chart createChart(host, spec, { table: 'beside' }); // on the right, the drawing takes 60 % createChart(host, spec, { table: 'toggle' }); // a Table button in the toolbar ``` The table is plain HTML (`` with `
`), with the same rows as the CSV export and the format of the chart. It is never part of the SVG or PNG export. Style it with `.nervure-table`. ## Safety Names and categories are written as text, never parsed as HTML. `decorate` and colours come from your code: do not build them from what visitors type. # Animation ## On or off ```ts createChart(host, spec); // animated createChart(host, spec, { animation: false }); // drawn at once ``` People who ask their system for less motion get no animation, whatever you write. ## When ```ts createChart(host, spec, { animation: { start: 'load' } }); // at once, the default createChart(host, spec, { animation: { start: 'visible' } }); // when the reader scrolls to it const chart = createChart(host, spec, { animation: { start: 'manual' } }); button.onclick = () => chart.play(); // when you decide, as often as you want ``` The room of the chart is kept while it waits, so nothing on the page jumps. ## How | Option | Does | |---|---| | `speed` | `2` is twice as fast | | `duration` | milliseconds for each mark, instead of the timing of the chart | | `delay` | milliseconds before the first mark | | `stagger` | `false` moves every mark together | | `easing` | `linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out`, `bounce`, `elastic`, or any CSS easing such as `cubic-bezier(.34,1.56,.64,1)` | | `effect` | `fade` replaces movement by a fade | | `loop` | plays the entrance again and again, with a pause between two runs; `update()` and `refresh()` start it again with the new data, `destroy()` stops it | | `line` | how the lines of `xy` charts come in: `trace` (default), `grow` or `draw` | ## Easing `bounce` and `elastic` go past the end and come back. They are written as a CSS `linear()` curve; a browser that cannot read it uses the easing of the chart instead. ```ts createChart(host, spec, { animation: { easing: 'bounce' } }); createChart(host, spec, { animation: { easing: 'ease-out', duration: 600 } }); ``` ## Lines ```ts createChart(host, spec, { animation: { line: 'draw' } }); ``` | `line` | Lines come in | |---|---| | `trace` (default) | traced along their length, each series a little after the one before | | `grow` | up from the axis, with their areas and points | | `draw` | from left to right at an even pace: the line, its area, its dots and its labels are uncovered together, like a pen drawing it | `line` applies to lines, areas and bands of `xy` charts; bars and other charts keep their own entrance. With `effect: 'fade'`, lines fade like the rest. ## Loop ```ts createChart(host, spec, { animation: { loop: true, line: 'draw' } }); ``` The entrance plays again once every movement has ended, after a short pause, until `update` with another spec, `refresh` (live data) or `destroy`. People who ask their system for less motion see the chart drawn once, still. Charts use the Web Animations API of the browser: no timer runs once they are drawn. Only `liquid` and `pipeline` with `flow` move without end. `chart.update(spec)` plays again; `chart.refresh(spec)` does not, for live data. # Axes The value axes of `xy` charts are listed in `axes` (the first one is the default axis, on the left). `scatter` charts, bubbles included, take `xAxis` and `yAxis`. Every one of them reads the same options. | Option | Does | |---|---| | `min`, `max` | fixed ends: the data cannot move them | | `suggestedMin`, `suggestedMax` | ends the axis reaches at least; data beyond them still widens it | | `step` | gap between two ticks, such as `5` | | `ticks` | about how many ticks | | `format` | a function, or options: `{ currency: 'EUR', compact: true }` | | `tickFormat` | `(value, index) => string`: the text of each tick, from code | | `grid` | `false` hides the grid of this axis; `{ dashed: true, color: '#ccc' }` changes it | | `scale` | `log`: powers of ten; zero and negative values have no place on it | | `title` | the name of the axis | `step` and `ticks` round the range to the step; with `min` and `max` set, the ticks start at the first multiple of the step. A step that would write more than 200 ticks is ignored. A log axis has its ticks at the powers of ten, whatever `step` and `ticks` say. ## A suggested range A score out of 100 that only reached 64 so far still shows the whole scale; a score of 130 would widen it: ```ts axes: [{ suggestedMin: 0, suggestedMax: 100 }] ``` `min` and `max` win over the suggested ends. ## Ticks from code ```ts axes: [ { step: 1000, tickFormat: (value, index) => (index === 0 ? '' : `${value / 1000} k`) }, { side: 'right', format: { percent: true }, grid: false }, ] ``` `tickFormat` writes the ticks only; tooltips keep the `format` of the chart. ## Grid of each axis The first axis draws the grid by default, following `grid` of the chart (`false`, `'dashed'`). Each axis can draw its own: ```ts axes: [{ grid: false }, { side: 'right', grid: { dashed: true, color: '#94a3b8' } }] ``` ## Scatter and bubbles ```ts { type: 'scatter', data, xAxis: { min: 0, step: 10, title: 'Price' }, yAxis: { suggestedMax: 100, format: { compact: true }, grid: { dashed: true } }, } ``` `xAxis.title` and `yAxis.title` replace `xLabel` and `yLabel` when both are given. ## Axes crossing at zero `center: true` draws the two axes through zero, inside the drawing, with their ticks beside them: a plane of gains and losses, of four quadrants. When zero is out of the range, the axis stays at the nearest end. ```ts { type: 'scatter', center: true, data, xAxis: { suggestedMin: -40, suggestedMax: 40 } } ``` # CDN and plain HTML ```html
``` The web component is included: ```html ``` In production, name a version: the file never changes. ```html ``` Live data is included too: `nervure.live`, `nervure.poll`, `nervure.events`, `nervure.socket` and `nervure.append`, and so are `createDashboard` and `loadMap`. The made-up data of every chart sits in a second file, so the main one stays lighter. Load it after the first one and `nervure.sample(kind, seed)` and the dashboard templates (`nervure.template(name)`) are there: ```html ``` To draw Mermaid text with nervure, load the Mermaid reader after the first file: `nervure.fromMermaid(text)` gives a chart spec, or null when the text is not one nervure reads (see [Mermaid](./mermaid.md)). ```html ``` # Colours A colour is found in this order: `setColor`, then the one in the spec, then the palette. ## Palette ```ts createChart(host, spec, { theme: { palette: ['#30466b', '#d1495b', '#2a9d8f'] } }); ``` ## From code ```ts chart.setPalette(['#264653', '#e76f51', '#2a9d8f']); chart.setColor('Last year', '#b8b4ad'); // a series, a slice, a group, an item chart.resetColors(); ``` Try it with the colour pickers of the [editor](/editor). ## One point ```ts { name: 'Change', kind: 'bar', data: [42, -8], colors: [undefined, '#d1495b'] } ``` ## Named themes ```ts createChart(host, spec, { theme: 'dark' }); // or 'light', or 'auto' to follow the system ``` ## Theme ```ts const dark = { strong: '#f3f4f6', label: '#d1d5db', muted: '#9ca3af', grid: '#33383f', halo: '#1b1b1f', surface: '#1b1b1f' }; chart.update(spec, { theme: dark }); ``` The stylesheet can set them too: see [CSS](/guide/css). CSS variables work (`color: 'var(--brand)'`) and are replaced by their value in exports. # CSS Every mark is an SVG element of the page: select it and style it. `toSVG` and `toPNG` keep what your stylesheet changed. ## Variables ```css .report { --nervure-palette: #264653, #e76f51, #2a9d8f; --nervure-label: #333; --nervure-muted: #777; --nervure-grid: #eee; --nervure-strong: #000; --nervure-surface: #fff; --nervure-halo: #fff; --nervure-font: Inter, sans-serif; } @media (prefers-color-scheme: dark) { .report { --nervure-label: #ddd; --nervure-surface: #111; --nervure-halo: #111; } } ``` Call `chart.resize()` after you change a variable from code. The `theme` option wins over the stylesheet. ## What to select | Selector | Is | |---|---| | `svg.nervure[data-type="sankey"]` | a chart, by type | | `[data-part="axes"]` | grid, axis labels and titles | | `[data-part="series"]` | every mark | | `[data-part="legend"]`, `[data-part="legend-item"]` | the legend | | `[data-part="heading"]`, `[data-part="subheading"]` | titles in the drawing | | `[data-series="Last year"]` | the marks of a name | | `[data-direction="up"]` | candles and bricks that rise | | `.nervure-tooltip`, `.nervure-toolbar` | the tooltip and the export menu, in HTML | | `.nervure-card`, `.nervure-card-title` | dashboards | ## Try it # Your own chart A chart type is three functions. It gets the theme, the tooltip, the animation, the exports and the accessibility of the others. The type starts with `custom:`. If others could use it, [propose it](/contribute). # Dashboards ```ts import { createDashboard } from 'nervure/dashboard'; const board = createDashboard(host, { link: true, // a series hidden in one chart is hidden in all editable: true, // cards move with the mouse, or the arrow keys on their title onMove: (ids) => localStorage.setItem('order', JSON.stringify(ids)), items: [ { id: 'revenue', title: 'Revenue', width: 8, height: 3, spec: revenue }, { id: 'goal', title: 'Goal', width: 4, height: 3, spec: goal, options: { toolbar: true } }, ], }); board.update('goal', nextGoal); board.add({ id: 'map', title: 'Map', width: 12, spec: map }); board.move('map', 0); board.chart('revenue')?.download('png'); board.destroy(); ``` | Option | Default | Does | |---|---|---| | `columns` | 12 | columns of the grid | | `rowHeight`, `gap` | 110, 16 | pixels | | `stackUnder` | 640 | under this width, one card by line | | `sync` | | `true`: [linked cursors](/guide/linked) between the cards; a name: with charts outside too | | `syncZoom` | | with `sync`, zooming one `xy` card zooms the others | | `theme`, `locale`, `animation`, `toolbar`, `keyboard`, `table` | | given to every chart | Cards are plain HTML: style `.nervure-dashboard`, `.nervure-card` and `.nervure-card-title`. # Events `onClick` and `onHover` tell you which mark the reader points at: a bar, a slice, a point, a cell, a category of a line. ```ts import { createChart } from 'nervure'; createChart(host, spec, { onClick: (p) => openDetails(p.series, p.label, p.value), onHover: (p) => (status.textContent = p ? `${p.label}: ${p.value}` : ''), }); ``` ## What you receive | Field | Holds | |---|---| | `type` | type of the chart: `xy`, `pie`, `scatter`… | | `series` | series or group of the mark, when the chart has several | | `stack` | stack of a bar, on an `xy` chart with `stack` on its series | | `segment` | label of the segment of a line the mark is on (`segments`) | | `label` | category, name or label of the mark | | `value` | its number, when it has one | | `index` | place of the mark in its series (or among the categories); `-1` when the chart does not say | | `item` | the item of the spec it comes from: a slice, a point, a category | | `color` | its colour | | `title`, `rows` | what the tooltip writes by default | | `event` | the DOM event behind it: `click`, `pointermove`, `keydown` | `onHover` is called once each time the pointer reaches another mark, and with `null` when it leaves the marks. ## By chart | Chart | A mark is | |---|---| | `xy` lines and areas | a category: `series` and `value` are those of the series nearest to the pointer | | `xy` bars | a category, or the bar itself from the keyboard | | `pie`, `treemap`, `pack`, `funnel`, `waterfall` | a slice, a rectangle, a circle, a step: `item` is the entry of `data` | | `scatter` | a point (also when painted on a canvas): `item` is the point, `series` its `group` | | `radar` | an indicator: `series` is the series nearest to the pointer | | `heatmap` | a cell: `series` is the row, `label` the column | | other charts | the shape under the pointer, with its tooltip title as `label` | ## Keyboard and touch - **Enter** (or Space) on a mark reached with the arrow keys calls `onClick`, with a `keydown` event. See [accessibility](/guide/accessibility). - A tap opens the tooltip and calls `onHover`, then `onClick`. - A click on the legend or on the zoom buttons is not a click on a mark. The events add to what the specs already have (`onItemClick`, `onPointClick`): both are called. ## In frameworks ```tsx // React: the latest functions are called, no need to memoise them setSelected(p.label)} onHover={(p) => setHovered(p?.label ?? null)} /> ``` ```vue ``` ```svelte
(selected = p.label) }} style="height: 300px">
``` ```js // the element: point-click and point-hover, the point in event.detail document.querySelector('nervure-chart').addEventListener('point-click', (e) => console.log(e.detail.label)); ``` # Export ## A menu `toolbar: true` adds a small button. It takes the formats, their labels, the name of the file, an icon, and what to write in the file. The formats are `svg`, `png` and `csv` by default; `md` and `figma` are there when you ask for them: ```ts createChart(host, spec, { toolbar: { formats: ['svg', 'png', 'csv', 'md', 'figma'] } }); ``` ## From code ```ts await chart.download('png', 'orders', { title: 'Orders', subtitle: '2026', caption: 'Source: me', background: '#fff', padding: 24, scale: 3 }); const svg = chart.toSVG({ title: 'Orders' }); const png = await chart.toPNG({ scale: 2 }); const csv = chart.toCSV(); const md = chart.toMarkdown(); ``` | Option | Does | |---|---| | `title`, `subtitle`, `caption` | text written in the file only | | `background` | the theme in PNG, transparent in SVG | | `padding` | pixels around the drawing | | `scale` | PNG only, 2 by default | Headings, notes, what `decorate` adds and what your CSS changed are kept; tooltips and buttons are not. PNG files use system fonts, because a browser does not load web fonts inside an image. Cells of a CSV that look like a formula get a quote in front. ## Markdown `chart.toMarkdown()` writes the data of the chart as a Markdown table, under the title of the chart as a heading: the same rows as the CSV, with the figures written as on the chart (its `format` and `locale`) and numbers aligned to the right. Paste it in a README, an issue, a wiki or a message to a language model. On a server, without a chart, `toMarkdown(spec)` from `nervure/render` does the same. ## Figma `chart.toSVG({ figma: true })` writes an SVG made to be pasted in Figma, and `await chart.copyForFigma()` puts it on the clipboard (as `image/svg+xml` and as text): paste it in a Figma file and it becomes layers you can edit. In the menu, `figma` copies it, or saves the file when the browser refuses the clipboard. - Layers are named after the parts of the chart: `axes`, `series`, `legend`, `legend-item Sales`, `heading`… (`id` and `data-name`). - Text stays text, with its font family, size and weight written on it. A family Figma cannot know, such as `system-ui` or `sans-serif`, becomes Inter; set `font` in the theme to the font you use in Figma. - CSS variables and `currentColor` become the colours they stand for. Halos behind labels are dropped, as Figma draws them over the letters. - Nothing is in a `foreignObject`. Clip paths stay only where a chart needs them (liquid gauge, pictograms, avatars). ## Many points A scatter plot with more than 3000 points paints them on a canvas (`render: 'auto'`, or `'canvas'` and `'svg'` to choose). Axes, legend and labels stay SVG; the tooltip and the click still find the nearest point. In an SVG export the points become a picture (a PNG inside the SVG), drawn at the resolution of the screen; in a PNG export they are drawn as the rest. For a file with real vector points, set `render: 'svg'`: the browser is slower with that many elements, but the file can be edited point by point. # Figures A figure counts, stops exactly where you said, and compares itself. ## In the text of a page ```ts import { createFigure } from 'nervure/figure'; const sales = createFigure(host, { value: 1284500, label: 'Sales', format: { currency: 'EUR', compact: true, letters: ['K', 'M', 'B'] }, compare: [ { value: 1100000, label: 'last year' }, { value: 1300000, label: 'target', show: 'both' }, ], animation: { start: 'visible', duration: 1800 }, }); sales.update({ value: 1310000 }); // counts from the figure shown ``` ```html ``` ```tsx import { Figure } from 'nervure/react';
``` ```vue ``` ## In a card, with a trend The [`kpi`](/charts/key-figure) chart takes the same fields, and `trend`. The figures of `gauge`, `liquid`, `speedometer`, `thermometer` and `progress` count too. ## Formats Any chart takes `format`, and each axis its own. ```ts createChart(host, { ...spec, format: { currency: 'TND' }, axes: [{ format: { compact: true } }] }); ``` | Option | Writes | |---|---| | `currency: 'EUR'` | any ISO code; the symbol and its place follow `locale`. `CURRENCIES` lists forty of them | | `percent: true` | 64 as 64 % | | `percent: 'ratio'` | 0.64 as 64 % | | `unit: 'kg'` | a unit after the figure | | `prefix`, `suffix` | your own text | | `decimals: 1`, `decimals: [0, 2]` | digits after the point | | `compact: true` | short from 1,000 | | `compact: 10000` | short from 10,000 | | `letters: ['K', 'M', 'B', 'T']` | your letters, instead of those of the language | | `sign: true` | + before positive figures | | `locale: 'fr'` | another language than the chart | ```ts import { formatter } from 'nervure'; const euros = formatter({ currency: 'EUR', compact: true }, 'fr'); euros(12400); // 12,4 k € ``` A function works as well: `format: (v) => `${v} points``. ## Comparisons | Option | Does | |---|---| | `value` | the figure to compare with | | `label` | what it is: last year, target, average | | `show` | `percent`, `value`, or `both` | | `lowerIsBetter` | a fall is green | | `up`, `down` | your colours of good and bad | The arrow says the direction and the colour says if it is good news: neither is the only clue. A comparison with zero shows the difference, because a share of zero means nothing. ## Style `.nervure-figure-value`, `.nervure-figure-label`, `.nervure-delta` and `.nervure-delta[data-direction="down"]` are plain HTML. Digits keep the same width while they count. Screen readers hear the last figure once, and people who ask for less motion see it at once. # Frameworks The host element must have a height, and the spec should be memoised: a new object draws the chart again. ## React ```tsx import { useMemo, useRef } from 'react'; import { Chart } from 'nervure/react'; export function Orders({ rows }) { const chart = useRef(null); const spec = useMemo(() => ({ type: 'xy', categories: rows.map((r) => r.month), series: [{ name: 'Orders', kind: 'bar', data: rows.map((r) => r.count) }], }), [rows]); return { chart.current = c; }} />; } ``` ## Next.js The same component. `nervure/react` is already marked `'use client'`, so it can be imported from a server component as long as the spec holds no function. ```tsx // app/page.tsx import { Chart } from 'nervure/react'; export default async function Page() { const data = await getOrders(); return ; } ``` ## Vue ```vue ``` ## Nuxt ```vue ``` ## Svelte and SvelteKit ```svelte
``` ## Angular ```ts import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import 'nervure/element'; @Component({ selector: 'app-orders', schemas: [CUSTOM_ELEMENTS_SCHEMA], template: ``, }) export class OrdersComponent { spec = { type: 'funnel', data: [{ name: 'Visitors', value: 5200 }, { name: 'Customers', value: 310 }] }; } ``` ## Solid, Astro, Lit, Ember, HTMX, plain HTML Use the web component: ```html ``` From code, set the property: `element.spec = {…}`. It fires `ready`, with the chart in `event.detail`. # Install ::: code-group ```bash [npm] npm install nervure ``` ```bash [pnpm] pnpm add nervure ``` ```bash [yarn] yarn add nervure ``` ```bash [bun] bun add nervure ``` ```bash [Deno] deno add npm:nervure ``` ```bash [From GitHub] npm install github:nervurejs/nervure ``` ::: yarn, pnpm, bun and Deno read the npm registry: the package is the same everywhere. Without a bundler, use [one script tag](/guide/cdn). React and Vue are optional: they are needed only by `nervure/react` and `nervure/vue`. | Import | For | |---|---| | `nervure` | `createChart`, in any project | | `nervure/react` | React, Next.js, Remix, Gatsby | | `nervure/vue` | Vue 3, Nuxt | | `nervure/svelte` | Svelte, SvelteKit | | `nervure/element` | the `` web component, for Angular, Solid, Astro and plain HTML | | `nervure/live` | live data | | `nervure/server` | event streams on your server | | `nervure/stimulus` | Symfony UX, Rails, Laravel | | `nervure/dashboard` | dashboards | | `nervure/maps` | map files | | `nervure/lazy`, `nervure/core`, `nervure/charts/*` | [only what you draw](/guide/size) | | `nervure/samples` | made-up data for each chart | # Labels and notes | Field | Writes | |---|---| | `heading`, `subheading` | text above the chart | | `xTitle`, `axes[].title` | axis titles | | `showLabel` | the value of each point or bar | | `labels` | your own text for each value | | `labelAngle` | turned category names | | `format`, `axes[].format` | every number, or the numbers of one axis | | `lines` | a target, an average, a date | | `annotations` | a note on a point | ## From code ```ts chart.addLine({ value: 60, label: 'Average' }); chart.addAnnotation({ at: 'Feb', value: 73, text: 'Holiday' }); chart.clearNotes(); ``` ## Zones A shaded zone marks a period (a forecast, a holiday) or a range of values (a target band), behind the series. ```js zones: [ { from: 'Oct', to: 'Dec', label: 'Forecast' }, { min: 80, max: 100, label: 'Target', color: '#2a9d8f' }, ] ``` Gauges take several marks (`target: [100, 90]`, the first one thicker) and progress bars a mark and a second line each (`target`, `detail`). ## Your own elements `decorate` receives the SVG: add a header or a watermark, which exports keep. ```ts { ...spec, insetTop: 40, decorate: ({ svg, width, theme }) => { /* append elements */ } } ``` # Legend Charts with a `legend` field take `true`, `false`, or options: ```ts createChart(host, { type: 'xy', legend: { position: 'right', align: 'start' }, categories: ['Q1', 'Q2', 'Q3', 'Q4'], series: [/* … */], }); ``` | Option | Values | |---|---| | `position` | `bottom` (default), `top`, `left`, `right` | | `align` | `center` (default), `start`, `end`: along the bottom or top line, or down the column on a side | | `onClick` | `(name, visible) => …`: called before a name is switched; return `false` to keep it as it is | - On a side, the legend takes a column of about a quarter of the width, one name by line. Under 360 pixels wide it goes back to the bottom, so small charts keep their room. - `xy`, `scatter`, `pie`, `radar`, `density`, `ecdf`, `qq`, `flowmap`, `dotdensity` and `piemap` take the options. On a `pie`, `legend: true` writes a legend instead of the labels around it; `false` hides it. ## onClick `visible` is the state the name is about to take. ```ts legend: { onClick: (name, visible) => { if (!visible && name === 'Total') return false; // Total cannot be switched off track('legend', name, visible); }, }, ``` The `onToggle` render option is still called after each switch. ## A legend of your own Turn the legend off, read its names with `legendItems()`, and switch them with `toggle()`: ```ts const chart = createChart(host, { ...spec, legend: false }); function drawLegend() { list.replaceChildren( ...chart.legendItems().map(({ name, color, visible }) => { const button = document.createElement('button'); button.textContent = name; button.style.borderLeft = `12px solid ${color}`; button.setAttribute('aria-pressed', String(visible)); button.onclick = () => { chart.toggle(name); drawLegend(); }; return button; }), ); } drawLegend(); ``` `legendItems()` returns `{ name, color, visible }` for each name: those of the legend drawn, or, without one, the series (or the slices of a pie) of the spec. Colours chosen with `setColor` or `setPalette` are included. # Lines, gaps and segments ## Missing values A `null` in the data of a line or an area is a missing value. `gaps` says how to draw it: | `gaps` | Draws | |---|---| | `break` (default) | the line stops, and starts again after the gap; an isolated point keeps its dot | | `join` | the points on each side of the gap are linked | | `zero` | the missing value at 0, and 0 stays inside the axis | ```ts series: [ { name: 'Sensor A', data: [12, null, 15, 16, null, 14], gaps: 'join' }, { name: 'Sensor B', data: [8, 9, null, null, 11, 10] }, // break { name: 'Sales', kind: 'area', data: [4, 6, null, 5], gaps: 'zero' }, ] ``` With `gaps: 'zero'`, the value stays missing for the tooltip, the keyboard and the table: only the drawing shows 0. Bands (`kind: 'band'`) follow `gaps` too, on both of their lines. ## Segments `segments` draws part of a line another way, by index in the series: from the point at `from` to the one at `to` (the last one when `to` is left out). ```ts { name: 'Sales', data: [62, 70, 74, 81, 77, 86, 90, 84, 92, 95, 99, 104], segments: [{ from: 8, dashed: true, label: 'forecast' }], } ``` | Field | Does | |---|---| | `from`, `to` | first and last index of the stretch | | `dashed` | dashes; the dots of the stretch are left out, as on a dashed line | | `color` | colour of the line, of its dots and of the area under it | | `opacity` | opacity of the line, and of the area under it | | `label` | said after the name of the series in the tooltip and to screen readers: `Sales (forecast), Dec: 104` | The line is drawn once for the whole series and once for each segment, each copy kept to its stretch: the curve is the same on both sides of a change, with `curve: 'linear'`, `'smooth'` or `'step'`, and so is the area under it. Segments follow the zoom and `thin`: they are counted in the indexes of the whole series. They should not overlap; when they do, the last one listed wins for the dots and the tooltip. The SVG and PNG exports keep them. # Linked charts Charts given the same `sync` name show the same place under the pointer: the crosshair and the tooltip follow in each of them. ```ts const options = { sync: 'sales', syncZoom: true }; createChart(visits, visitsSpec, options); createChart(orders, ordersSpec, options); ``` - Categories are matched by name, so the charts may have them in another order, or only some of them. - On a [time axis](/guide/time), the nearest date is shown, even when the charts have different dates. - A `scatter` shares its x value: the nearest point of the others is shown. - `syncZoom: true`: dragging to zoom an `xy` chart with `zoom` shows the same categories in the others; a double click brings them all back. - `destroy()` leaves the group. Groups live in the page only: nothing is global. In a [dashboard](/guide/dashboards), `sync: true` links every card. # Live data `live` feeds a chart from a source. It retries with growing waits after an error, stops while the tab is hidden, and draws at most ten times a second. ## Market price ```ts import { append, live, poll } from 'nervure/live'; const spec = { type: 'xy', categories: [], series: [{ name: 'Price', data: [], dots: false }] }; const chart = createChart(host, spec); const feed = live(chart, spec, poll('/api/price', { every: 1000 }), { apply: (data, previous) => append(previous, data.time, { Price: data.price }, 60), onStatus: (status) => console.log(status), }); ``` The figures on this page are made up in your browser. ## Processor and memory ## Sources ```ts poll('/api/cpu', { every: 2000, init: { headers: { Authorization: `Bearer ${token}` } } }); // an API, every 2 s poll(async (signal) => (await client.read({ signal })).value, { every: 5000 }); // your own function events('/api/cpu/stream'); // server-sent events socket('wss://example.com/prices', { hello: { subscribe: ['EURUSD'] } }); // WebSocket ``` | Source | Use it when | |---|---| | `poll` | you have a plain API; every few seconds is enough | | `events` | your server pushes; one way, over plain HTTP, see [server side](/guide/server) | | `socket` | many messages a second, or an existing WebSocket feed | `poll` waits for an answer before it counts the next interval, so a slow API is never called twice at once. ## Control ```ts feed.pause(); feed.resume(); feed.stop(); // call it when the chart goes away feed.status; // connecting, live, paused, retrying or stopped ``` | Option | Default | Does | |---|---|---| | `apply` | | turns a message into the next spec; `null` ignores it | | `throttle` | 100 | at most one drawing in this time (ms) | | `retry` | 1 s to 30 s | waits after errors; `false` gives up | | `pauseWhenHidden` | `true` | stops while the tab is hidden | | `onStatus`, `onError` | | follow what happens | ## Long series A year of minutes is more points than pixels. `thin` keeps the lowest and the highest point of each stretch, so peaks and dips stay visible, and the chart stays quick to draw. The data is untouched: the table and the CSV export keep every point, and zooming in brings the detail back. ```js createChart(el, { type: 'xy', categories, series, thin: true, zoom: true }); // or the most points kept createChart(el, { type: 'xy', categories, series, thin: 500 }); ``` ## In React ```tsx { if (chart) feed.current = live(chart, spec, events('/api/cpu/stream'), { apply }); else feed.current?.stop(); }} /> ``` ::: warning Keep keys on your server A key used in the browser can be read by everyone. Call paid or private APIs from your server, and let the chart read yours. ::: # Maps ```ts import { createChart } from 'nervure'; import { loadMap } from 'nervure/maps'; const geo = await loadMap('countries/tn'); createChart(host, { type: 'map', geo, values: { 'TN-11': 1056, 'TN-61': 955 }, legend: true, zoom: true }); ``` ## Files | Path | Holds | |---|---| | `world`, `continents` | every country; every continent | | `continents/africa` … | the countries of a continent | | `countries/tn` … | the regions of a country, by its two-letter code | | `france/departements`, `france/departements-outre-mer` | French departments | | `france/communes/75` … | the municipalities of a department | They are fetched from this site and kept in memory. To serve them yourself, copy the [maps folder](https://github.com/nervurejs/nervure/tree/main/maps) and give its address: `loadMap('world', '/maps')`. [Look at all of them](/maps/). ## Your own map Any GeoJSON or TopoJSON works: pass it as `geo`, with `key` for the property that identifies a place and `nameKey` for its name. ## Projections `mercator` (default), `equirectangular`, `naturalEarth` for the world, `equalEarth` and `gallPeters` for [true sizes](/maps/true-size), `conic` for a country far from the equator, `orthographic` for a globe that can be turned. ## Language Maps hold `name`, `name_fr` and `name_ar`: `nameKey: 'name_ar'` shows Arabic names. # Mermaid `fromMermaid` reads Mermaid text and gives back a nervure spec, or `null` when it does not know the diagram. An app that receives Mermaid blocks, from a person or from an assistant, can draw them with nervure and keep Mermaid itself for everything else. ```bash npm install nervure ``` ```ts import { createChart } from 'nervure'; import { fromMermaid } from 'nervure/mermaid'; const text = `pie title Pets "Dogs" : 386 "Cats" : 85 "Rats" : 15`; createChart(document.querySelector('#chart')!, fromMermaid(text)!); ``` The reader is a separate entry, `nervure/mermaid` (about 8 kB gzipped): it does not grow the main bundle. It has no dependency and never throws. ## The fallback `fromMermaid` returns `null` for a kind of diagram it does not know (class, state, git graph…) and for any line it does not understand. Mermaid then draws the block as it would have: ```ts import { createChart } from 'nervure'; import { fromMermaid } from 'nervure/mermaid'; async function drawWithMermaid(host: HTMLElement, text: string) { const { default: mermaid } = await import('mermaid'); const { svg } = await mermaid.render(`m${Date.now()}`, text); host.replaceChildren(new DOMParser().parseFromString(svg, 'image/svg+xml').documentElement); } export function drawDiagram(host: HTMLElement, text: string) { const spec = fromMermaid(text); return spec ? createChart(host, spec) : drawWithMermaid(host, text); } ``` In short: `fromMermaid(text) ?? drawWithMermaid(text)`. ## What is read | Mermaid | nervure type | Read | Left out | |---|---|---|---| | `flowchart`, `graph` (TD, TB, BT, LR, RL) | `flowchart` | nodes and their shapes (`[]`, `()`, `([])`, `[[]]`, `[()]`, `(())`, `{}`, the hexagon, `[//]`, `>]`, `@{ shape }`), links `-->`, `---`, `-.->`, `==>`, `<-->`, `--o`, `--x`, with `\|text\|` or `-- text -->`, chains and `&`, `style` and `classDef` fill colours, `;` between statements | subgraph frames (their nodes are kept), `~~~` links, link styles, clicks; BT and RL are drawn top to bottom and left to right | | `sequenceDiagram` | `sequence` | `participant`, `actor`, aliases (`as`), messages `->>`, `-->>`, `->`, `-->`, `-x`, `-)` (dashed for answers), `autonumber`, title | notes, activations; `loop`, `alt`, `opt`, `par`, `critical`, `break`, `rect`, `box` are drawn as plain messages | | `gantt` | `gantt` | `dateFormat` (YYYY, MM, DD, HH, mm, ss, X, x), tasks with ids, dates, durations (`ms`, `s`, `m`, `h`, `d`, `w`, `M`, `y`), `after a b`, `until a`, `done` (progress 1), `crit` (red), `milestone` | sections (the tasks keep their order), `excludes` (every day counts), axis settings | | `timeline` | `events` | periods and their events, `: event` lines under a period | sections | | `mindmap` | `mindmap` | the tree from the indentation, every node shape, Markdown strings | icons, classes | | `pie` | `pie` | `"label" : value`, title (on its own line or after `pie`) | `showData`; negative slices | | `journey` | `journey` | tasks, scores, the people taking part (as touchpoints) | sections | | `quadrantChart` | `quadrant` | axes `Low --> High`, `quadrant-1` to `quadrant-4`, points from 0 to 1 with their colour (`color:` or a class) | point radius and stroke | | `erDiagram` | `er` | entities, aliases (`p[Person]`), attributes (type, name, PK, FK, UK), relations with both ends (`\|\|--o{`, and words such as `one or more to zero or one`), written `places (1 to 0..n)` | attribute comments | | `kanban` | `kanban` | columns and cards, `assigned` (owner), `ticket` or `priority` (tag) | the ticket link | | `xychart-beta` | `xy` (bars and lines on one chart) | categories or a numeric x axis, axis titles, the y range, any number of `bar` and `line` series, `horizontal`; also as assistants write it: spaces between thousands (`[335 678, 412 000]`), unquoted titles, one value per line (`bar 335678 "2023"`), and no header when the lines are clearly an XY chart (a warning says so) | | | `sankey-beta` | `sankey` | CSV lines `source,target,value`, quoted fields | | Around every diagram: a Markdown fence, front matter (its `title` becomes the heading), `%%{init}%%` directives, `%%` comments, Windows line ends, `accTitle` and `accDescr` (the accessible title and description). Labels lose their quotes, `
` and other tags, and character codes such as `#quot;` are written out. ## Warnings `parseMermaid` gives the spec, the kind of diagram and what was left out: ```ts import { parseMermaid } from 'nervure/mermaid'; const result = parseMermaid(text); if (result) { result.kind; // 'sequence' result.spec; // { type: 'sequence', actors: [...], messages: [...] } result.warnings; // ['Notes are left out.'] } ``` An app can choose Mermaid when there are warnings, or show them beside the chart. ## Without a bundler Load `cdn/nervure.mermaid.min.js` after the main file: `nervure.fromMermaid` and `nervure.parseMermaid` are then there. ```html ``` ## On a server With [`nervure/render`](/guide/server), a Mermaid block becomes an SVG string without a browser: ```ts import { fromMermaid } from 'nervure/mermaid'; import { renderToSVG } from 'nervure/render'; const spec = fromMermaid(text); const svg = spec ? renderToSVG(spec, { width: 800, height: 400 }) : null; ``` # Plugins A plugin draws something more on a chart, at each drawing: a frame, a text in the hole of a donut, a message when there is no data. ```ts import { createChart, registerPlugin } from 'nervure'; import { centerLabel, emptyState, plotAreaBorder } from 'nervure/plugins'; // on one chart createChart(host, donut, { plugins: [centerLabel({ text: '1,284', sub: 'orders' })] }); // on every chart drawn from now on const remove = registerPlugin(emptyState({ text: 'Nothing to show yet' })); remove(); // when no longer wanted ``` `nervure/plugins` is a file of its own: the main bundle does not grow when you do not use it. ## Ready-made | Plugin | Draws | Options | |---|---|---| | `plotAreaBorder()` | a frame around the area where the data is drawn, inside the axes | `color`, `width`, `radius`, `dashed`, `fill` (behind the marks) | | `centerLabel({ text })` | a text in the hole of a donut, a pie or a gauge; in the middle for other charts | `text`, `sub` (a line under it), `color`, `size`; `text` and `sub` can be functions of the context | | `emptyState()` | a message in the middle when the spec has no value | `text` (`No data`), `color` | ## Your own A plugin is an object with an `id` and up to three hooks: ```ts import type { NervurePlugin } from 'nervure'; const watermark: NervurePlugin = { id: 'watermark', afterDraw(c) { c.add('text', { x: c.area.x + c.area.width - 6, y: c.area.y + c.area.height - 6, 'text-anchor': 'end', 'font-size': 10, 'font-family': c.theme.font, fill: c.theme.muted, }, 'below', 'Draft'); }, }; ``` | Hook | When | |---|---| | `beforeDraw(context)` | the drawing is empty; `area` is still the whole drawing | | `afterDraw(context)` | the chart is drawn; `area` and `hole` are known | | `onDestroy(context)` | `destroy()`: let go of what you hold | The context: | Field | Holds | |---|---| | `svg`, `width`, `height` | the SVG of the chart and its size in pixels | | `area` | `{ x, y, width, height }` where the data is drawn (inside the axes of `xy`, `scatter`, `heatmap`, `waterfall`…, the circle of a `pie` or a `radar`); the whole drawing for the other charts | | `hole` | `{ x, y, r }` of the hole of a donut, a pie or a gauge | | `spec`, `theme` | the spec drawn, and the colours and font in use | | `empty` | true when the spec has no value | | `below`, `above` | two layers, under the chart (grid and marks) and above it, emptied at each drawing | | `add(tag, attributes, layer?, text?)` | adds an SVG element to a layer, `above` by default; `text` is written as text | - Use `c.theme` colours: plugins then follow the light and dark themes. - What a plugin draws is part of the SVG and PNG exports, and of [`renderToSVG`](/guide/server). - One plugin by `id`: a plugin given to a chart replaces a registered one with the same `id`. - Elements above the marks should take `pointer-events="none"`, so the tooltip keeps working under them. # Series and bars The `xy` chart (lines, areas and bars) takes a few fields that change how each series is drawn. | Field | Where | Does | |---|---|---| | `stack` | a series | with `stacked`, bars of the same stack pile up; other stacks stand beside them | | `color`, `colors` | a series | a colour, or a function of each value (from code only) | | `dots` | a series | `false` hides the points, `{ shape, size }` changes them | | `radius` | the chart | rounded corners of the bars, in pixels (4 by default, 0 for square bars) | | `barWidth` | the chart | share of a category taken by its bars, from 0 to 1 (0.72 by default) | ## Stack groups With `stacked: true`, every bar series piles into one bar per category. Give series a `stack` name and each name gets a pile of its own, side by side in the category: two totals and their parts, compared at once. ```js { type: 'xy', categories: ['Q1', 'Q2', 'Q3', 'Q4'], stacked: true, legend: true, series: [ { name: 'Coffee (Shop)', kind: 'bar', stack: 'Shop', data: [30, 34, 28, 41] }, { name: 'Tea (Shop)', kind: 'bar', stack: 'Shop', data: [18, 22, 25, 20] }, { name: 'Coffee (Web)', kind: 'bar', stack: 'Web', data: [12, 19, 26, 33] }, { name: 'Tea (Web)', kind: 'bar', stack: 'Web', data: [9, 11, 14, 18] }, ], } ``` - Series without a `stack` share one pile, as before. - `stacked: 'percent'` fills 100 % with each stack on its own. - `totals: true` writes one total by stack at the end of horizontal bars, and lists them all in the tooltip (`Total Shop`, `Total Web`). - The keyboard says the stack with the name of the series (`Coffee (Shop), Q1: 30`) when there are several stacks. - `stack` does nothing on bars that are not stacked. CSV and Markdown exports keep one column for each series. ## Colours from values `color` and `colors` take a function as well as a text: `(value, index, category) => colour`. It is called for each value that is not empty; `index` is the place in `data` (zoomed or thinned charts give the same index), `category` the text of the category (a date as `2024-03-01`). ```ts series: [{ name: 'Result', kind: 'bar', data: [12, -4, 8, -9, 15], color: (value) => (value < 0 ? '#dc2626' : '#16a34a'), }] ``` - A list in `colors` wins over the function, point by point. - The legend, the line of a line series and the exports take the first colour worked out. - Pie and donut charts take `color: (value, index, name) => colour` for the slices with no colour of their own; scatter charts take `color: (y, index, label) => colour`. ::: warning From code only A function cannot be written in JSON. Specs written as JSON (the editor, the MCP server, the `spec` attribute of ``, Symfony and Laravel templates) keep plain colour texts: work out the colours before, into `colors`. ::: ## Point shapes `dots` takes `{ shape, size }`: `circle`, `square`, `triangle`, `diamond`, `cross`, `star` or `rect-rot` (a square on its corner), and a radius in pixels (4 by default). The legend shows the shape. Shapes tell series apart without colour: on paper in grey, or for readers who do not see every colour. ```js series: [ { name: 'North', data: [42, 48, 45, 53], dots: { shape: 'square', size: 5 } }, { name: 'South', data: [35, 39, 44, 41], dots: { shape: 'triangle', size: 5 } }, ] ``` The same shapes work on other charts: - scatter: `shape` on the chart, or on one point (`data: [{ x, y, label, shape: 'star' }]`); points painted on a canvas (`render`) stay circles; - radar: `dots: true` or `{ shape, size }` on a series puts a point on each corner. On a line cut into `segments`, each point takes the colour of its segment; dashed lines and dashed segments have no points, except a point alone between two gaps. Points keep what screen readers say and what the keyboard reads: the shape is only drawn. ## Bars ```js { type: 'xy', radius: 0, barWidth: 0.9, categories, series } ``` `radius` rounds the end of each bar (the end of each pile when stacked); `barWidth` is the share of the category that the bars of one category take together, grouped or stacked. # Server side `eventStream` calls your function every `every` milliseconds and sends what it returns. It answers with a Web `Response`, so it runs anywhere that speaks them. It stops when the visitor leaves. ## Next.js ```ts // app/api/cpu/route.ts import os from 'node:os'; import { eventStream } from 'nervure/server'; export const dynamic = 'force-dynamic'; export const GET = (request: Request) => eventStream(() => ({ time: new Date().toLocaleTimeString('en-GB'), load: Math.round((os.loadavg()[0] / os.cpus().length) * 100), }), { every: 1000, signal: request.signal }); ``` In the browser: `events('/api/cpu')`. ## A paid API, with the key kept secret ```ts export const GET = (request: Request) => eventStream(async (signal) => { const r = await fetch('https://api.example.com/quote?symbol=ACME', { headers: { 'X-Api-Key': process.env.QUOTE_KEY! }, signal }); if (!r.ok) throw new Error(`HTTP ${r.status}`); // this message is skipped return r.json(); }, { every: 5000, signal: request.signal }); ``` Each visitor opens its own stream. With many visitors, read the API once, keep the answer, and send it to all. ## Other servers ::: code-group ```ts [Hono, Bun, Deno, Workers] app.get('/stream', (c) => eventStream(read, { every: 1000, signal: c.req.raw.signal })); ``` ```ts [SvelteKit] export const GET = ({ request }) => eventStream(read, { every: 1000, signal: request.signal }); ``` ```ts [Nuxt] export default defineEventHandler(() => eventStream(read, { every: 1000 })); ``` ```ts [Astro] export const GET = ({ request }) => eventStream(read, { every: 1000, signal: request.signal }); ``` ::: PHP, Python, Go or any other language: send `text/event-stream` with one `data: {…}` line of JSON followed by an empty line, and `events()` reads it. ## SVG on the server `nervure/render` draws a chart without a browser and returns a standalone SVG string. It runs in Node, Deno, Bun and edge workers, with no dependency: a small document of its own stands in for the DOM while the chart is drawn, then goes away. ```ts import { renderToSVG, toMarkdown } from 'nervure/render'; const svg = renderToSVG( { type: 'xy', title: 'Orders', categories: ['Jan', 'Feb', 'Mar'], series: [{ name: 'Orders', kind: 'bar', data: [120, 180, 150] }] }, { width: 640, height: 320, theme: 'light', locale: 'en-GB', format: { compact: true } }, ); const table = toMarkdown(spec); // the data as a Markdown table, under the title ``` | Option | Does | |---|---| | `width`, `height` | pixels, 600 × 320 by default | | `theme` | `light` by default, `dark`, or your own colours | | `locale` | how numbers and dates are written | | `format` | how figures are written when the spec has no `format` | | `title`, `subtitle`, `caption`, `background`, `padding`, `figma` | as in [Export](./export.md) | Every chart type renders, maps included when you pass their GeoJSON or TopoJSON. Nothing moves and nothing reacts to the pointer. Text widths are estimated, since there is no font to measure: a long label may be cut a little sooner or later than in a page. A scatter plot with many points is drawn with SVG circles, as there is no canvas. ### A Node script ```js // charts.mjs: writes one file for each chart of the report import { writeFileSync } from 'node:fs'; import { renderToSVG } from 'nervure/render'; for (const [name, spec] of Object.entries(report)) writeFileSync(`out/${name}.svg`, renderToSVG(spec, { width: 800, height: 400 })); ``` ### Symfony, Laravel and other back ends PHP, Python or Ruby call a small Node service that turns a spec into an SVG. Keep it on the inside of your network. ```js // chart-service.mjs: node chart-service.mjs import { createServer } from 'node:http'; import { renderToSVG } from 'nervure/render'; createServer(async (request, response) => { let body = ''; for await (const part of request) body += part; try { const { spec, options } = JSON.parse(body); response.writeHead(200, { 'content-type': 'image/svg+xml' }).end(renderToSVG(spec, options)); } catch (e) { response.writeHead(400).end(String(e)); } }).listen(3020, '127.0.0.1'); ``` ::: code-group ```php [Symfony] $svg = $this->httpClient->request('POST', 'http://127.0.0.1:3020', [ 'json' => ['spec' => $spec, 'options' => ['width' => 640, 'height' => 320]], ])->getContent(); ``` ```php [Laravel] $svg = Http::post('http://127.0.0.1:3020', [ 'spec' => $spec, 'options' => ['width' => 640, 'height' => 320], ])->body(); ``` ::: A spec sent as JSON has no functions: write figures with format options (`{ currency: 'EUR', compact: true }`) instead of a function. ### Images in an e-mail Most e-mail programs do not show SVG. Turn the SVG into a PNG on the server, with a tool such as `@resvg/resvg-js` or `sharp`, and attach it or link it. Give it a `background`, since a mail can be dark. ```js import { Resvg } from '@resvg/resvg-js'; const png = new Resvg(renderToSVG(spec, { background: '#ffffff' }), { fitTo: { mode: 'width', value: 1280 } }).render().asPng(); ``` ### PDF Put the SVG in the HTML page that your PDF tool prints (Chromium, Gotenberg, WeasyPrint), or give the file to a tool that reads SVG (Typst, Inkscape, `svg-to-pdfkit`). The text stays text, so it stays sharp and can be searched. # Size and lazy loading You ship what you draw. nervure has no dependency, and each chart is a module of its own. ## Pick your charts ```ts import { createChart, registerChart } from 'nervure/core'; import { pie } from 'nervure/charts/basic/pie'; import { xy } from 'nervure/charts/basic/xy/index'; registerChart('pie', pie); registerChart('xy', xy); ``` The rest never enters your bundle. The [source folder](https://github.com/nervurejs/nervure/tree/main/src/charts) lists the paths. ## Load when drawn ```ts import { createChart, load } from 'nervure/lazy'; const chart = await createChart(host, spec); // fetches the code of its type, once await load('sankey', 'map'); // ahead of time ``` Vite, webpack, Rollup, esbuild and Parcel make a small file of each type. Before you give another type to `chart.update`, call `load` for it. ## In a framework `nervure/react`, `nervure/vue` and `nervure/svelte` hold every chart. `nervure/react/core`, `nervure/vue/core` and `nervure/svelte/core` hold none: register those you draw. ```tsx import { registerChart } from 'nervure/core'; import { gauge } from 'nervure/charts/basic/gauge'; import { Chart } from 'nervure/react/core'; registerChart('gauge', gauge); ``` ## Many points A scatter plot paints more than 3000 points on one canvas; axes, legend and labels stay SVG, and the tooltip finds the nearest point. Draw 100 000 points here, with a canvas and with SVG: ## While it runs A chart that is drawn does nothing: no loop, no timer. Live charts stop in hidden tabs, and draw at most ten times a second. # First chart ```ts import { createChart } from 'nervure'; const chart = createChart(document.querySelector('#chart')!, { type: 'xy', categories: ['Jan', 'Feb', 'Mar', 'Apr'], legend: true, series: [ { name: 'This year', data: [12, 18, 25, 31] }, { name: 'Last year', data: [10, 14, 20, 24], dashed: true }, ], }); ``` The host element must have a size; the chart follows it. ```css #chart { height: 300px; } ``` ## Change it ```ts chart.update(nextSpec); // with the entrance animation chart.refresh(nextSpec); // at once, for live data chart.destroy(); // when you are done ``` ## Options ```ts createChart(host, spec, { locale: 'en-GB', animate: false, theme: { font: 'Inter, sans-serif' } }); ``` # Symfony and Laravel Two Composer packages bring nervure to PHP: **`nervure/symfony`**, a Symfony UX bundle, and **`nervure/laravel`**, for Blade and Livewire. Both take a spec as a PHP array or from a small builder, and draw it in the browser with nervure. The [web component](#without-a-package-the-web-component) remains a way without a package. ## Symfony: nervure/symfony PHP 8.2+, Symfony 6.4, 7 or 8, AssetMapper or Webpack Encore. ```bash composer require nervure/symfony ``` Symfony Flex enables the bundle, adds its Stimulus controller to `assets/controllers.json` and, with AssetMapper, adds `nervure` to `importmap.php`. Without Flex: add `BenMacha\UxNervure\NervureBundle::class => ['all' => true]` to `config/bundles.php`, run `php bin/console importmap:require nervure`, and enable `"@nervure/symfony": { "chart": { "enabled": true, "fetch": "eager" } }` in `assets/controllers.json`. With Webpack Encore, `npm install nervure` as well. ### Configure ```yaml # config/packages/nervure.yaml nervure: theme: auto # light, dark or auto locale: ~ # the language of the page by default animation: true # true, false, or visible: plays when the chart comes into view toolbar: false # export button (SVG, PNG, CSV) zoom: false height: 300 # pixels, or any CSS length ``` ### The Twig component ```php use BenMacha\UxNervure\Chart; #[Route('/orders')] public function orders(OrderRepository $orders): Response { $rows = $orders->countByMonth(); return $this->render('orders.html.twig', [ 'spec' => Chart::xy() ->categories(array_column($rows, 'month')) ->series('Orders', array_column($rows, 'total'), kind: 'bar') ->format(currency: 'EUR'), ]); } ``` ```twig ``` Each attribute overrides the configuration: `height`, `theme`, `locale`, `animation`, `toolbar`, `zoom`. The others (`class`, `id`, `data-*`) go on the chart element. ### The Twig function ```twig {{ render_nervure_chart(spec, {height: 300, animation: 'visible', attr: {class: 'card'}}) }} ``` ### Specs A spec is a PHP array, exactly as in JavaScript, or a `Chart`: ```php Chart::xy()->categories(['Jan', 'Feb'])->series('Orders', [12, 18], kind: 'bar')->format(currency: 'EUR'); Chart::pie()->slice('Shop', 42)->slice('Web', 35)->with('inner', 0.6); Chart::gauge(72, 100)->with('unit', '%'); Chart::kpi('Revenue', 248000)->with('previous', 212000)->format(currency: 'EUR', compact: true); Chart::map(file_get_contents('countries.json'))->values(['FR' => 12, 'TN' => 7]); Chart::timeline()->bar('Build', new DateTime('2026-01-05'), new DateTime('2026-01-20')); Chart::of('sankey', ['nodes' => [...], 'links' => [...]]); ``` `->with('field', $value)` sets any field. Every chart type and its fields: [Charts](/charts/). ### Turbo A Turbo Frame or a Turbo Stream that replaces the element replaces the chart; the controller removes the old one. A Turbo Stream that only changes the spec draws the new data on the same chart. A Turbo 8 page refresh with morphing draws the chart again. ### Live Components ```php #[AsLiveComponent] final class Sales { use DefaultActionTrait; #[LiveProp(writable: true)] public string $year = '2026'; public function __construct(private readonly SalesRepository $sales) {} public function spec(): Chart { $rows = $this->sales->byMonth($this->year); return Chart::xy()->categories(array_keys($rows))->series('Sales', array_values($rows)); } } ``` ```twig
``` The drawing sits in a `data-live-ignore` element; on each re-render, Live Components update the spec of its parent and the chart draws the new data. ### Events ```js document.addEventListener('nervure--symfony--chart:connect', (event) => { const chart = event.detail.chart; // chart.toPNG(), chart.setColor(), chart.toggle()… }); ``` `nervure--symfony--chart:update` follows each new spec. ### Mercure For a chart that moves with your data: ```js import { append, events, live } from 'nervure/live'; document.addEventListener('nervure--symfony--chart:connect', ({ detail: { chart } }) => { live(chart, spec, events('https://example.com/.well-known/mercure?topic=prices'), { apply: (data, previous) => append(previous, data.time, { Price: data.price }, 60), }); }); ``` ## Laravel: nervure/laravel PHP 8.2+, Laravel 11 or 12. ```bash composer require nervure/laravel php artisan vendor:publish --tag=nervure-config # optional ``` ### Configure ```php // config/nervure.php return [ 'theme' => env('NERVURE_THEME', 'auto'), // light, dark or auto 'locale' => null, 'animation' => true, // true, false or 'visible' 'toolbar' => false, 'zoom' => false, 'height' => 300, 'assets' => env('NERVURE_ASSETS', 'cdn'), // cdn or vite 'version' => '0.14.0', // nervure version loaded from the CDN 'cdn' => 'https://cdn.jsdelivr.net/npm/nervure@{version}/cdn/nervure.min.js', ]; ``` ### Load nervure From the CDN, at the version pinned in the configuration, once in the layout: ```blade @nervureScripts ``` With Vite, set `NERVURE_ASSETS=vite`, `npm install nervure`, and: ```js // resources/js/app.js import 'nervure/element'; import '../../vendor/nervure/laravel/resources/js/nervure-blade.js'; ``` `@nervureScripts('nonce')` adds a CSP nonce; with `Vite::useCspNonce()` it is added by itself. ### The Blade component ```php use BenMacha\LaravelNervure\Facades\Nervure; $spec = Nervure::xy() ->categories(['Jan', 'Feb', 'Mar']) ->series('Orders', [120, 180, 150], kind: 'bar') ->format(currency: 'EUR'); ``` ```blade ``` The facade has the same builder as the Symfony bundle: `Nervure::xy()`, `pie()`, `gauge()`, `kpi()`, `map()`, `timeline()`, `of()`. A PHP array works too. Outside Blade, `Nervure::render($spec, ['height' => 300])` returns the HTML. ### Livewire Nothing to add: the drawing sits in a `wire:ignore` element, and the spec on its wrapper. When the component renders again, Livewire updates the spec and the chart draws the new data. ```php final class Sales extends Component { public string $year = '2026'; public function render() { $rows = Sale::byMonth($this->year); return view('livewire.sales', [ 'spec' => Nervure::xy()->categories(array_keys($rows))->series('Sales', array_values($rows)), ]); } } ``` ```blade
``` ### Inertia Use [the React, Vue or Svelte component](/guide/frameworks). ## Without a package: the web component The `` web component needs no build tool and follows Turbo and Livewire: it cleans up when its element goes away. ### Symfony ```bash php bin/console importmap:require nervure/element ``` ```js // assets/app.js import 'nervure/element'; ``` ```twig ``` Your own Stimulus controller, with Webpack Encore or AssetMapper: ```js // assets/controllers/chart_controller.js import { Controller } from '@hotwired/stimulus'; import { chartController } from 'nervure/stimulus'; export default chartController(Controller); ``` ```twig
``` It draws again when its value changes, and dispatches `chart:ready` with the chart. ### Laravel ```js // resources/js/app.js import 'nervure/element'; ``` ```blade ``` With Livewire, keep the element out of the re-render and send it the new spec: ```blade
``` ```php $this->dispatch('orders-changed', spec: $this->spec()); ``` ```js Livewire.on('orders-changed', ({ spec }) => { document.querySelector('#orders').spec = spec; }); ``` ## Rails, Django, WordPress The same web component, with [one script tag](/guide/cdn). # Theme charts Theme charts are made for one domain: they know its words, its usual scales and what people look for in it. They are plain SVG like the others, with tooltips, keyboard reading, legends where they help, the light and dark themes, reduced motion and the SVG, PNG, CSV and Markdown exports. ## Load them They are a separate entry, so they do not grow the main file: ```ts import { createChart } from 'nervure'; import 'nervure/themes'; // registers the theme types createChart(host, { type: 'amortization', amount: 250000, rate: 3.4, years: 20 }); createChart(other, { type: 'barometer', value: 1013.2, previous: 1009.8 }); ``` In a page without a bundler, load the browser file after the main one: ```html ``` `nervure/lazy` knows them too: `createChart` from `nervure/lazy` fetches the code of a theme type the first time it is drawn. ::: warning Examples, not advice Some charts draw a rule of their domain: a debt ratio limit (35 % by default, a common French rule), a reference price before a promotion (the lowest of the 30 days before, as European rules ask), a supply schedule with halvings. They are there to read a picture by. They are not financial, legal or technical advice, and every one of them can be changed in the spec. ::: ## Weather, nature and energy The data are yours: nervure draws them and does not compute the weather, an index or a price. Units are written as you give them (`unit`, `priceUnit`…); the defaults are said below. ### Weather | Type | What it shows | Data | |---|---|---| | [`meteogram`](/charts/meteogram) | Temperature line, rain bars (mm) and a wind arrow for each step | `data: [{ label, temperature, rain, wind, gust, direction }]`, `feels` | | [`windrose`](/charts/wind-rose) | % of the time the wind blows from each direction, by speed class | `classes`, `data: [{ direction, values }]`, `calm` | | [`sunpath`](/charts/sun-path) | Arc of the sun, sunrise and sunset, twilights, moon, now | `sunrise`, `sunset`, `dawn`, `dusk`, `moonrise`, `moonset`, `now`, `previous` | | [`barometer`](/charts/barometer) | Pressure in hPa on a dial, with the tendency over three hours | `value`, `previous`, `since` | ### Nature | Type | What it shows | Data | |---|---|---| | [`treerings`](/charts/tree-rings) | One ring a year, as wide as its growth in mm | `data: [{ year, width }]`, `events` | | [`riverlevel`](/charts/river-level) | River height with flood levels and a forecast | `data: [{ label, level }]`, `thresholds`, `forecastFrom` | | [`airquality`](/charts/air-quality-index) | An index on its bands (the United States bands by default) and its pollutants | `value`, `pollutants`, `bands` | | [`species`](/charts/species-count) | Small figures for the counts of a survey, and the change | `data: [{ name, kind, count, previous }]`, `each` | ### Electricity | Type | What it shows | Data | |---|---|---| | [`loadcurve`](/charts/load-curve) | Load over a day (MW), peak hours, price (€/MWh) | `data`, `every`, `price`, `peak` | | [`genmix`](/charts/generation-mix) | Generation stacked by source, demand on top | `sources: [{ name, kind, data }]`, `demand`, `every`, `start` | | [`plantboard`](/charts/power-plant-board) | Units as tiles: state, output and capacity | `data: [{ name, site, kind, capacity, output, state }]` | | [`powermeter`](/charts/electricity-meter) | Meter index on rolling digits, use since a reading, registers | `value`, `previous`, `registers`, `power` | | [`tariffclock`](/charts/tariff-clock) | Tariff periods on a 24-hour dial, use of each hour, now | `periods: [{ from, to, name, price }]`, `usage`, `now` | `kind` gives a source its usual colour: `nuclear`, `hydro`, `wind`, `solar`, `gas`, `coal`, `oil`, `bio`, `imports`, `storage`, `other`. ### Nuclear | Type | What it shows | Data | |---|---|---| | [`reactor`](/charts/reactor-panel) | Control rods and fuel, power %, coolant °C, pressure bar | `power`, `rods`, `temperature`, `pressure`, `nominal`, `state` | | [`doserate`](/charts/dose-rate-dial) | Dose rate in µSv/h on a logarithmic dial, dose in mSv against a limit | `value`, `total`, `limit`, `bands` | | [`reactorfleet`](/charts/reactor-fleet) | Each reactor over weeks, and the power the fleet has left | `periods`, `data: [{ name, capacity, states }]` | The bands of `doserate` are rough usual levels, not a rule: give your own with `bands`. ### Oil and gas | Type | What it shows | Data | |---|---|---| | [`crudespread`](/charts/crude-oil-spread) | Two crude prices ($/bbl) and their gap | `data: [{ label, first, second }]`, `names` | | [`tankfarm`](/charts/tank-farm) | Tanks in 3D filled to their level | `data: [{ name, volume, capacity, product }]`, `view` | | [`refinery`](/charts/refinery-yields) | Products of a barrel, light at the top | `data: [{ name, share }]`, `input` | | [`gasstorage`](/charts/gas-storage) | % full over the year against past years and a target | `periods`, `data`, `low`, `high`, `average`, `target` | | [`degreedays`](/charts/degree-days) | Heating degree days against the normal, gas used | `data: [{ label, degreeDays, normal, use }]`, `base` | ## Everyday life ### Transport | Type | What it shows | | --- | --- | | [`delays`](/charts/delay-heat-strip) | Lines down the side, hours across, each cell coloured by the average delay (on time, a little late, late, very late), and the share on time of each line. `late` sets the minutes from which a trip is late (5). | | [`modeshare`](/charts/mode-share) | The share of each way of travelling (`walk`, `bike`, `scooter`, `bus`, `tram`, `metro`, `train`, `car`, `carpool`, `plane`), each with its icon, and a `compare` split under it: a goal or another year. | | [`journeys`](/charts/door-to-door-journeys) | Several ways of making one trip, their legs (`walk`, `wait`, `ride`, `drive`, `bike`, `park`) to scale, with the time, `cost` and `co2` of each; the fastest is marked. | ```ts { type: 'delays', hours: ['07', '08', '09'], lines: [{ name: 'A', delays: [1.2, 6.5, 3] }, { name: 'B', delays: [0.4, 2.1, null] }] } ``` ### Cars | Type | What it shows | | --- | --- | | [`carcluster`](/charts/car-dashboard) | Speed and engine speed on two dials with a red zone, the `gear`, `fuel` (or the battery with `electric: true`, and `power` in kW on the second dial), `temperature`, `range` and `odometer`. | | [`evcharge`](/charts/ev-charging-session) | State of charge and charging power over a session, the energy added, the minute the `target` (80 %) is reached and, with a `price`, the cost. | | [`carservice`](/charts/car-service-log) | Work done above the road and work planned below it, along the odometer, the car where it is now and how far the next work is. | ### Real estate | Type | What it shows | | --- | --- | | [`priceladder`](/charts/price-per-m-ladder) | Districts placed on one ladder by their price per m², from green to red, their `low`–`high` range beside, and a `mark`: the home studied. | | [`yieldgrid`](/charts/rental-yield-grid) | The yearly yield of a rental for a range of `prices` and monthly `rents`; `charges` (a share of the rent) gives a net yield, `target` writes the cells that reach it in bold, `mark` rings the home studied. | | [`lots3d`](/charts/3d-building-lots) | A building in 3D, floor by floor, its lots coloured by sale state (free, reserved, sold), with rooms, area and price in the tooltip. It takes `view` and `rotate` like the [3D charts](/guide/3d). | The energy label of a home (classes A to G) is [`energy`](/charts/energy-label), in the main file. ### Financing | Type | What it shows | | --- | --- | | [`amortization`](/charts/loan-amortization) | A loan paid back in equal monthly payments: principal, interest and `insurance` of each year, and what is left to pay on its own scale. | | [`debtratio`](/charts/debt-ratio-gauge) | Monthly `charges` against `income` on a dial, green under `warn` (33 %), amber up to `limit` (35 %), red above; the income cut into the charges and what is left to live on. | | [`borrowing`](/charts/borrowing-capacity) | The loan one can get for each length in `rates`, from the income, the charges and the highest ratio, with the `deposit` and the `price` aimed at. | ### Crypto | Type | What it shows | | --- | --- | | [`halving`](/charts/halving-and-supply) | Coins issued against the cap, the reward of each era and the blocks left to the next halving, from the block `height`. `reward`, `interval`, `minutes` and `start` describe the schedule. | | [`volcone`](/charts/volatility-cone) | From daily `prices`: the range of past volatility (put on a year) over several `windows`, its middle half and median, and where it stands now. | | [`wallet`](/charts/crypto-wallet) | What each coin is worth, its share on a ring, its move over a day and, with `cost`, the gain or loss. | ### Money | Type | What it shows | | --- | --- | | [`compound`](/charts/compound-savings) | Savings that grow with interest added each month: what was put in and what the interest added, with the year a `goal` is reached. | | [`envelopes`](/charts/budget-envelopes) | One envelope for each kind of spending, filled as the money goes; `elapsed` (the share of the month gone) marks the pace, amber ahead of it, red over budget. | | [`fxboard`](/charts/exchange-rate-board) | An `amount` of the `base` currency in several others, with the move and the recent path of each rate. | ### Products | Type | What it shows | | --- | --- | | [`specmatrix`](/charts/product-comparison-matrix) | Products side by side with their price and rating, feature by feature; the best value of each row is marked (`better: 'low'` for a weight or a price) and the product best in most rows is framed. | | [`ratings`](/charts/star-ratings) | The average in stars, how many reviews gave 5 to 1 star, and scores out of 5 by aspect. | | [`pricetrack`](/charts/price-history-with-promotions) | The price over time, its promotions, and the real cut of each against the lowest price of the `window` days before (30). | | [`stocklevel`](/charts/stock-level-and-reorder-point) | Stock over time against its reorder point, safety stock and room, the orders placed and received with their lead time, and the days out of stock. | # Time axis Give dates as categories: an `xy` chart places them by time, so uneven gaps are drawn to scale. ```ts createChart(host, { type: 'xy', categories: ['2024-01-01', '2024-01-02', '2024-01-08', '2024-03-15'], series: [{ name: 'Orders', data: [4, 6, 7, 9] }], }, { locale: 'fr-FR' }); ``` | Categories | Time axis | |---|---| | `Date` objects | yes | | ISO texts: `2024-03`, `2024-03-01`, `2024-03-01T08:30`, `…Z` | yes | | Timestamps (milliseconds) | with `xScale: 'time'` | | Anything else | names, evenly spaced | `xScale: 'category'` keeps dates as names, evenly spaced. Dates without a zone are local time. ## Ticks Ticks are chosen by the span shown: minutes, hours, days, weeks (Mondays), months, quarters, years or decades. They are written with `Intl.DateTimeFormat` in the `locale` of the chart: `14:00`, `4 Mar`, `Jan 2024`, `2020`. The tooltip writes the date in full, with the time when the data has one. ## Bars, zoom and zones - Bars take the width of the shortest gap between two dates, so they never overlap. - `zoom: true` and `thin` work as with names: ticks follow the part shown. - `zones`, `lines` and `annotations` take dates: `{ from: '2024-02-01', to: '2024-02-15' }`, `{ at: '2024-03-01', label: 'Launch' }`. - Horizontal charts keep their categories as names. # Tooltip Every chart opens a tooltip on the mark under the pointer, or reached with the keyboard. The `tooltip` option changes it for every chart type. ## Off ```ts createChart(host, spec, { tooltip: false }); ``` The marks still answer [`onHover` and `onClick`](/guide/events): show what is pointed at somewhere else on the page. ## Your own lines `format` receives the [point](/guide/events#what-you-receive) and returns a line, or several: the first one is the title. Lines are written as text, never read as HTML. ```ts createChart(host, spec, { tooltip: { format: (p) => [p.label, `${p.series}: ${p.value} orders`], }, }); ``` `title` and `rows` of the point hold what the tooltip writes by default, to build on it. ## HTML `html` returns HTML that is used as it is: escape every value that comes from data with the `escape` function it receives. Scripts, frames and event attributes (`onclick`…) are removed anyway. ```ts createChart(host, spec, { tooltip: { html: (p, escape) => `${escape(p.label)}
${escape(String(p.value))} €`, }, }); ``` The tooltip is a `div.nervure-tooltip`: style what you put in it [with CSS](/guide/css). ## Place `position`: `auto` (default: on the right of the pointer, on the left near the edge), `top`, `bottom`, `left` or `right`. The tooltip always stays inside the chart. ```ts createChart(host, spec, { tooltip: { position: 'top' } }); ``` ## From code ```ts const chart = createChart(host, spec); chart.showTooltip('Visits', 3); // series name (or its place, 0, 1…) and index of the mark chart.hideTooltip(); chart.setActive('Visits', 3); // rings the mark, as the keyboard does, until… chart.setActive(null); ``` For charts with one list of marks (`pie`, `treemap`, `funnel`…), any series name works: `chart.showTooltip('', 2)`. The ring of `setActive` stays when the chart is drawn again. Neither calls `onHover`. ## Scatter The `tooltip` field of a `scatter` spec still writes its lines; the `format` or `html` of the option wins when both are given. # Zoom ## Any chart ```ts const chart = createChart(host, spec, { zoom: true }); ``` | Gesture | Does | |---|---| | Buttons | closer, further, back | | Ctrl or ⌘ and wheel, two fingers | closer, around the pointer | | Drag | moves, once closer | | Double click | back | The plain wheel keeps scrolling the page. Buttons work with the keyboard. Useful for `network`, `sankey`, `flowchart`, `er`, `mindmap`, `timeline`, `tree`, `bracket`, and any dense drawing. In an export, the part on screen is saved. ## Lines, bars and prices ```ts createChart(host, { type: 'xy', zoom: true, … }); // drag to look closer, double click to come back createChart(host, { type: 'candlestick', zoom: true, … }); // moving averages remember the prices before chart.zoom(10, 25); // categories 10 to 25 chart.resetZoom(); ``` Axes are drawn again for the part shown, which a plain enlargement cannot do. ## Maps `zoom: true` in the spec of a [map](/guide/maps): buttons, drag, ctrl and wheel; a globe turns. ## In the component ```tsx ``` ```html ``` # Types ```ts import type { DomainCharts } from './specs/domain.ts'; import type { Format } from './core/format.ts'; export type { Format, FormatOptions } from './core/format.ts'; import type { MapCharts } from './specs/map.ts'; import type { GridCharts } from './specs/grid.ts'; import type { DiagramCharts } from './specs/diagram.ts'; import type { FlowCharts } from './specs/flow.ts'; import type { CircularCharts } from './specs/circular.ts'; import type { ComparisonCharts } from './specs/comparison.ts'; import type { DistributionCharts } from './specs/distribution.ts'; import type { FinanceCharts } from './specs/finance.ts'; import type { TimeCharts } from './specs/time.ts'; export type * from './specs/finance.ts'; export type * from './specs/distribution.ts'; export type * from './specs/comparison.ts'; export type * from './specs/circular.ts'; export type * from './specs/flow.ts'; export type * from './specs/diagram.ts'; export type * from './specs/grid.ts'; export type * from './specs/map.ts'; export type * from './specs/domain.ts'; export type * from './specs/time.ts'; // Places import type { PlacesCharts } from './specs/places.ts'; export type * from './specs/places.ts'; // Health import type { HealthCharts } from './specs/health.ts'; export type * from './specs/health.ts'; // Sport import type { SportCharts } from './specs/sport.ts'; export type * from './specs/sport.ts'; import type { ThreeDCharts } from './specs/3d.ts'; export type * from './specs/3d.ts'; import type { EnergyThemeCharts } from './specs/themes-energy.ts'; export type * from './specs/themes-energy.ts'; import type { LivingCharts } from './specs/themes-living.ts'; export type * from './specs/themes-living.ts'; /** Colours and fonts. Every field is optional when passed by the caller. */ export interface Theme { strong: string; label: string; muted: string; grid: string; halo: string; surface: string; font: string; /** Colours used when a series or a point has none. */ palette: string[]; } /** A line across the chart: a target, an average, a date. */ export interface ReferenceLine { value?: number; /** Vertical line on a category (xy) or on the x axis (scatter). */ at?: string | number | Date; axis?: number; label?: string; color?: string; dashed?: boolean; } /** A shaded zone: a stretch of categories (`from`, `to`), or a range of values (`min`, `max`). */ export interface Zone { /** A category, or a date on a time axis. */ from?: string | number | Date; to?: string | number | Date; min?: number; max?: number; axis?: number; label?: string; color?: string; /** 0.08 by default. */ opacity?: number; } /** A note pinned on the chart. `at` is a category (xy) or an x value (scatter). */ export interface Annotation { at: string | number | Date; value: number; text: string; color?: string; axis?: number; } /** * Colour worked out from a value: `(value, index, category) => colour`, for example red below zero. * Only from code: a JSON spec (the editor, the MCP server) keeps plain colour texts. */ export type ColorFn = (value: number, index: number, category: string) => string; /** Shape of a point: on lines, areas, scatter and radar charts, and in the legend. */ export type PointShape = 'circle' | 'square' | 'triangle' | 'diamond' | 'cross' | 'star' | 'rect-rot'; /** How the points of a series are drawn. */ export interface PointStyle { /** `circle` by default. */ shape?: PointShape; /** Radius in pixels, 4 by default. */ size?: number; } export interface Series { name: string; data: (number | null)[]; /** A colour, or a function of each value (`(value, index, category) => colour`, from code only). */ color?: string | ColorFn; kind?: 'line' | 'bar' | 'area' | 'band'; /** Lower bound of a `band` (`data` is the upper one). */ low?: (number | null)[]; /** Colour of one point or bar, when it differs from the series; or a function of each value (from code only). */ colors?: (string | undefined)[] | ColorFn; /** With `stacked`: bars of the same `stack` pile up, other stacks stand beside them in the category. */ stack?: string; dashed?: boolean; gradient?: boolean; /** Points on a line or an area: `false` hides them, `{ shape, size }` changes them. */ dots?: boolean | PointStyle; showLabel?: boolean; /** Text of each label, instead of the formatted value. */ labels?: (string | undefined)[]; /** Joins points with straight segments (default), a smooth curve or steps. */ curve?: 'linear' | 'smooth' | 'step'; /** Index in `axes`. */ axis?: number; legend?: boolean; width?: number; opacity?: number; /** * Missing values (`null`) of a line or an area: `break` cuts the line (default), * `join` links the points on each side, `zero` draws them at 0. */ gaps?: 'break' | 'join' | 'zero'; /** Stretches of the line drawn another way, by index: a forecast in dashes from index 9. */ segments?: Segment[]; } /** A stretch of a line or an area, from the point at index `from` to the one at `to` (the last by default). */ export interface Segment { from: number; to?: number; dashed?: boolean; color?: string; /** Opacity of the line, and of the area under it. */ opacity?: number; /** Said after the value, in the tooltip and to screen readers: `forecast`. */ label?: string; } /** Range, ticks and grid of a value axis. */ export interface AxisScale { /** `log` ignores zero and negative values. */ scale?: 'linear' | 'log'; /** Fixed ends: the data cannot move them. */ min?: number; max?: number; /** Ends the axis reaches at least; data beyond them still widens it. */ suggestedMin?: number; suggestedMax?: number; /** Gap between two ticks, such as 5 (linear scale). */ step?: number; /** About how many ticks (linear scale). */ ticks?: number; /** A function, or options: { currency: 'EUR', compact: true }. */ format?: Format; /** Text of each tick, before `format`: (value, index) => string. */ tickFormat?: (value: number, index: number) => string; /** Grid lines of this axis: `false` hides them; `dashed` and `color` change them. */ grid?: boolean | { dashed?: boolean; color?: string }; title?: string; } export interface Axis extends AxisScale { side?: 'left' | 'right'; } /** Where the legend goes, and what a click on a name does. */ export interface LegendOptions { /** `bottom` by default. `left` and `right` fall back to `bottom` on narrow charts. */ position?: 'top' | 'bottom' | 'left' | 'right'; align?: 'start' | 'center' | 'end'; /** Called with the name and the state it is about to take; return `false` to keep it as it is. */ onClick?: (name: string, visible: boolean) => unknown; } /** A name of the legend, for a legend written outside the chart. */ export interface LegendItem { name: string; color: string; visible: boolean; } /** What a mark stands for: given to `onClick`, `onHover` and the tooltip options. */ export interface ChartPoint { /** Type of the chart: `xy`, `pie`… */ type: string; /** Series or group of the mark, when the chart has several. */ series?: string; /** Stack of a bar (`xy` with `stack` on its series). */ stack?: string; /** Label of the segment of a line the mark is on (`xy` with `segments`). */ segment?: string; /** Category, name or label of the mark. */ label: string; value?: number; /** Place of the mark in its series (or among the categories); -1 when the chart does not say. */ index: number; /** The item of the spec the mark comes from, when there is one. */ item?: unknown; color?: string; /** What the tooltip writes by default: a title, then lines. */ title: string; rows: { name: string; value?: string; color?: string }[]; } export interface ChartPointEvent extends ChartPoint { /** The pointer or keyboard event behind it. */ event: Event; } export interface TooltipOptions { /** Lines of the tooltip: the first is its title. Written as text. */ format?: (point: ChartPoint) => string | string[]; /** * HTML of the tooltip, trusted as it is: escape every value that comes from data with `escape`. * Scripts and event attributes are removed. */ html?: (point: ChartPoint, escape: (text: string) => string) => string; /** Side of the pointer where the tooltip opens; `auto` keeps it inside the chart. */ position?: 'auto' | 'top' | 'bottom' | 'left' | 'right'; } /** Rectangle in the coordinates of the SVG. */ export interface Area { x: number; y: number; width: number; height: number; } /** What a plugin receives at each drawing. */ export interface PluginContext { svg: SVGSVGElement; width: number; height: number; /** Where the data is drawn (inside the axes); the whole drawing for charts that do not say. */ area: Area; /** Middle and radius of the hole of a donut, a pie or a gauge. */ hole?: { x: number; y: number; r: number }; spec: ChartSpec; theme: Theme; /** True when the spec has no value to show. */ empty: boolean; /** Layers of the plugins: under the chart (grid and marks), and above it. Emptied at each drawing. */ below: SVGGElement; above: SVGGElement; /** Adds an SVG element to a layer (`above` by default); `text` is written as text. */ add: ( tag: string, attributes: Record, layer?: 'below' | 'above', text?: string, ) => SVGElement; } /** Draws something more on every chart it is given to. See `nervure/plugins`. */ export interface NervurePlugin { /** Name, unique: a plugin registered twice runs once. */ id: string; beforeDraw?: (context: PluginContext) => void; afterDraw?: (context: PluginContext) => void; onDestroy?: (context: PluginContext) => void; } export interface DecorateContext { svg: SVGSVGElement; width: number; height: number; theme: Theme; } export interface Base { title?: string; description?: string; /** Writes every figure: a function, or options such as { currency: 'EUR', compact: true }. */ format?: Format; /** Text written above the drawing (part of the exports). */ heading?: string; subheading?: string; /** Pixels kept free above the drawing, for a header added by `decorate`. */ insetTop?: number; /** Pixels kept free under the drawing (a watermark). */ insetBottom?: number; /** Adds your own elements (header, watermark); they are part of the exports. */ decorate?: (context: DecorateContext) => void; } export interface XYSpec extends Base { type: 'xy'; /** Names, or dates: Date objects, ISO texts (`2024-03-01`), or timestamps with `xScale: 'time'`. */ categories: (string | number | Date)[]; /** * `time`: categories are dates, placed by time (uneven gaps drawn to scale), with ticks by span. * Chosen alone when every category is a Date or an ISO date; `category` keeps them evenly spaced. */ xScale?: 'category' | 'time'; series: Series[]; axes?: Axis[]; horizontal?: boolean; /** `percent`: each category fills the axis, its bars as shares of 100 %. Series with a `stack` pile up by group. */ stacked?: boolean | 'percent'; /** Rounded corners of the bars, in pixels: 4 by default, 0 for square bars. */ radius?: number; /** Share of a category taken by its bars, from 0 to 1: 0.72 by default. */ barWidth?: number; /** Horizontal bars: first category at the top (default) or at the bottom. */ reverse?: boolean; totals?: boolean; legend?: boolean | LegendOptions; labelWidth?: number; grid?: boolean | 'dashed'; /** Title under the horizontal axis. */ xTitle?: string; /** Angle of the category labels (vertical charts), for example -45. */ labelAngle?: number; lines?: ReferenceLine[]; annotations?: Annotation[]; /** Shaded zones behind the series: a period, a forecast, a range of values. */ zones?: Zone[]; /** Drag on the chart to look closer, double click to come back (vertical charts). */ zoom?: boolean; /** No axis, no legend, no margin: a sparkline. */ bare?: boolean; /** * Long series: keeps the lowest and highest points of each stretch, so peaks stay. * `true`: about one point every 3 pixels; a number: the most points kept. Zooming in brings the detail back. */ thin?: boolean | number; } export interface PieSpec extends Base { type: 'pie'; data: { name: string; value: number; color?: string }[]; inner?: number; outer?: number; labels?: boolean; /** Outside label of a slice. */ label?: (name: string, value: number, percent: number) => string; /** Text in the hole of a donut. */ center?: string; /** Colour of each slice from its value, `(value, index, name) => colour` (from code only); a slice's own `color` wins. */ color?: ColorFn; /** Drawn instead of the labels around the pie when they have no room; `true` or options: always; `false`: never. */ legend?: boolean | LegendOptions; } export interface RadarSpec extends Base { type: 'radar'; indicators: { name: string; max?: number }[]; series: { name: string; values: number[]; color?: string; /** Points on the corners: `true`, or `{ shape, size }`. */ dots?: boolean | PointStyle; }[]; /** Drawn with two series or more; `false` hides it. */ legend?: boolean | LegendOptions; } export interface GaugeSpec extends Base { type: 'gauge'; value: number; max?: number; color?: string; /** Mark on the arc; several marks with a list (the first one is thicker). */ target?: number | number[]; /** Size of the figure in pixels; it follows the size of the gauge by default. */ figureSize?: number; name?: string; unit?: string; } export interface ScatterPoint { x: number; y: number; r?: number; label: string; color?: string; id?: string; /** Radius in pixels, instead of `r`. */ radius?: number; group?: string; /** Shape of this point, instead of the chart's `shape`. */ shape?: PointShape; [key: string]: unknown; } export interface ScatterSpec extends Base { type: 'scatter'; data: ScatterPoint[]; /** A colour, or a function `(y, index, label) => colour` (from code only); a point's own `color` wins. */ color?: string | ColorFn; /** Shape of the points: `circle` by default. The canvas (`render`) always paints circles. */ shape?: PointShape; xLabel?: string; yLabel?: string; /** Names written above the points. */ labels?: boolean; legend?: boolean | LegendOptions; lines?: ReferenceLine[]; annotations?: Annotation[]; /** Range, ticks, format and grid of each axis. */ xAxis?: AxisScale; yAxis?: AxisScale; /** Axes crossing at zero, inside the drawing, instead of along its edges. */ center?: boolean; tooltip?: (point: ScatterPoint, format: (v: number) => string) => string[]; onPointClick?: (point: ScatterPoint) => void; /** * Points as SVG circles, or painted on one canvas: much faster with tens of thousands of points. * `auto` (default) uses a canvas above 3000 points, where there is one. Axes, legend and labels stay SVG. */ render?: 'svg' | 'canvas' | 'auto'; } export interface Item { name: string; value: number; color?: string; label?: string; id?: string; } interface Clickable { onItemClick?: (id: string) => void; } export interface TreemapSpec extends Base, Clickable { type: 'treemap'; data: Item[]; } export interface PackSpec extends Base, Clickable { type: 'pack'; data: Item[]; } export interface FunnelSpec extends Base, Clickable { type: 'funnel'; data: Item[]; /** Share of the first step (default) or of the previous one. */ rate?: 'first' | 'previous' | false; } /** Steps from a start to an end; `total: true` restarts from zero. */ export interface WaterfallSpec extends Base { type: 'waterfall'; data: { name: string; value: number; total?: boolean; color?: string }[]; up?: string; down?: string; totalColor?: string; } export interface HeatmapSpec extends Base { type: 'heatmap'; columns: string[]; rows: string[]; values: (number | null)[][]; color?: string; /** Values written in the cells. */ labels?: boolean; labelWidth?: number; } export interface TimelineBar { row: string; start: number; end: number; color?: string; label?: string; detail?: string; } export interface TimelineMark { row: string; at: number; color?: string; label?: string; id?: string; } /** Dates are timestamps in milliseconds. */ export interface TimelineSpec extends Base, Clickable { type: 'timeline'; rows: string[]; bars?: TimelineBar[]; marks?: TimelineMark[]; now?: number; nowLabel?: string; labelWidth?: number; formatDate?: (t: number) => string; } export interface TreeNode { name: string; color?: string; children?: TreeNode[]; } /** Radial tree; a click on a node folds or unfolds it. */ export interface TreeSpec extends Base { type: 'tree'; root: TreeNode; /** Deepest level whose names are written. */ labelDepth?: number; } /** A type added with `registerChart`. */ export interface CustomSpec extends Base { type: `custom:${string}`; [key: string]: unknown; } export type BasicCharts = | XYSpec | PieSpec | RadarSpec | GaugeSpec | ScatterSpec | TreemapSpec | PackSpec | FunnelSpec | WaterfallSpec | HeatmapSpec | TimelineSpec | TreeSpec; export type ChartSpec = | BasicCharts | FinanceCharts | DistributionCharts | ComparisonCharts | CircularCharts | FlowCharts | DiagramCharts | GridCharts | MapCharts | DomainCharts /* families */ | TimeCharts // Places | PlacesCharts // Health | HealthCharts | SportCharts // 3D, drawn once `nervure/3d` is imported | ThreeDCharts // Theme charts (weather, nature, energy; everyday life), drawn once `nervure/themes` is imported | EnergyThemeCharts | LivingCharts | CustomSpec; export type Easing = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'bounce' | 'elastic' | (string & Record); export interface AnimationOptions { /** 2 is twice as fast. */ speed?: number; /** Milliseconds for each element, instead of the timing of the chart. */ duration?: number; /** Milliseconds before the first element. */ delay?: number; /** `false`: everything moves together. */ stagger?: boolean; /** A named easing (`bounce` and `elastic` overshoot), or any CSS easing. */ easing?: Easing; /** `fade` replaces movement by a fade. */ effect?: 'default' | 'fade'; /** Plays again and again, with a pause between two runs; never when the reader asks for less motion. */ loop?: boolean; /** * How the lines of `xy` charts come in: traced along their length (default), * `grow` up from the axis, or `draw` from left to right at an even pace, points and areas with them. */ line?: 'trace' | 'grow' | 'draw'; /** When to play: at once, when first seen on screen, or by `play()`. */ start?: 'load' | 'visible' | 'manual'; } export type ThemeInput = Partial | 'light' | 'dark' | 'auto'; /** `md`: the data as a Markdown table. `figma`: an SVG made for Figma; the menu copies it, `download` saves it. */ export type ExportFormat = 'svg' | 'png' | 'csv' | 'md' | 'figma'; export interface ExportOptions { /** Written in the file only. */ title?: string; subtitle?: string; caption?: string; background?: string; padding?: number; /** PNG only. */ scale?: number; /** * SVG made to be pasted in Figma: layers named after the parts of the chart, plain colours instead of CSS * variables and `currentColor`, text with its font family, size and weight. */ figma?: boolean; } export interface ToolbarOptions { formats?: readonly ExportFormat[]; label?: string; labels?: Partial>; icon?: string; fileName?: string; options?: ExportOptions; } export interface RenderOptions { /** A named theme, or your own colours. Stylesheets can also set `--nervure-*`. */ theme?: ThemeInput; locale?: string; /** `false` draws at once. */ animation?: boolean | AnimationOptions; /** Short form of `animation`. */ animate?: boolean; /** The reader shows or hides a series in the legend. */ onToggle?: (name: string, visible: boolean) => void; /** Zoom and drag of the whole drawing, for any chart. Lines, prices and maps also have `spec.zoom`. */ zoom?: boolean; /** Export button. */ toolbar?: boolean | ToolbarOptions; /** * Linked cursors: charts of the same group show the same category (or x value) under the pointer. * Any name; leave the group with `destroy`. */ sync?: string; /** With `sync`: zooming an `xy` chart with `zoom` shows the same categories in the others. */ syncZoom?: boolean; /** Reading with the keyboard (default `true`): Tab reaches the chart, arrows go from mark to mark. Read once. */ keyboard?: boolean; /** * The data as an HTML table, formatted like the chart: under the host (`true`, `below`), * beside the drawing, or behind a Table button of the toolbar (`toggle`). Never in the SVG export. */ table?: boolean | 'below' | 'beside' | 'toggle'; /** A click (or Enter) on a mark: a bar, a slice, a point, a cell, a category of a line. */ onClick?: (point: ChartPointEvent) => void; /** The pointer reaches a mark; `null` when it leaves the marks. */ onHover?: (point: ChartPointEvent | null) => void; /** `false`: no tooltip (`onHover` still works). Or how to write and place it. */ tooltip?: boolean | TooltipOptions; /** Run at each drawing of this chart, after those of `registerPlugin`. */ plugins?: NervurePlugin[]; } export interface ChartHandle { readonly svg: SVGSVGElement; /** Draws another spec, with its entrance animation. */ update(spec: ChartSpec, options?: RenderOptions): void; /** Draws new data at once, without animation (live charts). */ refresh(spec: ChartSpec): void; resize(): void; /** Plays the entrance animation (again). */ play(): void; /** Colour of a series or of an item, by name. Kept until `resetColors`. */ setColor(name: string, color: string): void; setPalette(colors: string[]): void; resetColors(): void; /** Adds a note or a line (`xy` and `scatter`). Kept until `clearNotes`. */ addAnnotation(note: Annotation): void; addLine(line: ReferenceLine): void; clearNotes(): void; /** Shows or hides a series, as the legend does. */ toggle(name: string, visible?: boolean): void; /** Names of the legend with their colour and state, to write a legend of your own (with `toggle`). */ legendItems(): LegendItem[]; /** Opens the tooltip of a mark: a series name (or its place among the series), and the index of the mark. */ showTooltip(series: string | number, index: number): void; hideTooltip(): void; /** Rings a mark as the keyboard does, until `setActive(null)`. */ setActive(series: string | number | null, index?: number): void; /** Shows the categories from one index to another (`xy` with `zoom`). */ zoom(from: number, to: number): void; resetZoom(): void; destroy(): void; /** Standalone SVG document. */ toSVG(options?: ExportOptions): string; toPNG(options?: ExportOptions | number, background?: string): Promise; toCSV(): string; /** The data as a Markdown table, under the title of the chart. */ toMarkdown(): string; /** Puts the Figma SVG on the clipboard, as `image/svg+xml` and as text: paste it in Figma. */ copyForFigma(options?: ExportOptions): Promise; /** Saves a file on the reader's computer. */ download(format: ExportFormat, fileName?: string, options?: ExportOptions): Promise; } ```