Class: WindRose

PD.SVG. WindRose

Generates a Wind Rose diagram within an SVG element.

This type of diagram shows the relative frequencies of wind speed and direction. It can also be used to map other weather data metrics such as temperature, humidity, pressure and even solar radiation that correspond to each wind speed and direction.

There are two basic types of wind frequency diagram:

Wind Rose

This is the default type and shows each wind direction band as a separate segment whose radial length corresponds to the total percentage of time the wind was blowing from that direction. Each segment is divided into speed bands whose relative radial length vary to show the relative percentage of time in each wind speed band. Speed bands are shown in different colors and should cumulatively add up to the total length of each segment.

Wind Frequency

This type of diagram shows the same wind speed and direction data, but all speed and direction segments have exactly the same radial length. This therefore appears as a donut shaped diagram in which wind frequency is indicated by the color and opacity of each segment rather than its size. This is typically accompanied by a numeric percentage as the uniform spacing of each band allows this even if the percentage is zero or close to it.


new WindRose(config [, initialise])

Creates a new Wind Rose diagram instance.

Parameters:
Name Type Argument Default Description
config object

A configuration object.

Properties of config:
Name Type Argument Description
svgId SVGElement | string

The SVG element to use, or the DOM ID of an SVG element.

weather PD.WeatherData <optional>

The weather data to generate the diagram from, defaults to project site data.

range PD.DateTimeRange <optional>

The date/time range to generate the diagram for, defaults to all day over a full year.

scale number <optional>

An optional scale factor for font sizes and line widths (0.01 to 10.0).

angleBand number <optional>

The preferred angle of each band in degrees, defaults to 30deg (12 bands).

speedBand number <optional>

The number of speed segments in each angular band (number or array), defaults to 10 kilometres per hour.

angleGap number <optional>

The relative gap between angular segments (0.0 to 0.5), defaults to 0.05.

speedGap number <optional>

The relative gap between speed segments (0.0 to 0.5), defaults to 0.05.

useTheme boolean <optional>

Whether or not to use the theme styles, defaults to true.

initialise boolean <optional>
true

Whether or not to initialise the diagram immediately, intended for use by sub-classes.

Author:
  • drajmarsh
Throws:

Throws an error if provided with an invalid svgId element or id.

Type
Error

Members


:number

angleBand

The preferred angle of each band in degrees, defaults to 30deg (12 bands).

This is a preferred angle as its value will automatically be rounded to evenly divide into 360, so that the full circle is divided into equal segments.

Type
  • number

:number

angleGap

The relative gap between angular segments (0.0 to 0.5), defaults to 0.05.

Type
  • number

:number

id

A unique identifier for this diagram.

Type
  • number

:PD.DateTimeRange

range

The date/time range to generate the diagram for.

Type

:number|Array.<number>

speedBand

The number of speed segments in each angular band (number or array), defaults to 10 kilometres per hour.

Instead of a speed value in km/h, the wind speed band can also be given as an array of wind speed thresholds in kilometers per hour if you need irregular sized speed bands. If you pass an empty array, the speed bands will default to the Beaufort scale.

Type
  • number | Array.<number>

:number

speedGap

The relative gap between speed segments (0.0 to 0.5), defaults to 0.05.

Type
  • number

:number

speedMax

The maximum wind speed in kilometres per hour (1 to 150), defaults to 100 km/h.

Type
  • number

:SVGElement

svgElem

The SVG element to render the diagram to.

Type
  • SVGElement

:PD.WeatherData

weather

The weather data to generate the diagram from.

Type

Methods


set(config [, update])

Sets the weather data and date/time range of the diagram and updates it.

Parameters:
Name Type Argument Default Description
config number

A configuration object.

Properties of config:
Name Type Argument Description
scale number <optional>

An optional scale factor for font sizes and line widths (0.01 to 10.0).

weather PD.WeatherData <optional>

The weather data to generate the diagram from, defaults to project site data.

range PD.DateTimeRange <optional>

The date/time range to generate the diagram for, defaults to all day over a full year.

fromDay number <optional>

The day of the year to start calculating, inclusive (0 to 365/6).

toDay number <optional>

The day of the year to end calculating, inclusive (0 to 365/6).

fromTime number <optional>

The hour of each day to start calculating, in decimal hours (0.0 to 24.0).

toTime number <optional>

The hour of each day to stop calculating, in decimal hours (0.0 to 24.0).

timeStep number <optional>

The fractional hour for each calculation step (0 to 1).

sunriseToSunset boolean <optional>

Whether or not to use daily sunrise and sunset as from/to times, defaults to false.

update boolean <optional>
true

Whether or not to update sun-path diagram if changed.

Returns:

Returns true if anything changed, otherwise false.

Type
boolean

setDateTimeRange(range [, update])

Sets the date/time range of the diagram and updates it.

Parameters:
Name Type Argument Default Description
range PD.DateTimeRange

A date/time range object.

update boolean <optional>
true

Whether or not to update sun-path diagram if changed.

Returns:

Returns true if date or time changed, otherwise false.

Type
boolean

setScale(scale [, update])

Sets the scale of detail in the wind-rose diagram and updates it.

This scale is used to adjust the font sizes and line widths relative to the overall size of the diagram.

Parameters:
Name Type Argument Default Description
scale float

The new wind-rose feature scale (0.01 to 2.5).

update boolean <optional>
true

Whether or not to update wind-rose diagram if changed.

Returns:

Returns true if the scale changed, otherwise false.

Type
boolean

setWeatherData(weather [, update])

Sets the weather data the wind rose diagram is based on and updates it.

Parameters:
Name Type Argument Default Description
weather PD.WeatherData

A weather data object.

update boolean <optional>
true

Whether or not to update the diagram if changed.

Returns:

Returns true if the weather data changed, otherwise false.

Type
boolean

show(state)

Shows or hides the diagram based on given state.

Parameters:
Name Type Description
state boolean

Use true to show, false to hide.

Returns:

Returns this diagram instance to support method chaining.

Type
object

update()

Performs a complete update of the diagram.

This method updates the diagram to reflect the current date, time and location.

Returns:

Returns this Sun-path instance to support method chaining.

Type
PD.SVG.SunPath