Skip to content

mhistory.js

This page contains the full API reference for mhistory.js, which shows history plots on custom pages.

For how to add history plots to a custom page, with examples, see Custom pages: history plots. For the history system itself, see History: overview.

mhistory.js needs midas.js, controls.js and mhttpd.js to be included before it (see mhttpd.js).

mjshistory

An element with the class mjshistory shows a history plot, once mhistory_init() has been called. It shows either a history panel, or one or more variables without a panel.

Attribute Required Default Description
data-group For a panel Group of the history panel, as in /History/Display/<group>/<panel>
data-panel For a panel Name of the history panel
data-history-var For variables Variables to plot instead of a panel, as event:tag, separated by commas. If a name contains a comma, give a JSON array instead, e.g. '["A:x, y", "A:z"]'. The plot uses the default settings
data-scale The panel's Timescale Time span shown, e.g. 10m, 5h or 3d
data-show-title true false or 0 hides the title
data-show-values The panel's Show values true/1 or false/0: whether to show the variables' names and values
data-show-fill The panel's Show fill true/1 or false/0: whether to fill the area under each line
data-show-axis true false or 0 hides the axes
data-show-menu-buttons true false or 0 hides the menu buttons
data-show-zoom-buttons true false or 0 hides the zoom buttons
CSS width, height Size of the plot. Set both, so that the plot has a sensible height

mhistory_init()

mhistory_init(mhist, noBorder, param) creates the plots. Call it once, after the page has loaded.

Parameter Required Default Description
mhist All elements with the class mjshistory An element, or array of elements, to show plots in
noBorder false true draws the plot without a border
param Settings for plots of variables (data-history-var), as for mhistory_dialog_var()

mhistory_dialog()

mhistory_dialog(group, panel, width, height, x, y, param) opens a history panel, or a plot of history variables, in a dialog box. It returns the dialog's element.

Parameter Required Default Description
group ✔ Group of the history panel. For variables, the dialog's title is History <group>
panel ✔ Name of the history panel, or the variables to plot as event:tag. Separate several variables with commas, or pass an array. Use an array if a variable name contains a comma
width, height 400, 300 Size of the dialog, in pixels
x, y The normal dialog position Position of the dialog, in pixels. Only used if both are given
param Settings for a plot of variables, as for mhistory_dialog_var()

mhistory_dialog_var()

mhistory_dialog_var(historyVar, param) plots history variables in a dialog box, without a history panel.

Parameter Required Default Description
historyVar ✔ Variables to plot, as event:tag. Separate several variables with commas, or pass an array. Use an array if a variable name contains a comma
param An object with the settings below

The settings have the same names as the ODB keys of a history panel:

Setting Default Description
width, height 400, 300 Size of the dialog, in pixels
x, y The normal dialog position Position of the dialog, in pixels. Only used if both are given
Timescale "1h" Time span shown, e.g. "10m", "1h", "24h" or "3d"
Minimum, Maximum 0, 0 Limits of the Y axis. If they're equal, the limits are chosen automatically
Zero ylow false Always include zero at the bottom of the Y axis
Log axis false Logarithmic Y axis
Show run markers false Show when runs started and stopped
Show values true Show the current values next to the variable names
Show fill true Fill the area under each line
Show raw value false Also show the value before Formula was applied
Formula "" Expression applied to the values, using x
Label The variable names Labels of the variables (an array)
Colour The standard colors Colors of the variables (an array of CSS colors)

Functions and variables

Classes

MhistoryGraph

function MhistoryGraph(divElement, noBorder, floating)

Defined in resources/mhistory.js:232

Methods
discardCurrentData
MhistoryGraph.prototype.discardCurrentData = function()

Defined in resources/mhistory.js:1709

download
MhistoryGraph.prototype.download = function(mode)

Defined in resources/mhistory.js:4308

draw
MhistoryGraph.prototype.draw = function()

Defined in resources/mhistory.js:2804

drawTAxis
MhistoryGraph.prototype.drawTAxis = function(ctx, x1, y1, width, xr, minor, major, text, label, grid, xmin, xmax)

Defined in resources/mhistory.js:4181

drawVAxis
MhistoryGraph.prototype.drawVAxis = function(ctx, x1, y1, height, minor, major, text, label, grid, ymin, ymax, logaxis, draw)

Defined in resources/mhistory.js:3899

findMinMax
MhistoryGraph.prototype.findMinMax = function()

Defined in resources/mhistory.js:2621

getMeasurementBox
MhistoryGraph.prototype.getMeasurementBox = function()

Translate the movable dialog's document position into plot coordinates for hit testing.

Defined in resources/mhistory.js:1796

initializePanel
MhistoryGraph.prototype.initializePanel = function(index, param)

Defined in resources/mhistory.js:601

jumpToCurrent
MhistoryGraph.prototype.jumpToCurrent = function()

Defined in resources/mhistory.js:2523

keyDown
MhistoryGraph.prototype.keyDown = function(e)

Defined in resources/mhistory.js:559

loadFullData
MhistoryGraph.prototype.loadFullData = function(t1, t2, scrollFlag)

Defined in resources/mhistory.js:1080

