BarGraph Class
Visualization of a singular snow profile as bar graph with optional curves.
Constructor
Item Index
Methods
bar
-
data
-
valuefunc
-
drawaspng
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.
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:
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:
The coordinate calculation function
curve
-
data
-
axis
-
color
-
callback
-
stairs
Draw curve for a certin parameter, either as stair case graph or curve.
datetime
-
datetime
Display date and time of current profile.
Parameters:
-
datetime
Moment
draggable
-
element
Drag functions used for zooming when mouse goes down over this.cover, start drawing selection box.
Parameters:
-
element
Elementelement to set up with drag functionality
draw
()
chainable
Remove layer popup and curve dot
drawPNGPolygon
-
path
-
options
Draw a PNG polygon onto the png canvas
Parameters:
-
path
Array -
options
Object
greenbar
-
svg
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
Objectgroup 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
Draw grid for abscissa axis - if curve should be displayed.
gridy
()
Object
private
Draw the grid of the ordinate (snow height) including annotating texts.
Returns:
svg group container
height
-
reatio
Given a percentage, calculate a corresponding value within this.range.min (0%) and this.range.max (100%).
Parameters:
-
reatio
NumberA percentage
Returns:
highlight
-
last
-
current
Highlight the current cursor position by showing a popup to the right of the bar currently active. Remove any opacity on active bar.
Returns:
Reference to currently active bar
index
-
y
Calculate the index of the bar that spans the y value passed.
Parameters:
-
y
Numbery-coordinate (height)
Returns:
Index in this.bars or undefined
mousedblclick
()
private
Method that emits a layer event to the emitter specified in the properties
mouseevents
-
svg
Create a cover for the graph area and turn the drag events on
Parameters:
-
svg
Objectgroup 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:
mousemove handler
mouseon
-
on
This method enables/disables the mousemove event on the element spanning the graph (this.cover).
Parameters:
-
on
BooleanWhether to turn the mousemove event on or off
pastePNG
-
origin
Converts the image on the canvas into a base64 encoded dataURI and embeds it in a SVG image tag.
Parameters:
-
origin
Objecthas a x and y property
path
-
grid
-
path
-
svg
Draw grid paths, either on the grid (light and dotted) or as solid lines.
reconfigure
-
properties
Cleanup the graph by deleting some visual elements and then call configure() to set up valid config again.
Parameters:
-
properties
Object
remove
-
name
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
StringObject identifier
reset
()
private
Reset the zoom, redraw ordinate grid, redraw bars.
setupPNG
-
width
-
height
Set width and height for the png canvas, which is an SVG image element
showdot
-
coord
-
lastindex
Highlight the current cursor position by adding a dot on top of the currently active curve (if activated). Calls BarGraph:showlegend.
Parameters:
Returns:
Current index of layer array of highlighted curve feature
showlegend
-
color
-
text
Highlight the current cursor position by adding a legend denoting the current data value at the position of the dot.
unhighlight
()
private
Remove the highlight on the currently highlighted bar, including the popup.