Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field Config: Add new units (mΩ, kHz, MHz, GHz, ac, ha) #71357

Merged
merged 4 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/grafana-data/src/valueFormats/categories.ts
Expand Up @@ -80,6 +80,8 @@ export const getCategories = (): ValueFormatCategory[] => [
{ name: 'Square Meters (m²)', id: 'areaM2', fn: toFixedUnit('m²') },
{ name: 'Square Feet (ft²)', id: 'areaF2', fn: toFixedUnit('ft²') },
{ name: 'Square Miles (mi²)', id: 'areaMI2', fn: toFixedUnit('mi²') },
{ name: 'Acres (ac)', id: 'acres', fn: toFixedUnit('ac') },
{ name: 'Hectares (ha)', id: 'hectares', fn: toFixedUnit('ha') },
],
},
{
Expand Down Expand Up @@ -236,6 +238,7 @@ export const getCategories = (): ValueFormatCategory[] => [
{ name: 'Kilovolt (kV)', id: 'kvolt', fn: SIPrefix('V', 1) },
{ name: 'Millivolt (mV)', id: 'mvolt', fn: SIPrefix('V', -1) },
{ name: 'Decibel-milliwatt (dBm)', id: 'dBm', fn: SIPrefix('dBm') },
{ name: 'Milliohm (mΩ)', id: 'mohm', fn: SIPrefix('Ω', -1) },
{ name: 'Ohm (Ω)', id: 'ohm', fn: SIPrefix('Ω') },
{ name: 'Kiloohm (kΩ)', id: 'kohm', fn: SIPrefix('Ω', 1) },
{ name: 'Megaohm (MΩ)', id: 'Mohm', fn: SIPrefix('Ω', 2) },
Expand Down Expand Up @@ -341,6 +344,9 @@ export const getCategories = (): ValueFormatCategory[] => [
formats: [
{ name: 'Revolutions per minute (rpm)', id: 'rotrpm', fn: toFixedUnit('rpm') },
{ name: 'Hertz (Hz)', id: 'rothz', fn: SIPrefix('Hz') },
{ name: 'Kilohertz (kHz)', id: 'rotkhz', fn: SIPrefix('kHz', 3) },
{ name: 'Megahertz (MHz)', id: 'rotmhz', fn: SIPrefix('MHz', 4) },
{ name: 'Gigahertz (GHz)', id: 'rotghz', fn: SIPrefix('GHz', 5) },
{ name: 'Radians per second (rad/s)', id: 'rotrads', fn: toFixedUnit('rad/s') },
{ name: 'Degrees per second (°/s)', id: 'rotdegs', fn: toFixedUnit('°/s') },
],
Expand Down
Expand Up @@ -40,6 +40,7 @@ describe('valueFormats', () => {
${'kbytes'} | ${undefined} | ${10000000} | ${'9.54 GiB'}
${'deckbytes'} | ${undefined} | ${10000000} | ${'10 GB'}
${'megwatt'} | ${3} | ${1000} | ${'1.000 GW'}
${'mohm'} | ${3} | ${1000} | ${'1.000 Ω'}
${'kohm'} | ${3} | ${1000} | ${'1.000 MΩ'}
${'Mohm'} | ${3} | ${1000} | ${'1.000 GΩ'}
${'farad'} | ${3} | ${1000} | ${'1.000 kF'}
Expand Down