loadInitialData
MhistoryGraph.prototype.loadInitialData = function()

Defined in resources/mhistory.js:734

loadNewData
MhistoryGraph.prototype.loadNewData = function()

Defined in resources/mhistory.js:1628

loadSideData
MhistoryGraph.prototype.loadSideData = function()

Defined in resources/mhistory.js:1181

mouseEvent
MhistoryGraph.prototype.mouseEvent = function(e)

Defined in resources/mhistory.js:1953

mouseWheelEvent
MhistoryGraph.prototype.mouseWheelEvent = function(e)

Defined in resources/mhistory.js:2418

receiveData
MhistoryGraph.prototype.receiveData = function(rpc)

Defined in resources/mhistory.js:1320

receiveDataBinned
MhistoryGraph.prototype.receiveDataBinned = function(rpc)

Defined in resources/mhistory.js:1449

redraw
MhistoryGraph.prototype.redraw = function(force)

Defined in resources/mhistory.js:2556

resetAxes
MhistoryGraph.prototype.resetAxes = function()

Defined in resources/mhistory.js:2513

resize
MhistoryGraph.prototype.resize = function()

Defined in resources/mhistory.js:2543

scrollRedraw
MhistoryGraph.prototype.scrollRedraw = function()

Defined in resources/mhistory.js:1688

setTimespan
MhistoryGraph.prototype.setTimespan = function(tMin, tMax, scroll)

Defined in resources/mhistory.js:2537

timeToX
MhistoryGraph.prototype.timeToX = function(t)

Defined in resources/mhistory.js:2566

timeToXInit
MhistoryGraph.prototype.timeToXInit = function()

Defined in resources/mhistory.js:2562

truncateInfinity
MhistoryGraph.prototype.truncateInfinity = function(v)

Defined in resources/mhistory.js:2570

updateLastWritten
MhistoryGraph.prototype.updateLastWritten = function()

Defined in resources/mhistory.js:706

updateMarker
MhistoryGraph.prototype.updateMarker = function(eventX, eventY)

Locate a nearby sample, or use the cursor coordinates when snapping is disabled.

Defined in resources/mhistory.js:1807

updateURL
MhistoryGraph.prototype.updateURL = function()

Defined in resources/mhistory.js:2750

valueToY
MhistoryGraph.prototype.valueToY = function(v)

Defined in resources/mhistory.js:2587

valueToYInit
MhistoryGraph.prototype.valueToYInit = function()

Defined in resources/mhistory.js:2580

xToTime
MhistoryGraph.prototype.xToTime = function(x)

Defined in resources/mhistory.js:2603

yToValue
MhistoryGraph.prototype.yToValue = function(y)

Defined in resources/mhistory.js:2607

Functions

binarySearch

function binarySearch(array, target)

Defined in resources/mhistory.js:1740

convertLastWritten

function convertLastWritten(last)

Defined in resources/mhistory.js:2736

createPinstripeCanvas

function createPinstripeCanvas()

Defined in resources/mhistory.js:2760

doQueryAB

function doQueryAB(t)

Defined in resources/mhistory.js:532

getUrlVars

function getUrlVars()

Defined in resources/mhistory.js:224

log_hs_read

function log_hs_read(str, a, b)

Defined in resources/mhistory.js:14

mhistory_create

function mhistory_create(parentElement, baseURL, group, panel, tMin, tMax, index)

Defined in resources/mhistory.js:194

mhistory_create_var

function mhistory_create_var(parentElement, baseURL, historyVar, tMin, tMax, index)

Defined in resources/mhistory.js:209

mhistory_dialog

function mhistory_dialog(group, panel, width, height, x, y, param)

Defined in resources/mhistory.js:78

mhistory_dialog_var

function mhistory_dialog_var(historyVar, param)

Defined in resources/mhistory.js:70

mhistory_init

function mhistory_init(mhist, noBorder, param)

Defined in resources/mhistory.js:43

profile

function profile(flag)

Defined in resources/mhistory.js:31

splitEventAndTagName

function splitEventAndTagName(var_name)

Defined in resources/mhistory.js:1758

timeToLabel

function timeToLabel(sec, base, forceDate)

Defined in resources/mhistory.js:4153

timeToSec

function timeToSec(str)

Defined in resources/mhistory.js:512

Variables

LN10

LN10 = 2.302585094

Defined in resources/mhistory.js:10

LOG2

LOG2 = 0.301029996

Defined in resources/mhistory.js:11

LOG5

LOG5 = 0.698970005

Defined in resources/mhistory.js:12

options1

let options1 = {…}

Defined in resources/mhistory.js:4104

options2

let options2 = {…}

Defined in resources/mhistory.js:4110

options3

let options3 = {…}

Defined in resources/mhistory.js:4116

options4

let options4 = {…}

Defined in resources/mhistory.js:4122

options5

let options5 = {…}

Defined in resources/mhistory.js:4127

options6

let options6 = {…}

Defined in resources/mhistory.js:4132

options7

let options7 = {…}

Defined in resources/mhistory.js:4137

options8

let options8 = {…}

Defined in resources/mhistory.js:4142

options9

let options9 = {…}

Defined in resources/mhistory.js:4148