Class: PlotManager

org.bodytrack.grapher.PlotManager(dateAxisElementId, minTimeSecsopt, maxTimeSecsopt)

new PlotManager(dateAxisElementId, minTimeSecsopt, maxTimeSecsopt)

Creates a PlotManager associated with date axis specified by the given dateAxisElementId. If minTimeSecs and maxTimeSecs are not specified, the visible time range defaults to the past 24 hours.
Parameters:
Name Type Attributes Default Description
dateAxisElementId string the DOM element ID for the container div into which the date axis should be added
minTimeSecs number <optional>
24 hours ago a double representing the time in Unix time seconds of the start of the visible time range
maxTimeSecs number <optional>
now a double representing the time in Unix time seconds of the end of the visible time range
Source:

Methods

addDataSeriesPlot(plotId, datasource, plotContainerElementId, yAxisElementId, minValueopt, maxValueopt, styleopt, isLocalTimeopt, yAxisRangePaddingStrategyFunctionopt)

Helper method for adding a plot, shorthand for plotManager.addPlotContainer('plot_container').addDataSeriesPlot(...).
Parameters:
Name Type Attributes Default Description
plotId string | number A identifier for this plot, unique within the PlotContainer. Must be a number or a string.
datasource datasourceFunction function with signature function(level, offset, successCallback) resposible for returning tile JSON for the given level and offset
plotContainerElementId string the DOM element ID for the container div into which this plot should be added
yAxisElementId string the DOM element ID for the container div holding this plot's Y axis
minValue number <optional>
0 the minimum initial value for the Y axis (if the Y axis is created for this plot). Defaults to 0 if undefined, null, or non-numeric.
maxValue number <optional>
100 the maximum initial value for the Y axis (if the Y axis is created for this plot). Defaults to 100 if undefined, null, or non-numeric.
style Object <optional>
the style object. A default style is used if undefined, null, or not an object.
isLocalTime boolean <optional>
false whether the plot's data uses local time. Defaults to false (UTC).
yAxisRangePaddingStrategyFunction yAxisRangePaddingStrategyFunction <optional>
Y axis range padding strategy function. Defaults to the default padding strategy.
Source:
See:

addPlotContainer(plotContainerElementId) → {org.bodytrack.grapher.PlotContainer}

Adds a PlotContainer for the specified DOM element ID. If the PlotContainer has already been added, a new one is not created. Returns the PlotContainer.
Parameters:
Name Type Description
plotContainerElementId string the DOM element ID for the container div holding the plot container
Source:
Returns:
Type
org.bodytrack.grapher.PlotContainer

forEachPlotContainer(plotContainerIteratorFunction)

Method for iterating over each of the PlotContainer instances. Does nothing if the given plotContainerIteratorFunction is not a function.
Parameters:
Name Type Description
plotContainerIteratorFunction plotContainerIteratorFunction
Source:

getDateAxis() → {org.bodytrack.grapher.DateAxis}

Returns the DateAxis object representing the date axis.
Source:
Returns:
the DateAxis object
Type
org.bodytrack.grapher.DateAxis

getPlot(plotIdopt) → {org.bodytrack.grapher.DataSeriesPlot|null}

Returns the first plot found with the given plotId. Note that since the plotId need only be unique within its PlotContainer, it is possible to have more than one plot with the same plotId within a PlotManager. Thus, this is merely a convenience method which iterates over all PlotContainers looking for the specified plot and returns the first one found. If no matching plot is found, this method returns null. If the given plotId is undefined or null, this method returns the first plot found in the first PlotContainer found, or null if no plots have been added to any PlotContainer.
Parameters:
Name Type Attributes Description
plotId string | number <optional>
A identifier for the plot, unique within its PlotContainer. Must be a number or a string.
Source:
Returns:
Type
org.bodytrack.grapher.DataSeriesPlot | null

getPlotContainer(plotContainerElementIdopt) → {org.bodytrack.grapher.PlotContainer}

Returns the PlotContainer for the specified DOM element ID. Returns null if no such plot container exists. If the given plotContainerElementId is undefined or null, this method returns the first PlotContainer found, or null if none have been added.
Parameters:
Name Type Attributes Description
plotContainerElementId string <optional>
the DOM element ID for the container div holding the desired plot container.
Source:
Returns:
Type
org.bodytrack.grapher.PlotContainer

getYAxis(yAxisElementIdopt) → {org.bodytrack.grapher.YAxis}

Returns the YAxis for the specified DOM element ID. Returns null if no such axis exists. If the given yAxisElementId is undefined or null, this method returns the first Y axis found in the first PlotContainer found, or null if no Y axes have been added to any PlotContainer.
Parameters:
Name Type Attributes Description
yAxisElementId string <optional>
the DOM element ID for the container div holding the desired Y axis
Source:
Returns:
Type
org.bodytrack.grapher.YAxis

removeAllPlotContainers()

Removes all PlotContainers from PlotManger.
Source:

removePlotContainer(plotContainerElementId)

Removes the plotContainer with the given plotContainerId from this PlotManager.
Parameters:
Name Type Description
plotContainerElementId string | number A identifier for the plotContainer to remove, unique within the PlotManager. Must be a number or a string.
Source:

setCursorColor(colorDescriptor)

Sets the cursor to the color described by the given colorDescriptor, or to black if the given colorDescriptor is undefined, null, or invalid. The color descriptor can be any valid CSS color descriptor such as a word ("green", "blue", etc.), a hex color (e.g. "#ff0000"), or an RGB color (e.g. "rgb(255,0,0)" or "rgba(0,255,0,0.5)").
Parameters:
Name Type Description
colorDescriptor string a string description of the desired color.
Source:

setWidth(newDesiredWidth)

Sets the width of the date axis and all plot containers to the given width.
Parameters:
Name Type Description
newDesiredWidth int the new width
Source:

setWidthCalculator(widthCalculatorFunction)

Sets the width calculator if the given widthCalculatorFunction is a function. Otherwise, sets the calculator to null.
Parameters:
Name Type Description
widthCalculatorFunction
Source:

setWillAutoResizeWidth(willAutoResizeWidth, widthCalculatorFunctionopt)

Set whether the PlotManager should auto-resize the width of the date axis and all plot containers upon resize of the browser window. Although the widthCalculatorFunction function is optional, it must be provided at least once (either here or via #setWidthCalculator) in order for auto-resizing to do anything. After setting it, you are then free to call this function with only the first argument to toggle auto-resizing. If the second argument is undefined null, or not a function, the stored function will not be changed.
Parameters:
Name Type Attributes Description
willAutoResizeWidth boolean whether the PlotManager should auto resize the width of the date axis and all plot containers upon resize of the browser window.
widthCalculatorFunction widthCalculatorFunction <optional>
function which calculates and returns the desired width of the date axis
Source: