All components · Category: Charts and data
Gauge meter
A semicircle gauge with zones, a swinging needle and a slider to try values.
A dial with three zones, a needle that swings to the value and the zone said in words as well as color. A slider lets a visitor try other values, and your page can set the real one. The default numbers are illustrative.
01
Try it
Props
Generated from the component's manifest and the values above.
index.html
<gauge-meter locale="en"></gauge-meter>
<script>
const element = document.querySelector("gauge-meter");
element.addEventListener("gauge-meter:zonechange", (event) => {
console.log(event.detail);
});
</script>
- Add the site's Taggor script once; the component appears when it loads.
taggor-component.js
const element = document.createElement("gauge-meter");
element.setAttribute("locale", "en");
element.addEventListener("gauge-meter:zonechange", (event) => {
console.log(event.detail);
});
document.body.append(element);
- Add the site's Taggor script once; the component appears when it loads.
GaugeMeter.tsx
import { useEffect, useRef } from "react";
export function GaugeMeter() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onZonechange = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("gauge-meter:zonechange", onZonechange);
return () => {
element.removeEventListener("gauge-meter:zonechange", onZonechange);
};
}, []);
return <gauge-meter ref={ref} locale="en" />;
}
- Add the site's Taggor script once; the component appears when it loads.
- React 18 sends every prop of a custom element as a text attribute.
- The event is heard with addEventListener, inside an effect.
GaugeMeter.tsx
import { useEffect, useRef } from "react";
export function GaugeMeter() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onZonechange = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("gauge-meter:zonechange", onZonechange);
return () => {
element.removeEventListener("gauge-meter:zonechange", onZonechange);
};
}, []);
return <gauge-meter ref={ref} locale="en" />;
}
- Add the site's Taggor script once; the component appears when it loads.
- React 19 sets a property when the element already has it, an attribute otherwise.
- The event is heard with addEventListener, inside an effect.
src/GaugeMeter.vue
<script setup lang="ts">
function onZonechange(event: Event) {
console.log((event as CustomEvent).detail);
}
</script>
<template>
<gauge-meter locale="en" @gauge-meter:zonechange="onZonechange" />
</template>
vite.config.ts
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag === "gauge-meter",
},
},
}),
],
});
- Add the site's Taggor script once; the component appears when it loads.
- vite.config.ts tells Vue that this tag is not a Vue component.
src/app/gauge-meter.component.ts
import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";
@Component({
selector: "app-gauge-meter",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<gauge-meter locale="en"></gauge-meter>
`,
})
export class GaugeMeterComponent {
constructor() {
const host = inject<ElementRef<HTMLElement>>(ElementRef);
const element = () => host.nativeElement.querySelector("gauge-meter");
const onZonechange = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("gauge-meter:zonechange", onZonechange));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("gauge-meter:zonechange", onZonechange));
}
}
- Add the site's Taggor script once; the component appears when it loads.
- The component declares CUSTOM_ELEMENTS_SCHEMA.
- The event is heard with addEventListener, inside an effect.
src/TaggorComponent.svelte
<script>
function onZonechange(event) {
console.log(event.detail);
}
</script>
<gauge-meter locale="en" ongauge-meter:zonechange={onZonechange}></gauge-meter>
- Add the site's Taggor script once; the component appears when it loads.
How an agent gets a component like this onto a site:
taggor checktaggor publishThe CSS variables the component exposes, set the way a customer's page would.
styles.css
gauge-meter {
--gm-radius: 20px;
}02
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| value | number | 72 | The current value. |
| min | number | 0 | The value at the left end. |
| max | number | 100 | The value at the right end. |
| warn | number | 60 | From here the zone is High. |
| danger | number | 85 | From here the zone is Critical. |
| label | string | none | Replaces the gauge name. |
| unit | string | none | Replaces the unit shown after the value. |
| hideSlider | boolean | false | Hides the slider (use it with a real value). |
| hideSample | boolean | false | Hides the Illustrative numbers mark (use it with a real value). |
| locale | pt-BR | en | en | – |
Prop names and descriptions are the component's own, in English, as its author wrote them.
03
Events
| Event | When it fires |
|---|---|
| zonechange | The needle moved into another zone. |
04
Build one with your agent
Paste this into your agent. It asks you before it signs in, pays or goes further than checking and publishing.
Build me a Taggor component like "Gauge meter" (gauge-meter): A semicircle gauge with zones, a swinging needle and a slider to try values.
Fetch https://taggor.dev/agent-setup/prompt.md and follow its instructions to set me up for Taggor. Ask me before you sign in, create an account, accept terms, pay for anything or type a secret.
Check it with `taggor check` and publish it with `taggor publish`, and stop there.
Do not promote it to production, attach it to a site, roll back anything or use --yes, --force or --force-drop-invalid unless I ask for exactly that in this conversation.
05
Related components
- KPI board<kpi-board>
- Donut chart<chart-donut>
- Live bar chart<chart-bars-live>