มาตรวัด
GaugeChart
One percentage against a target, as a half-circle gauge with a target tick.
ใช้แสดงตัวเลขเปอร์เซ็นต์เดียวเทียบเป้า เช่น การเบิกจ่ายของไตรมาส ถ้ามีหลายหน่วยงานเทียบเป้าเดียวกัน ใช้ BulletChart ถ้าเป็นความคืบหน้าทั่วไปที่ไม่มีเป้า ใช้ ProgressBar หรือ ProgressRing
import { GaugeChart } from "@bsru/ui";ตัวอย่าง
ต่ำกว่าเป้า
value และ target เป็นเปอร์เซ็นต์ 0 ถึง 100 ขีดดำบนมาตรคือเป้า
<GaugeChart
title="เบิกจ่ายเทียบเป้าไตรมาส"
label="เบิกจ่าย"
value={62}
target={75}
targetLabel="เป้า"
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | "เบิกจ่ายเทียบเป้าไตรมาส" | string | The chart's caption. |
| label* จำเป็น | "เบิกจ่าย" | string | Before the value, for the tooltip and screen readers, such as "เบิกจ่าย". |
| value* จำเป็น | 62 | number | The result in %, from 0 to 100. |
| target* จำเป็น | 75 | number | The target in %, from 0 to 100. |
| targetLabel* จำเป็น | "เป้า" | string | Before the target, such as "เป้า". |
พร้อมข้อความใต้มาตร
footer แสดงใต้มาตร เช่น ห่างจากเป้าเท่าใด รับข้อความหรือโหนดก็ได้
<GaugeChart
title="เบิกจ่ายเทียบเป้าไตรมาส"
label="เบิกจ่าย"
value={81}
target={75}
targetLabel="เป้า"
footer="สูงกว่าเป้า 6 จุด"
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | "เบิกจ่ายเทียบเป้าไตรมาส" | string | The chart's caption. |
| label* จำเป็น | "เบิกจ่าย" | string | Before the value, for the tooltip and screen readers, such as "เบิกจ่าย". |
| value* จำเป็น | 81 | number | The result in %, from 0 to 100. |
| target* จำเป็น | 75 | number | The target in %, from 0 to 100. |
| targetLabel* จำเป็น | "เป้า" | string | Before the target, such as "เป้า". |
| footer | "สูงกว่าเป้า 6 จุด" | ReactNode | Under the gauge, such as how far it is from target. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | string | — | The chart's caption. |
| label* จำเป็น | string | — | Before the value, for the tooltip and screen readers, such as "เบิกจ่าย". |
| value* จำเป็น | number | — | The result in %, from 0 to 100. |
| target* จำเป็น | number | — | The target in %, from 0 to 100. |
| targetLabel* จำเป็น | string | — | Before the target, such as "เป้า". |
| footer | ReactNode | — | Under the gauge, such as how far it is from target. |
ข้อควรปฏิบัติ
- value และ target เป็นเปอร์เซ็นต์ระหว่าง 0 ถึง 100
- มาตรนี้ไม่มีมุมมองตาราง ค่าและเป้าแสดงเป็นตัวเลขบนมาตร และ label ใช้เป็นชื่อสำหรับโปรแกรมอ่านหน้าจอ
- หน้าที่มีกราฟต้องวาง <ChartPaints /> หนึ่งครั้ง ไม่เช่นนั้นมาตรจะไม่มีสี
- ส่ง title label targetLabel และ footer ในภาษาของหน้าจออยู่แล้ว แอปแปลเองด้วยไฟล์ข้อความของแอป เช่น t() ของ next-intl
- ข้อมูลในตัวอย่างและการทดสอบต้องเป็นข้อมูลสมมติ
ซอร์สโค้ด: ui/src/charts/target.tsx