API Docs for: 0.0.1
Show:

Timeline Class

Extends Rangegraph
Module: niviz

Visualization of a time line of snow profiles.

Constructor

Timeline

(
  • data
  • canvas
  • properties
)

Parameters:

  • data Station
  • canvas Object

    A svg element that will be used as SnapSVG paper

  • properties Object

Methods

clip

(
  • start
  • end
)
private

Show a part (or all) of the data within a start and an end date.

Parameters:

  • start Moment

    Start date

  • end Moment

    End date

config

() protected

Configure basic properties of the Rangegraph such as font, margins, height and width

coordx

(
  • date
)
Number private

Get the rounded x-coordinate for a given date.

Parameters:

  • date Moment

Returns:

Number:

x-coordinate

coordy

(
  • height
)
Number private

Get the rounded y-coordinate for a given (snow) height.

Parameters:

Returns:

Number:

y-coordinate

datelabel

(
  • date
)
protected

Draw a date label below the abscissa for any given date

Parameters:

  • date Moment

    Date to be highlighted on the abscissa

desynchronize

(
  • graph
)
protected

Desynchronize this graph with another rangegraph derivate by registering for all the relevant events.

Parameters:

drag

(
  • Date
)
protected

Inherited from Rangegraph but overwritten in lib/graphs/timeline.js:564

Method to be called during dragging on top of cover.

Parameters:

  • Date Moment

    at current drag position

dragend

(
  • current
  • ms
)
protected

Inherited from Rangegraph but overwritten in lib/graphs/timeline.js:587

Method to be called at the end of dragging on top of cover.

Parameters:

  • current Moment

    Date at current drag position

  • ms Number

    Duration of drag in ms

draggable

(
  • element
)
private

Drag functions used for zooming when mouse goes down over this.cover, start drawing selection box.

Parameters:

  • element Element

    SnapSVG element to set up with drag functionality

dragstart

(
  • current
)
protected

Inherited from Rangegraph but overwritten in lib/graphs/timeline.js:576

Method to be called at the start of dragging on top of cover.

Parameters:

  • current Moment

    Date at current drag position

draw

()

Inherited from Graph but overwritten in lib/graphs/timeline.js:847

Draw the Timeline and set up the mouse events.

draw_indicator

(
  • current
)
private

Draw the indicator line in case the user desires to lock onto a certain profile.

Parameters:

  • current Number

    Index of profile in this.data.profiles

drawPNG

() private

Draw the PNG image for the currently selected parameter. The method creates a canvas element to use as drawing board. Once the graph is drawn onto the canvas, the pastePNG method is called which tranforms the image into a base64 encoded dataURI and embeds it into an SVG image tag.

getpaper

() private

Check if this instance has a valid SnapSVG paper object, in case the size of the canvas element has changed or no paper object is present resize or create the paper object.

griddates

(
  • start
  • end
)
Array private

Given a start and an end date return an array of dates that divide up the range between the start and end date into approximately even intervals

Parameters:

  • start Moment

    Start date of time series

  • end Moment

    End date of time series

Returns:

Array:

Array of dates

gridx

() protected

Draw the coordinate system with dotted lines and a frame around it

gridy

() private chainable

Draw the ordinate legend and grid for the snow height

gtlegend

() private

Draw the grain shape legend and hook it up with the mousemove event. Hovering on a grain shape color will display a popup with a description of the grain shape.

header

() private chainable

Draw a header at the left top of the graph. The header information is clickable and links to a map revealing the exact location.

highlight

(
  • current
  • noemit
)
private

Highlight the current cursor position by drawing the date label and displaying the current snow height.

Parameters:

  • current Number

    Index in this.data.profiles

  • noemit Boolean

    Whether to emit the 'profile' event

hs

(
  • snowheight
)
protected

Display the snow height at the current cursor position.

Parameters:

  • snowheight Number

    The height of snow in cm

indices

(
  • startdate
  • enddate
)
private

Given a start and end index (for this.data.profiles) draw the current parameter. In case the start index is not 0 and the end index is not the last index show the resetbutton.

Parameters:

  • startdate Moment

    Start date of range

  • enddate Moment

    End date of range

labelsx

(
  • dates
)
Array private

Given an array of dates, create the respective labels to be shown

Parameters:

  • dates Array

    An array of dates as moment objects

Returns:

Array:

Array of strings representing the passed dates

legend

() private chainable

Draw the legend on the left side of the graph. The legend consists of a bar filled with the color gradient for the current parameter and a few labels to denote important values on the bar.

mode

(
  • start
  • end
)
String private

Check the size of the date range given.

Parameters:

  • start Moment

    Start date of time series

  • end Moment

    End date of time series

Returns:

String:

Categorization of date range as 'years', 'months', 'monthweeks' or 'days'

mousemove

(
  • e
  • offset
)
private

Inherited from Rangegraph but overwritten in lib/graphs/timeline.js:462

Method to be called when mousemove event is detected. It calls the method Timeline:highlight in turn, which displays the date label.

Parameters:

  • e Object

    Mousemove DOM event object

  • offset Object

    canvas offset object

mouseon

(
  • on
)
protected

This method enables/disables the mousemove event on the area spanning the graph. Children may implement the methods mouseout, mousemove and mouseoff to tap into this event.

Parameters:

  • on Boolean

    Whether to turn the mousemove event on or off

mouseout

() protected

Inherited from Rangegraph but overwritten in lib/graphs/timeline.js:435

Method to be called when mouseout event is detected. Delete the currently displayed date label (unhighlight) and display the date label for the current indicator position, if the indicator is set.

mouseout

() protected

Method to be called when mouse events are turned off.

next

()

In case an indicator is present, move one profile to the right.

pastePNG

() private

Converts the image on the canvas into a base64 encoded dataURI and embeds it in a SVG image tag.

previous

()

In case an indicator is present, move one profile to the left.

range

(
  • start
  • end
)
protected

Set the new date range for the abscissa

Parameters:

  • start Moment

    Start date of time series

  • end Moment

    End date of time series

reconfigure

() private chainable

Reconfigure gridy, i.e. snow height axis, according to zoom area and draw it

remove

(
  • name
)
static

Inherited from Rangegraph but overwritten in lib/graphs/timeline.js:105

Remove a parameter from the timeline Config Timeline.defaults. This method is invoked by the settings modal when a user removes a parameter from the pro parser parameters section.

Parameters:

  • name String

    Paramter name (e. g. ramm, density)

reset

() private

Show all the data from start to end and remove the 'Show all' button.

resetbutton

(
  • show
  • callback
)
protected

Show or delete the resetbutton

Parameters:

  • show Boolean

    true = show button, false = hide button

  • callback Function

    Callback function executed on click

setDate

()

Set the date to display explicitly (may be used externally)

setProperties

(
  • properties
)

Inherited from Rangegraph but overwritten in lib/graphs/timeline.js:140

Overwrite current properties with the ones passed as parameter. If a new parameter is set to display: emit the 'parameter' event and retrieve the gradient and color settings for the parameter.

Parameters:

setup

() private chainable

Setup the dimensions of the underlying Rangegraph and draw header, horizontal grid and legend.

synchronize

(
  • graph
)
protected

Synchronize this graph with another rangegraph derivate by registering for all the relevant events.

Parameters:

unhighlight

() private

Remove all highlights (date and snow height labels).

Properties

parameters

Array static

A list of parameters that are available for display.

parameters

Array

Get all selectable parameters.