Class: Analemma

PD.SVG. Analemma

Generates a solar declination vs equation of time chart.

This is a simple chart with the origin at the center, minutes in the X-axis, declination angle in the Y-axis, and a single line tracking the variation in declination and the equation of time over the days of the year.

NOTE: To maintain compatibility with a number of legacy web apps, this class still uses some old-school getter/setter methods. These methods take an optional argument which, if present, sets the value of the corresponding internal property. If no argument is given, the method just returns the internal property value.


new Analemma(config [, initialise])

Creates a new solar declination vs equation of time chart.

Parameters:
Name Type Argument Description
config object

A configuration object.

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

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

sunPos PD.SolarPosition <optional>

An optional solar position calculator to use.

throttledRescale number <optional>

The number of milliseconds to throttle calls to rescale() by.

padding Array <optional>

An array of padding pixels in top, right, bottom, left order.

paddingTop number <optional>

The number of padding pixels at the top of the chart, if padding is not given.

paddingRight number <optional>

The number of padding pixels to the right of the chart, if padding is not given.

paddingBottom number <optional>

The number of padding pixels at the bottom of the chart, if padding is not given.

paddingLeft number <optional>

The number of padding pixels to the left of the chart, if padding is not given.

useGlobalState boolean <optional>

A flag indicating that the chart uses global date, time and location, defaults to true.

useTheme boolean <optional>

A flag indicating that the chart uses the global dark/light theme, defaults to true.

interactive boolean <optional>

A flag indicating that the chart should add pointer/touch interactivity, defaults to false.

initialise boolean <optional>

A flag used by subclasses to control initialisation, defaults to true.

Author:
  • drajmarsh
Throws:

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

Type
Error

Members


:number

id

A unique identifier for this chart.

Type
  • number

:boolean

interactive <readonly>

A flag indicating that the chart uses pointer/touch interactivity.

Type
  • boolean

:boolean

isAnalemma <readonly>

A flag identifying this object as a solar analemma chart.

Type
  • boolean

:PD.SolarPosition

sunPos

An internal solar position calculator.

Type

:SVGElement

svgElem

The SVG element to render the chart to.

Type
  • SVGElement

:boolean

usesGlobalState <readonly>

A flag indicating that the chart uses global date, time and location.

Type
  • boolean

Methods


dispose()

Cleans up the sun-path and removes all event listeners.

NOTE: Only call this method when the sun-path is no longer needed and you wish to free all its resources.


height( [height])

Get/set the overall height of the chart, in pixels.

Parameters:
Name Type Argument Description
height number <optional>

When provided, this sets the new chart height in pixels.

Returns:

Returns the current chart height in pixels.

Type
number

paddingBottom( [pixels])

Get/set the inset on the bottom side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the bottom side.

Returns:

Returns the current bottom padding in pixels.

Type
number

paddingLeft( [pixels])

Get/set the inset on the left side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the left side.

Returns:

Returns the current left padding in pixels.

Type
number

paddingRight( [pixels])

Get/set the inset on the right side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the right side.

Returns:

Returns the current right padding in pixels.

Type
number

paddingTop( [pixels])

Get/set the inset on the top side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the top side.

Returns:

Returns the current top padding in pixels.

Type
number

refresh()

Regenerates the whole chart from scratch.

Returns:

Returns this chart instance to support method chaining.

Type
object

rescale( [instant])

Initiates a rescaling of the chart when it has changed size or shape.

The maximum frequency at which this method will actually rescale the chart is governed by the 'throttledRescale' property.

Parameters:
Name Type Argument Default Description
instant boolean <optional>
<nullable>
false

An optional flag to make the rescale immediate even if debounced, defaults to false.


set(config)

Sets one or more configuration values for the chart.

Parameters:
Name Type Description
config object

An object containing one or more configuration settings.

Returns:

Returns this chart instance to support method chaining.

Type
object

show(state)

Shows or hides the chart based on given state.

Parameters:
Name Type Description
state boolean

Use true to show, false to hide.

Returns:

Returns this chart instance to support method chaining.

Type
object

throttledRescale( [ms])

Get/set the timer value for throttling calls to the rescale() method.

This basically means that multiple calls to the rescale() method that occur within the specified number of milliseconds will be amalgamated to a single call that occurs at the end of that period.

Parameters:
Name Type Argument Description
ms number <optional>

When provided, this sets the throttling time, in milliseconds. Any value less than 5ms effectively turns off throttling.

Returns:

Returns the current throttling time in milliseconds.

Type
number

update()

Regenerates just the date indicator.

Returns:

Returns this chart instance to support method chaining.

Type
object

width( [width])

Get/set the overall width of the chart.

Parameters:
Name Type Argument Description
width number <optional>

When provided, this sets the new chart width in pixels.

Returns:

Returns the current width in pixels.

Type
number