API Docs for: 0.0.1
Show:

Rangegraph Class

Extends Graph
Module: niviz

The Rangegraph class provides the basic visual means to display time series of data (e. g. snow profiles or meteo data). The class focuses on the display of the dates along the abscissa and provides methods to easily change the range of the dates to be displayed. No interactivity is provided by the Rangegraph - the children of the Rangegraph class shall deal with this issue.

Constructor

Rangegraph

(
  • data
  • canvas
  • properties
)

Parameters:

  • data Object

    Time series of data

  • canvas Object

    A svg element that will be used as SnapSVG paper

  • properties Object

Methods

config

() protected

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

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

(
  • current
)
protected

Method to be called during dragging on top of cover.

Parameters:

  • current Moment

    Date at current drag position

dragend

(
  • current
  • ms
)
protected

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

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: lib/graph.js:106

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

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

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
)
protected

Method to be called when mousemove event is detected.

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

Method to be called when mouseout event is detected.

mouseout

() protected

Method to be called when mouse events are turned off. Use this to implement cleanup routines.

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

remove

(
  • ctx
  • name
)
protected

Check if the object with identifier name exists in context ctx and try to remove it from the paper and then delete the object itself.

Parameters:

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

setProperties

(
  • properties
)

Overwrite current properties with the ones passed as parameter.

Parameters:

synchronize

(
  • graph
)
protected

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

Parameters: