Skip to content

Revenue Area Chart Card

Revenue area chart card with total revenue, change versus the previous period, a revenue and costs SVG area chart, legend toggles and a keyboard-friendly tooltip.

Also known as: area chart, revenue chart dashboard, svg line chart with tooltip, income vs expenses chart, sales analytics chart card

Revenue Area Chart Card live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A revenue area chart card built with Tailwind CSS and a small vanilla JavaScript file that draws the SVG, so no chart library is needed. This dashboard chart example shows total revenue, the change against the previous period, and revenue and costs as two smooth area series with a legend toggle and a tooltip. It fits SaaS analytics, e-commerce admin panels and finance reports.

How it works

The root section.rac-root holds one card. The header shows the total from [data-rac-total], the change badge [data-rac-change] and two legend buttons with data-rac-series="revenue" and data-rac-series="costs". A dl underneath lists costs, gross profit and margin. The chart lives in .rac-plot, which contains an empty svg[data-rac-svg] and the tooltip [data-rac-tip].

All numbers come from the DATA object at the top of script.js. On DOMContentLoaded the script computes the month labels from today (the last value is the current month, shown without a year), the totals and the change badge, then draw() measures the plot width and builds the SVG: dashed gridlines, a value axis with "nice" steps from niceStep(), month labels, and for each visible series a gradient area plus a line. Lines use monotone cubic curves from smoothPath(), so they never overshoot the data. The current month is active on load, with a guide line, two point markers and the tooltip showing revenue, costs and profit.

Moving the pointer or tapping the plot picks the nearest month. Clicking a legend button flips aria-pressed, hides that series and rescales the value axis to the remaining data.

Customization

  • DATA.series[].values in script.js: replace with your own monthly figures; totals, labels, tooltip and table update.
  • DATA.series[].color: line and gradient colors, #0ea5e9 (sky) and #64748b (slate) by default.
  • DATA.previousRevenue: the comparison total behind the change badge; a negative change switches the badge to rose.
  • DATA.currency and DATA.locale: any ISO currency such as EUR; formatting uses Intl.NumberFormat.
  • var H = W < 480 ? 240 : 300 in draw(): the chart height on phones and wider cards.
  • max-w-3xl on the article: make the card wider or narrower.

Use cases

  • SaaS dashboards: monthly recurring revenue against infrastructure and payroll costs.
  • Online stores: sales versus cost of goods for the last twelve months.
  • Agency and freelancer reports: income and expenses in one client-ready card.

Accessibility

The plot is focusable (tabindex="0") with role="group", aria-roledescription="chart" and a label that explains the arrow keys. Left and Right move between months, Home and End jump to the first and last, and a polite live region [data-rac-live] reads the month and its values. Legend buttons use aria-pressed; hidden series show a hollow dot and grey text, and at least one series always stays visible. The SVG is aria-hidden; a summary paragraph and a visually hidden table repeat every number.

Usage notes

The Inter font loads from Google Fonts. Several cards can share a page because every query is scoped to its .rac-root and gradient ids are unique per card.

Revenue Area Chart Card at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS, fonts.googleapis.com
Layout
Responsive, works on mobile
Category
Charts
License
Free for personal and commercial use

Questions about this template

Can I use the Revenue Area Chart Card code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS and fonts.googleapis.com from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
  • <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap">

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Revenue Area Chart Card – free Tailwind CSS chart template
Revenue Area Chart Card · free Tailwind CSS chart template

More Charts

Funnel Chart – free Bootstrap 6 chart template

Funnel Chart

Sales funnel chart with five narrowing stages, user counts, step and overall conversion, a channel switch and a detail panel for the selected stage.

Multi-Line Chart with Range Tabs – free Bootstrap 6 chart template

Multi-Line Chart with Range Tabs

SVG multi-line chart comparing organic, paid and email traffic, with 7 day, 30 day and 12 month tabs, legend toggles and a crosshair tooltip.

Sparkline KPI Row – free Pure CSS chart template

Sparkline KPI Row

Sparkline KPI row with four stat tiles, change badges and SVG sparklines that redraw when a 7d, 30d or 90d range is picked, with keyboard and touch tooltips.

SVG Line Chart with Hover Points – free Pure CSS chart template

SVG Line Chart with Hover Points

Smooth SVG line chart of daily website visitors with a gradient area fill, axis labels, and a crosshair tooltip that follows the pointer or the arrow keys.

Horizontal Bar Chart Ranking – free Bootstrap 6 chart template

Horizontal Bar Chart Ranking

Horizontal bar chart ranking the top 8 products by revenue, units or returns; a select re-sorts the bars and announces the new order.

Donut Chart with Legend – free Pure CSS chart template

Donut Chart with Legend

SVG donut chart of traffic sources with the total in the centre and an interactive legend that highlights each segment and shows its share, value and percent.