Representing capacity warning levels with a gauge | meter

プログラミング・Web開発カテゴリを表すパンダのイラスト Programming / Web Development

About this article
This article was created using an automated generation workflow leveraging generative AI. Official documentation and fixed material implementations were reviewed to organize operational and technical constraints.

Verification Status: 📘 Official Information and Implementation Verification. Actual browser testing not confirmed.

Storage utilization percentages alone may not effectively convey urgency. Adding state names to numerical values allows comparison immediately before and after thresholds.

Open live demo

Key terms to know first

  • Gaugeis a display indicating the current value within a range.

  • Thresholdis the reference value used to switch states.

Thinking in pie charts

Shows the breakdown with the total as 100%. Thresholds of 70% and 90% are used to determine whether a danger level is reached.

pie showData
    title 使用率85%の内訳
    "使用中" : 85
    "空き" : 15

Operating the live demo

Enter 69, 70, 89, and 90 in order. Compare the numerical values with the states.

How to read the results

The state name in the result field becomes 'Warning' at 70 and 'Danger' at 90. This is distinct from the color boundaries of the gauge itself.

For usage examples, lower values are treated as the desirable range. For metrics like temperature where values near the center are desirable, the settings must be changed.

Key points of the code

Specify max=100, low=70, high=90, and optimum=0, and also add an accessible label for the value.

The implementation can be viewed in the "Implementation Code" section of the demo screen.

When using in production

Do not rely on color alone; display the status name and usage rate together.

Check just before and just after the threshold

The initial value is 85. Pressing the run button is expected to create a gauge representing the usage rate and a slider to change the value. Change the slider value sequentially to 69, 70, 89, and 90, and compare the gauge with the result field. If it is difficult to adjust to precise values, enter the number in the initial input field and rerun. Also verify in a real browser whether the slider can be operated via keyboard.

Usage rateStatus name in the result field
69%Normal
70%Warning
89%Warning
90%Critical

This table represents the status names output by the JavaScript in this demo. The same conditional expressions were executed in local Node.js to verify the four values. The gauge colors and appearance in a real browser have not been tested. Ensure not to conclude that the table status matches solely based on color.

Separating the gauge from business logic states

The meter element is an HTML element that indicates a measured value within a known range. The tutorial sets min to 0, max to 100, low to 70, high to 90, and optimum to 0. This is an example where a lower usage rate is considered the desirable side. Browsers can determine the gauge ranges and appearance based on low, high, and optimum. Meanwhile, the status name is displayed by JavaScript conditional expressions. If it is 90 or higher, it is critical; otherwise, if it is 70 or higher, it is a warning.

The important point is that the handling of boundary classifications by HTML low and high does not necessarily match our custom anomaly determination. For example, the HTML standard has concepts for classifying values on or below low, or above high, and if you want boundary values to change color in sync with custom status names, verify consistency separately. Gauge colors also vary depending on the browser theme and CSS. It is necessary to clearly display the percentage and status name on the screen rather than judging by color alone.

This is not a function for calculating numerical values.

This learning material displays the utilization rate entered by the user. There is no processing to retrieve capacity from actual storage or measure available space. When applying this to business systems, first verify the definitions of the measurement target and the denominator. For example, the same usage amount will result in different percentages depending on whether the total storage capacity or the allocated usage quota is used as the denominator. Test whether the calculation is correct and whether the display is easy to read separately.

Utilization rates of 70% and 90% are threshold values for this learning exercise. This is not a proposal that the same warning values should be used in every environment. They are determined by the growth rate of usage, the time required for response, and service requirements. For metrics where a low value is problematic, or for temperatures where a value near the center is desirable, the optimal setting will also change. Check the characteristics of the metric before selecting a gauge.

When used for operational decision-making

In capacity monitoring, not only the current value but also the change over time is important. The priority of response may differ between a sudden increase in utilization rate and a gradual increase over several weeks. Since a gauge indicates the state at a single point in time, combine it with a time-series graph as needed. If linking display warnings with actual notifications, manage the same boundary conditions and duration rules, and verify whether notifications occur frequently when values fluctuate near the boundary.

If the gauge does not move, check whether the slider changes after execution, and whether the value passed to value matches the result field. If the status name changes but the color remains the same, check the HTML classification and display theme. Do not enter actual internal system names or capacity information into public learning materials; understand the differences in decision criteria using fictitious percentages.

Verification Scope

Target: HTML meter / range. Executed conditional expressions with the same state strings as the implementation on Node.js v22.16.0. 69 normal, 70 warning, 89 warning, 90 danger. Display and screen reading of HTMLMeterElement were not executed. Browser compatibility, display, accessibility, and Mermaid rendering are unverified.

References

GitHub Sample

Implementation and Experiment Procedure

Document information

Article title
Representing capacity warning levels with a gauge | meter
Published
Updated
Source
https://papanda925.com/?p=19155&lang=en

License: Text and original figures for which this site holds the relevant rights are available under CC BY 4.0 , unless otherwise noted. This article may include content created or edited with generative AI. If code has a separate license notice or a linked GitHub repository license, that license takes precedence for the code. Quotations, third-party materials, images, and trademarks are excluded from this license. Usage policy

Copied title and URL