A gauge chart KPI card built with Tailwind CSS and an inline SVG drawn by a few lines of vanilla JavaScript. This semicircle gauge, often called a speedometer or dial chart, tracks a monthly sales target with a needle, red, yellow and green zones, a target marker and a status badge that changes with the value. It suits sales dashboards, CRM home screens and team KPI boards.
How it works
The root section.gkc-root holds a two-column card. On the left, [data-gkc-meter] wraps the SVG and the large percentage [data-gkc-percent]. On the right, a dl shows the remaining amount, days left in the month and the amount needed per day, followed by the zone legend [data-gkc-legend] and three buttons: data-gkc-step="-5", data-gkc-step="5" and [data-gkc-reset].
The script reads the DATA object at the top of script.js. arc() and point() turn percentages into SVG arc paths on a 0 to DATA.max scale, so the zone bands, tick marks, labels and the dark target line at 100% are all drawn from data. The month name and "day x of y" come from today's date without a year, and the days left include today.
update() rotates the .gkc-needle group with a CSS transform, formats every amount with Intl.NumberFormat, picks the zone for the current percentage and sets data-zone on the status badge (low, mid, high or reached), which style.css colors. The buttons add or remove DATA.step percent of the target and disable themselves at 0% and at the end of the scale. The needle only animates after the first state is drawn.
Customization
DATA.targetandDATA.valueinscript.js: your monthly target and the sales so far.DATA.zones: the end percentage, color and status label of each band, for example a 50/80/120 split.DATA.max: where the scale ends (default120, so the needle can show overachievement).DATA.step: how many percent of the target each simulate button adds or removes.DATA.reachedLabel: the badge text at 100% or more..gkc-status[data-zone="..."]rules instyle.css: the badge colors per zone.- Remove the "Simulate an update" block and call your own code to change the value when real data arrives.
Use cases
- Sales dashboards: progress toward the monthly revenue target at a glance.
- CRM and team boards: quota attainment for a rep or region.
- Operations panels: any KPI with clear red, amber and green thresholds.
Accessibility
The gauge wrapper has role="meter" with aria-valuemin, aria-valuemax, aria-valuenow and an aria-valuetext such as "80.5% of target, $96,600 of $120,000, close to target", labelled by the card title. The SVG itself is aria-hidden. Each button press is announced through a polite live region [data-gkc-live]. Buttons are native, keyboard operable and show a visible focus ring, and status is never shown by color alone because the badge always carries text. Reduced motion removes the needle animation.
Usage notes
The Outfit font loads from Google Fonts. Several gauges can share a page; queries are scoped to each .gkc-root.