API Docs for: 0.0.1
Show:

BarGraph Class

Module: niviz

Visualization of a singular snow profile as bar graph with optional curves.

Constructor

BarGraph

(
  • paper
  • properties
)

Parameters:

Methods

bar

(
  • data
  • valuefunc
  • drawaspng
)
private

Draw bars into the BarGraph for a certain data with a certain value function. This function takes a value from the profile feature (passed as data) and returns a single number that determines the length of the bar denoted by the axis this.range.axis.

Parameters:

  • data Feature

    A niViz feature such as Hardness

  • valuefunc Function
  • drawaspng Boolean

    Whether to draw bars on png canvas or as svg elements

button

() private

Create 'Reset zoom' button.

callback

() private chainable

Call all callbacks registered.

changed

() Boolean private

Check whether the max and min snow height or the span of the ordinate has changed.

Returns:

Boolean:

true if there was a change, false otherwise

clearcurve

()

Remove the currently displayed curve.

configure

() private

Calculate important corner points of this BarGraph instance and initialize properties.

coordfunc

() Function private

Create a coordinate function for the bars.

Returns:

Function:

The coordinate calculation function

curve

(
  • data
  • axis
  • color
  • callback
  • stairs
)

Draw curve for a certin parameter, either as stair case graph or curve.

Parameters:

  • data Feature
  • axis Axis
  • color String
  • callback Function

    Function that is called on label click

  • stairs Boolean

    true = display the curve as stair case graph

datetime

(
  • datetime
)
private

Display date and time of current profile.

Parameters:

  • datetime Moment

draggable

(
  • element
)
private

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

Parameters:

  • element Element

    element to set up with drag functionality

draw

() chainable

Remove layer popup and curve dot

draw

(
  • profile
)

Draw the complete BarGraph.

Parameters:

drawPNGPolygon

(
  • path
  • options
)
private

Draw a PNG polygon onto the png canvas

Parameters:

greenbar

(
  • svg
)
private

Draw the green bar if necessary, i. e. if the profile height is less than the snow height or if the snow height is zero.

Parameters:

  • svg Object

    group container to append to

grid

() private

Draw the top and bottom grid of the abscissa (user configured) including annotating texts.

gridx

(
  • data
  • axis
  • color
  • callback
)
private

Draw grid for abscissa axis - if curve should be displayed.

Parameters:

  • data Feature
  • axis Axis
  • color String
  • callback Function

    Function that is called on label click

gridy

() Object private

Draw the grid of the ordinate (snow height) including annotating texts.

Returns:

Object:

svg group container

height

(
  • reatio
)
Number private

Given a percentage, calculate a corresponding value within this.range.min (0%) and this.range.max (100%).

Parameters:

Returns:

highlight

(
  • last
  • current
)
Object private

Highlight the current cursor position by showing a popup to the right of the bar currently active. Remove any opacity on active bar.

Parameters:

  • last Object

    Last active bar

  • current Object

    Bar to activate

Returns:

Object:

Reference to currently active bar

index

(
  • y
)
Number private

Calculate the index of the bar that spans the y value passed.

Parameters:

  • y Number

    y-coordinate (height)

Returns:

Number:

Index in this.bars or undefined

mousedblclick

() private

Method that emits a layer event to the emitter specified in the properties

mouseevents

(
  • svg
)
private

Create a cover for the graph area and turn the drag events on

Parameters:

  • svg Object

    group container to append the cover to

mousemove

() Function private

Method that generates a function in a closure to deal with the mousemove event. It calls the method BarGraph:highlight and BarGraph:showdot in turn.

Returns:

Function:

mousemove handler

mouseon

(
  • on
)
private

This method enables/disables the mousemove event on the element spanning the graph (this.cover).

Parameters:

  • on Boolean

    Whether to turn the mousemove event on or off

pastePNG

(
  • origin
)
private

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

Parameters:

  • origin Object

    has a x and y property

path

(
  • grid
  • path
  • svg
)
private

Draw grid paths, either on the grid (light and dotted) or as solid lines.

Parameters:

  • grid Boolean

    true if dotted, false if solid

  • path Array

    The path to draw

  • svg Object

    group container to append to

reconfigure

(
  • properties
)

Cleanup the graph by deleting some visual elements and then call configure() to set up valid config again.

Parameters:

remove

(
  • name
)
private

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

Parameters:

  • name String

    Object identifier

reset

() private

Reset the zoom, redraw ordinate grid, redraw bars.

setupPNG

(
  • width
  • height
)
private

Set width and height for the png canvas, which is an SVG image element

Parameters:

showdot

(
  • coord
  • lastindex
)
Number private

Highlight the current cursor position by adding a dot on top of the currently active curve (if activated). Calls BarGraph:showlegend.

Parameters:

  • coord Number

    x-coordinate of dot

  • lastindex Number

    Last index of layer array of curve feature

Returns:

Number:

Current index of layer array of highlighted curve feature

showlegend

(
  • color
  • text
)
private

Highlight the current cursor position by adding a legend denoting the current data value at the position of the dot.

Parameters:

  • color String

    Color of the legend

  • text String

    Actual test to display

unhighlight

() private

Remove the highlight on the currently highlighted bar, including the popup.

zoom

(
  • start
  • end
)
private

Zoom into the range denoted by the start and end parameters.

Parameters: