mplot.js
This page contains the full API reference for mplot.js, which draws scatter plots, histograms, bar charts, color maps and functions on custom pages.
For how to add plots to a custom page, with examples and screenshots, see Custom pages: plots of your own data.
mplot.js needs midas.js, controls.js and mhttpd.js to be included before it (see mhttpd.js). Call mplot_init() once the page has loaded: it creates a plot in each element with the class mplot, and reads the plots' ODB data once per second. Each element's MPlotGraph object is then in its mpg property.
Plot types
| Type | Data | Description |
|---|---|---|
scatter |
X and Y arrays, and optional X and Y errors | Points, with optional lines and error bars |
histogram |
An array of bin contents, and optional X values | Histogram. Without X values, the bins are centred at 0, 1, 2, ... |
bar |
X and Y arrays | Groups of bars. An array of strings as the X data gives a category axis |
colormap |
An array of nx * ny values |
A two-dimensional array drawn as colors. X changes fastest: (0,0), (1,0), ... (nx-1,0), (0,1), ... |
function |
An expression | A mathematical expression of x, calculated again each time the plot is drawn |
HTML attributes
Attributes without a number set up the first dataset. For several datasets, use the numbered versions, from 1 to 16. Paths of data (data-x, data-y, data-h, data-z and the errors) are relative to data-odb-path.
| Attribute | Plot types | Required | Default | Description |
|---|---|---|---|---|
data-type |
All | Chosen from the data attributes | Plot type: scatter, histogram, bar, colormap or function |
|
data-odb-path |
All except functions | "" |
ODB directory holding the data | |
data-x |
Scatter, bar | X data. An array of strings selects a category axis | ||
data-y |
Scatter, bar | Y data | ||
data-x-error, data-y-error |
Scatter | X and Y errors | ||
data-h |
Histogram | Bin contents | ||
data-z |
Color map | The nx * ny values |
||
data-nx, data-ny |
Color map | Number of cells in X and Y | ||
data-zero-color |
Color map | CSS color of cells whose value is below 0.5, e.g. white for empty cells | ||
data-function |
Function | A mathematical expression of x, or the absolute ODB path (starting with /) of a string holding one |
||
data-x1 … data-x16 |
Scatter, bar | data-x |
X data of each dataset | |
data-y1 … data-y16 |
Scatter, bar | Y data of each dataset | ||
data-x1-error … data-x16-error, data-y1-error … data-y16-error |
Scatter | X and Y errors of each dataset | ||
data-h1 … data-h16 |
Histogram | Bin contents of each histogram | ||
data-function1 … data-function16 |
Function | Expression (or ODB path) of each function | ||
data-label, data-label1 … data-label16 |
All | "" |
Legend label of each dataset | |
data-marker-style, data-marker1-style … data-marker16-style |
Scatter | circle |
Marker: none, circle, square, diamond, pentagon, triangle-up, triangle-down, triangle-left, triangle-right, cross or plus |
|
data-line-color, data-line1-color … data-line16-color |
Scatter, histogram, function | The next color of a sequence starting with #00AAFF. A histogram without a number is dark gray (#404040) |
CSS color of the line. The markers keep their own color | |
data-line-width, data-line1-width … data-line16-width |
Scatter, histogram, function | 2 |
Width of the line in pixels. 0 hides the line |
|
data-line-style, data-line1-style … data-line16-style |
Scatter, function | solid |
none, solid, dashed or dotted |
|
data-alpha, data-alpha1 … data-alpha16 |
All | 1 |
Opacity, from 0 (transparent) to 1 |
|
data-bar-width |
Bar | 0.3 |
Width of each group of bars, from 0 to 1 (where groups touch) |
|
data-title |
All | "" |
Title of the plot | |
data-x-text, data-y-text, data-z-text |
All (data-z-text: color map) |
"" |
Titles of the axes | |
data-x-type |
Scatter, bar | numeric |
numeric, datetime (Unix times) or category (strings) |
|
data-x-min, data-x-max |
All | For a function on its own | Automatic | Limits of the X axis. A function drawn with other data uses their range |
data-y-min, data-y-max |
All | Automatic | Limits of the Y axis | |
data-z-min, data-z-max |
Color map | Automatic | Limits of the color scale | |
data-x-log, data-y-log, data-z-log |
All (data-z-log: color map) |
false |
true or 1 for a logarithmic axis |
|
data-stats |
All except functions | 1 |
0 hides the box of statistics |
|
data-overlay |
All | Name of a function to draw on top of the plot. See callbacks | ||
data-event |
All | Name of a function that handles mouse events. See callbacks | ||
data-tooltip |
All | Name of a function that returns the tooltip text. See callbacks | ||
CSS width, height |
All | Size of the plot |
Instead of attributes, the element can contain a JSON object with graph settings.
Function expressions
Function plots use mathematical expressions, which aren't run as JavaScript:
| Element | Supported |
|---|---|
| Variable | x |
| Constants | pi, e |
| Operators | +, -, *, /, %, ^ and ** (both powers) |
| Functions | abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, exp, floor, log, ln, log10, max, min, pow, round, sign, sin, sinh, sqrt, tan, tanh, trunc |
log and ln are both the natural logarithm.
Callbacks
The values of data-overlay, data-event and data-tooltip are names of global functions of your own. The overlay and event functions can also be named in the graph settings overlay and event. The tooltip function can only be given with data-tooltip.
| Attribute | Called as | Returns |
|---|---|---|
data-overlay |
f(plot, ctx), after the plot has been drawn. plot is the MPlotGraph and ctx its canvas context |
Nothing |
data-event |
f(event, plot, ix, iy), for each mouse event. ix and iy are the column and row of a color map |
true to stop the plot's normal handling (e.g. zooming) |
data-tooltip |
f(plot), when the mouse is over a point. The point is in plot.marker (x, y, and z for a color map) |
The tooltip text |
Graph settings
The JSON object inside an mplot element, and the second argument of the MPlotGraph constructor, can contain any of these settings. Settings that aren't given keep their defaults.
| Setting | Default | Description |
|---|---|---|
type |
Plot type of the first dataset | |
showMenuButtons |
true |
Show the menu buttons |
mouseWheelZoom |
true |
Zoom with the mouse wheel |
color.background |
"#FFFFFF" |
Background color |
color.axis |
"#808080" |
Color of the axes and ticks |
color.grid |
"#D0D0D0" |
Color of the grid lines |
color.label |
"#404040" |
Color of the axis labels |
title.text |
"" |
Title |
title.color |
"#000000" |
Color of the title |
title.backgroundColor |
"#808080" |
Background color of the title |
title.textSize |
16 |
Font size of the title |
legend.show |
true |
Show the legend |
legend.color |
"#D0D0D0" |
Color of the legend's border |
legend.backgroundColor |
"#FFFFFF" |
Background color of the legend |
legend.textColor |
"#404040" |
Color of the legend's text |
legend.textSize |
12 |
Font size of the legend |
barWidth |
0.3 |
Width of each group of bars, from 0 to 1 |
stats.show |
true |
Show the box of statistics |
xAxis.type |
"numeric" |
"numeric", "datetime" or "category" |
xAxis.log, yAxis.log, zAxis.log |
false |
Logarithmic axis |
xAxis.min, xAxis.max, yAxis.min, yAxis.max, zAxis.min, zAxis.max |
Automatic | Axis limits |
xAxis.grid, yAxis.grid |
true |
Draw grid lines |
xAxis.textSize, yAxis.textSize, zAxis.textSize |
16 |
Font size of the tick labels |
xAxis.title.text, yAxis.title.text, zAxis.title.text |
"" |
Axis titles |
xAxis.title.textSize, yAxis.title.textSize, zAxis.title.textSize |
16 |
Font size of the axis titles |
zAxis.show |
true |
Show the color scale of a color map |
overlay |
Name of a function to draw on top of the plot, as for data-overlay. See callbacks |
|
event |
Name of a function that handles mouse events, as for data-event. See callbacks |
|
plot |
[] |
The datasets, with the dataset settings below |
Dataset settings
Each dataset in the plot array of the graph settings, and the argument of MPlotGraph.addPlot(), can contain any of these settings. Settings that aren't given keep their defaults.
| Setting | Default | Description |
|---|---|---|
type |
"scatter" |
Plot type: "scatter", "histogram", "bar", "colormap" or "function" |
label |
"" |
Legend label |
odbPath |
"" |
ODB directory holding the data |
xPath, yPath, zPath |
"" |
ODB paths of the data, relative to odbPath |
xErrorPath, yErrorPath |
"" |
ODB paths of the errors, relative to odbPath |
xData, yData, zData |
[] |
The data, for plots of data from JavaScript |
xErrorData, yErrorData |
[] |
The errors, for plots of data from JavaScript |
function |
"" |
Expression of a function plot |
functionPath |
"" |
Absolute ODB path of a string holding the expression |
nx, ny |
0 |
Size of a color map |
zMin, zMax |
Automatic | Limits of a color map's scale |
showZScale |
false |
Show the color scale of a color map |
zeroColor |
Color of cells whose value is below 0.5 | |
xMin, xMax, yMin, yMax |
Automatic | Range drawn |
alpha |
1 |
Opacity, from 0 to 1 |
marker.draw |
true |
Draw markers |
marker.style |
"circle" |
Marker shape, as for data-marker-style |
marker.size |
10 |
Marker size |
marker.lineWidth |
2 |
Width of the marker's outline |
marker.lineColor, marker.fillColor |
The next color in the sequence | Colors of the marker's outline and fill |
line.draw |
true |
Draw a line between the points |
line.fill |
false |
Fill the area under the line |
line.color |
The next color in the sequence | Line color |
line.style |
"solid" |
"none", "solid", "dashed" or "dotted" |
line.width |
2 |
Line width |
Classes, functions and variables
Classes
MPlotGraph
class MPlotGraph
Umbrella figure object containing the axes, buttons, and all plots. MPlotGraph redraws all contained elements upon any change to the figure (zoom, pan, new line, etc). For most drawing applications you will need only draw, and addPlot or setData.
Defined in resources/mplot.js:1149
Methods
addPlot
addPlot(plotParam)
Add a plot to the graph Plot drawing info is stored in the MPlotGraph.param.plot array. Parameters can be modified in realtime by editing this array directly
let index = plt.addPlot({xData:[1,2,3], yData:[4,5,6], yErrorData=[1,1,2]});
Parameters:
-
plotParam(Object) –subset of keys from thedefaultPlotParamobject
Returns:
-
int–index of the plot added in the MPlotGraph.param.plot array
Defined in resources/mplot.js:1574
barGeometry
barGeometry(plotIndex)
Use matching grouped-bar widths and offsets for rendering and selection.
Defined in resources/mplot.js:1852
baselineY
baselineY()
Screen y of the baseline that filled areas, histogram bins and bars rise from. A log axis has no zero to anchor to, so the bottom of the frame stands in for it.
Defined in resources/mplot.js:1896
calcMinMax
calcMinMax()
Calculate the min/max of each axis
Defined in resources/mplot.js:2078
calcStats
calcStats()
Calculate the stats to display in the graph These are stored in MPlotGraph.param.stats. See also defaultGraphParam
Defined in resources/mplot.js:2249
constructor
constructor(divElement, graphParam)
let graph = MPlotGraph();
graph.addPlot({xData:[1,2,3], yData:[4,5,6]});
graph.draw();
Parameters:
-
divElement(Object) –HTML div element to place the plot into -
graphParam(Object) –JS object with keys a subset ofdefaultGraphParam, controls plot display style.
Defined in resources/mplot.js:1160
createDownloadSelector
createDownloadSelector()
Make a download selection menu
Defined in resources/mplot.js:1651
deletePlot
deletePlot(label)
Delete an exising plot
plt.deletePlot(0);
Parameters:
-
label(int/string) –to the plot array [0...n-1] or label name of plot
Defined in resources/mplot.js:1645
download
download(mode)
Download the figure as an image or data
Parameters:
-
mode(string) –either "CSV" | "PNG"
Defined in resources/mplot.js:4320
draw
draw()
draw all elements of the graph into the canvas: axes, plots, text, buttons, etc.
Defined in resources/mplot.js:2569
drawCAxis
drawCAxis(ctx, x1, y1, width, tick, label, xmin, xmax, category, draw)
Draw the xaxis as "category"
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
x1(number) –coordinate position of the axis on screen -
y1(number) –coordinate position of the axis on screen -
width(number) –width of the axis, likely also the width of the plot -
tick(number) –height in pixel of tick markers at labels -
label(number) –distance of text from axis -
xmin -
xmax -
category(string) –array of category labels to plot -
draw(bool) –if false, only return height of labels
Returns:
-
float–maximum height + 2
Defined in resources/mplot.js:4233
drawMarker
drawMarker(ctx, p, x, y)
Draw a single marker on plot
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
p(object) –param object from MPlotGraph -
x(number) –x coord of marker -
y(number) –y coord of marker
Defined in resources/mplot.js:2432
drawTAxis
drawTAxis(ctx, x1, y1, width, xr, minor, major, text, label, grid, xmin, xmax)
Draw the xaxis as "datetime"
Tick spacing is picked internally from xmin, xmax and width out of a table of calendar-friendly intervals (seconds .. days). The minor, major, text, label and grid arguments only say how far each stroke extends below the axis line. Returns without drawing, after showAlert(), if the limits or the width are unusable.
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
x1(number) –screen coordinate of the left end of the axis -
y1(number) –screen coordinate of the axis line; ticks and labels go below it -
width(number) –width of the axis, likely also the width of the plot -
xr(number) –right limit for the label text, which is shifted inwards so it never crosses xr; draw() passes the full canvas width -
minor(number) –length of a minor tick mark -
major(number) –length of a major tick mark -
text(number) –length of a tick mark that carries a label -
label(number) –offset of the label text from the axis, 0 to suppress labels -
grid(number) –length of the grid lines, 0 to suppress them. Drawn at the labelled and major ticks. draw() passes y2 - y1, a negative length spanning the plot area. -
xmin(number) –low limit of the axis, in seconds since the epoch -
xmax(number) –high limit of the axis, in seconds since the epoch
Defined in resources/mplot.js:4084
drawTextBox
drawTextBox(ctx, text, x, y)
Draw a box encapsulating some text. Width and height are set by the text
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
text(string) –text to include in the box -
x(number) –coordinate of box lower left corner -
y(number) –coordinate of box lower left corner
Defined in resources/mplot.js:4462
drawXAxis
drawXAxis(ctx, x1, y1, width, minor, major, text, label, grid, xmin, xmax, logaxis)
Draw the xaxis as "numeric"
Tick spacing is derived internally from xmin, xmax and width. The minor, major, text, label and grid arguments only say how far each stroke extends from the axis line (positive = downwards on the canvas). Returns without drawing, after showAlert(), if the limits or the width are unusable.
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
x1(number) –screen coordinate of the left end of the axis -
y1(number) –screen coordinate of the axis line; ticks and labels go below it -
width(number) –width of the axis, likely also the width of the plot -
minor(number) –length of a minor tick mark -
major(number) –length of a major tick mark -
text(number) –length of a tick mark that carries a label -
label(number) –offset of the label text from the axis, 0 to suppress labels -
grid(number) –length of the grid lines, 0 to suppress them. Drawn at the labelled and major ticks, and on a log axis at the minor ticks too. draw() passes y2 - y1, a negative length spanning the plot area. -
xmin(number) –low limit of the axis -
xmax(number) –high limit of the axis -
logaxis(bool) –if true draw axis on a log scale (base 10)
Defined in resources/mplot.js:3591
drawXErrorBar
drawXErrorBar(ctx, p, x, y, x1, x2)
Draw a single horizontal errorbar on the plot
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
p(object) –param object from MPlotGraph -
x(number) –x coord of bar center (unused) -
y(number) –y coord of bar center -
x1(number) –position of the low side error bar enpoint -
x2(number) –position of the high side error bar enpoint
Defined in resources/mplot.js:2534
drawYAxis
drawYAxis(ctx, x1, y1, height, minor, major, text, label, grid, ymin, ymax, logaxis, draw)
Draw the yaxis as "numeric"
Tick spacing is derived internally from ymin, ymax and height. The minor, major, text, label and grid arguments only say how far each stroke extends from the axis line: negative draws them to the left of it, as draw() does for the y axis, positive to the right, as it does for the z axis. Returns without drawing, after showAlert(), if the limits or the height are unusable.
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
x1(number) –screen coordinate of the axis line; ticks and labels go beside it -
y1(number) –screen coordinate of the bottom end of the axis -
height(number) –height of the axis, likely also the height of the plot, extending upwards from y1 -
minor(number) –length of a minor tick mark -
major(number) –length of a major tick mark -
text(number) –length of a tick mark that carries a label -
label(number) –offset of the label text from the axis, 0 to suppress labels. A negative value right-aligns the text, a positive one left-aligns it. -
grid(number) –length of the grid lines, 0 to suppress them. Drawn at the labelled and major ticks, and on a log axis at the minor ticks too. the y axis passes x2 - x1, spanning the plot area. -
ymin(number) –low limit of the axis -
ymax(number) –high limit of the axis -
logaxis(bool) –if true draw axis on a log scale (base 10) -
draw(bool) –if true draw the axis, if false only measure the labels
Returns:
-
number|undefined–width of the widest label in pixels, which draw() uses to place the plot area, or undefined if the limits were rejected
Defined in resources/mplot.js:3829
drawYErrorBar
drawYErrorBar(ctx, p, x, y, y1, y2)
Draw a single vertical errorbar on the plot
Parameters:
-
ctx(CanvasRenderingContext2D) –canvas context, for example: canvas.getContext("2d") -
p(object) –param object from MPlotGraph -
x(number) –x coord of bar center -
y(number) –y coord of bar center (unused) -
y1(number) –position of the low side error bar enpoint -
y2(number) –position of the high side error bar enpoint
Defined in resources/mplot.js:2555
findPlot
findPlot(label)
Defined in resources/mplot.js:1597
getMeasurementBox
getMeasurementBox()
Translate the floating measurement dialog to plot coordinates for hit testing.
Defined in resources/mplot.js:4483
invalidateColormap
invalidateColormap(plot = 0)
Mark a colormap bitmap stale after changing its data in place. Redraw separately.
Defined in resources/mplot.js:1637
keyDown
keyDown(e)
Handle key events
Parameters:
-
e(Object) –keydown event with properties key, metaKey, ctrlKey, target, etc
Defined in resources/mplot.js:1711
markerToScreen
markerToScreen(point)
Project a saved marker, including its dataset's offset within a bar group.
Defined in resources/mplot.js:1862
modifyPlot
modifyPlot(label, plotParam)
Modify an exising plot Plot drawing info is stored in the MPlotGraph.param.plot array. Parameters can be modified in realtime by editing this array directly
plt.modifyPlot(0, {label:"Modified plot", line: {color: "red"}} );
Parameters:
-
label(int/string) –to the plot array [0...n-1] or label name of plot -
plotParam(Object) –subset of keys from thedefaultPlotParamobject
Defined in resources/mplot.js:1628
mouseEvent
mouseEvent(e)
Handle mouse events
Parameters:
-
e(Object) –mouse event object, specifies type, buttons
Defined in resources/mplot.js:4620
prepareFunctionPlots
prepareFunctionPlots()
Resolve function domains and calculate their initial Y ranges.
Defined in resources/mplot.js:1973
redraw
resetAxes
resetAxes()
Reset min/max of x and y axes, redraws
Defined in resources/mplot.js:4987
resize
resize()
Resize canvas and redraw
Defined in resources/mplot.js:1831
sampleFunctionPlot
sampleFunctionPlot(plot, pixelStep = 3)
Sample a function plot approximately once per pixelStep visible pixels.
Defined in resources/mplot.js:2052
screenToX
screenToX(x)
Convert screen coordinates to data coordinates x axis
Defined in resources/mplot.js:1953
screenToY
screenToY(y)
Convert screen coordinates to data coordinates y axis
Defined in resources/mplot.js:1963
setData
setData(index, x, y, z)
Set the data for the mplot For new applications please use addPlot
Parameters:
-
index(int) –Choose which graph to modify 0...n-1. Stored in the MPlotGraph.param.plot array -
x(float[]) –X values -
y(float[]) –Y values -
z(float[]) –Z values
Defined in resources/mplot.js:1738
showAlert
showAlert(message)
Error message display
Parameters:
-
message(String) –message to display in popup alert
Defined in resources/mplot.js:4999
traceRuns
traceRuns(ctx, xData, yData, baseline)
Add a series to the current path as one subpath per run of drawable points.
A non-finite point ends the current run, so nothing is dragged across the gap. A value <= 0 on a log axis also ends a fill run, but a stroked line runs through it off the frame. With a baseline, each run is closed down to it, making a fillable polygon; without one, the runs are open polylines for stroking. Points go straight onto the path, so a large plot costs no per-point allocation.
Parameters:
-
ctx(CanvasRenderingContext2D) –context with a path already begun -
xData(number[]) –x values -
yData(number[]) –y values -
baseline(number) –screen y to close each run down to, for a fill
Defined in resources/mplot.js:1913
updateMarker
updateMarker(e)
Locate a nearby plot point, or use the cursor coordinates when snapping is disabled.
Defined in resources/mplot.js:4493
xToScreen
xToScreen(x)
Convert data coordinates to screen coordinates x axis.
Defined in resources/mplot.js:1872
yToScreen
yToScreen(y)
Convert data coordinates to screen coordinates y axis. See xToScreen for the NaN rule.
Defined in resources/mplot.js:1883
Functions
checkPlotType
function checkPlotType(type)
Defined in resources/mplot.js:1082
deepMerge
function deepMerge(target, source)
Recursively merge object keys from source into target. Modifies in-place.
Parameters:
-
target(object) –the object to make new keys or overwrite existing ones -
source(object) –the object from which the keys are copied
Returns:
-
object–the target with the new keys
Defined in resources/mplot.js:771
isObject
function isObject(item)
Defined in resources/mplot.js:734
loadMPlotData
function loadMPlotData()
Load data from the ODB for all HTML elements with the mplot class name
Defined in resources/mplot.js:786
mpgDialog
function mpgDialog(p)
Defined in resources/mplot.js:1087
mplot_init
function mplot_init()
Initialize
Defined in resources/mplot.js:703
mplotCompileFunction
function mplotCompileFunction(expression)
Compile a mathematical expression into a function of x without using eval().
Defined in resources/mplot.js:446
mplotConfigureFunctionPlot
function mplotConfigureFunctionPlot(plot)
Defined in resources/mplot.js:689
mplotEvaluateFunction
function mplotEvaluateFunction(plot, x)
Defined in resources/mplot.js:680
mplotLogLimits
function mplotLogLimits(min, max, padMin, padMax)
Force a pair of axis limits onto the positive range a log axis can display. An unusable limit is rebuilt from the usable one, so an explicit limit on one side survives when the data give nothing for the other. The padding fractions refer to the FINAL span, so a padded side occupies exactly that fraction of the plot.
Parameters:
-
min(number) –lower limit, Infinity when the data held no positive value -
max(number) –upper limit, -Infinity when the data held no positive value -
padMin(number) –fraction of the final log span added below min -
padMax(number) –fraction of the final log span added above max
Returns:
-
number[]–[min, max], both finite with 0 < min < max
Defined in resources/mplot.js:646
mplotMinMax
function mplotMinMax(data, positiveOnly = false)
Smallest and largest value of a data array, in a single pass. Values are coerced to numbers; entries that cannot be plotted (NaN, +-Infinity) are skipped rather than poisoning both results, so a single bad point cannot destroy the range of a whole series. An array with no usable entry yields [Infinity, -Infinity], which callers must read as "no range".
Parameters:
-
data(number[]) –data array -
positiveOnly(boolean, default:false) –also skip values <= 0, which a log axis cannot show
Returns:
-
number[]–[min, max]
Defined in resources/mplot.js:619
mplotPrepareFunction
function mplotPrepareFunction(plot)
Defined in resources/mplot.js:666
profile
function profile(flag)
Defined in resources/mplot.js:716
ptimeToLabel
function ptimeToLabel(sec, base, forceDate)
Convert time in seconds to a human-readable string
Parameters:
-
sec(number) –number of seconds -
base(number) –chooses which display option to use on conversion -
forceDate(bool) –if true force showing the date, else can show only time
Returns:
-
string–human-readable datetime as a string
Defined in resources/mplot.js:1054
windowResize
function windowResize()
Resize all mplot objects as defined by their class
Defined in resources/mplot.js:728
Variables
colorPalette
let colorPalette = […]
Use Viridis color map from matplotlib for 2D plots
Defined in resources/mplot.js:23
colorPaletteBytes
let colorPaletteBytes = …
Cache the palette as bytes for bitmap colormaps.
Defined in resources/mplot.js:282
defaultGraphColor
let defaultGraphColor = […]
Default parameters for the MPlotGraph constructor These parameters control the formatting of the whole graph (figure) Only a subset of the below keys are needed to be passed to the MPlotGraph constructor. The rest are taken as below.
Defined in resources/mplot.js:15
defaultGraphParam
let defaultGraphParam = {…}
Defined in resources/mplot.js:285
defaultPlotParam
let defaultPlotParam = {…}
Default parameters for the MPlotGraph.addPlot() function These parameters control the formatting for each plot (read: dataset) added into the graph Only a subset of the below keys are needed to be passed to the addPlot function. The rest are taken as below.
Defined in resources/mplot.js:368
LN10
LN10 = 2.302585094
Defined in resources/mplot.js:993
LOG2
LOG2 = 0.301029996
Defined in resources/mplot.js:994
LOG5
LOG5 = 0.698970005
Defined in resources/mplot.js:995
mplotMathFunctions
const
const mplotMathFunctions = {…}
Defined in resources/mplot.js:415
poptions1
let poptions1 = {…}
Begin ptimeToLabel format options
Defined in resources/mplot.js:998
poptions2
let poptions2 = {…}
Defined in resources/mplot.js:1004
poptions3
let poptions3 = {…}
Defined in resources/mplot.js:1010
poptions4
let poptions4 = {…}
Defined in resources/mplot.js:1016
poptions5
let poptions5 = {…}
Defined in resources/mplot.js:1021
poptions6
let poptions6 = {…}
Defined in resources/mplot.js:1026
poptions7
let poptions7 = {…}
Defined in resources/mplot.js:1031
poptions8
let poptions8 = {…}
Defined in resources/mplot.js:1036
poptions9
let poptions9 = {…}
Defined in resources/mplot.js:1042