@windy/Metric
Major Windy class for conversion of units, that are used in Windy.com.
Enjoy methods like convertValue, convertNumber, listMetrics, howManyMetrics
Never change users selected metric without user's action or consent.
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new Metric(params): Metric
Parameters
| Name | Type |
|---|---|
params | MetricInitParams |
Returns
Properties
backConv
• Optional backConv: ConvObj
Backward conversion functions
cohesion
• Optional cohesion: Object
Keeps cohesion in between multiple metric instances. For example setting in in rain will set in in snow also
Type declaration
conv
• conv: ConvObj
Conversion functions
defaults
• defaults: MetricItem[]
Default metric for start-up [ metric, imperial, ??? ]
ident
• ident: MetricIdent
Identifies metric
legend
• Optional legend: Legend | DiscreteLegend
Gradiend legend associated with this metric
metric
• metric: MetricItem
Actually selected unit
nativeSync
• nativeSync: boolean
Sync the metric to native iOS/Android apps
separator
• separator: "" | " "
number ' ' metric separator
useConvertValue
• Optional useConvertValue: boolean
convertValue for this metric returns nonsense, so use convertValue
Methods
convertNumber
▸ convertNumber(value, forcedPrecision?, metric?, back?): number
produces converted number value without label
Parameters
| Name | Type |
|---|---|
value | number |
forcedPrecision? | number |
metric? | MetricItem |
back? | boolean |
Returns
number
convertValue
▸ convertValue(value, separator?, suffix?, forcedPrecision?): string
get value + label on a basis of user selected metric
Parameters
| Name | Type |
|---|---|
value | number |
separator? | string |
suffix? | string |
forcedPrecision? | number |
Returns
string
cycleMetric
▸ cycleMetric(): void
Cycles throu different metrics (for example after clicking on a legend)
Returns
void
howManyMetrics
▸ howManyMetrics(): number
How many metrics we have
Returns
number
initProperties
▸ initProperties(): void
Returns
void
listMetrics
▸ listMetrics(): MetricItem[]
List all avail units
Returns
na
▸ na(): string
Not available
Returns
string
setMetric
▸ setMetric(metric, ignoreCohesion?): void
Stores required metric into storage
Parameters
| Name | Type |
|---|---|
metric | MetricItem |
ignoreCohesion? | boolean |
Returns
void