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. 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 in a dialog box, and returns the dialog's element.
| Parameter | Required | Default | Description |
|---|---|---|---|
group |
Group of the history panel | ||
panel |
Name of the history panel | ||
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 |
Only used by 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, separated by commas |
||
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:217
Methods
discardCurrentData
MhistoryGraph.prototype.discardCurrentData = function()
Defined in resources/mhistory.js:1682
download
MhistoryGraph.prototype.download = function(mode)
Defined in resources/mhistory.js:4273
draw
MhistoryGraph.prototype.draw = function()
Defined in resources/mhistory.js:2798
drawTAxis
MhistoryGraph.prototype.drawTAxis = function(ctx, x1, y1, width, xr, minor, major, text, label, grid, xmin, xmax)
Defined in resources/mhistory.js:4146
drawVAxis
MhistoryGraph.prototype.drawVAxis = function(ctx, x1, y1, height, minor, major, text, label, grid, ymin, ymax, logaxis, draw)
Defined in resources/mhistory.js:3864
findMinMax
MhistoryGraph.prototype.findMinMax = function()
Defined in resources/mhistory.js:2615
getMeasurementBox
MhistoryGraph.prototype.getMeasurementBox = function()
Translate the movable dialog's document position into plot coordinates for hit testing.
Defined in resources/mhistory.js:1769
initializePanel
MhistoryGraph.prototype.initializePanel = function(index, param)
Defined in resources/mhistory.js:583
jumpToCurrent
MhistoryGraph.prototype.jumpToCurrent = function()
Defined in resources/mhistory.js:2517
keyDown
MhistoryGraph.prototype.keyDown = function(e)
Defined in resources/mhistory.js:541
loadFullData
MhistoryGraph.prototype.loadFullData = function(t1, t2, scrollFlag)
Defined in resources/mhistory.js:1053
loadInitialData
MhistoryGraph.prototype.loadInitialData = function()
Defined in resources/mhistory.js:707
loadNewData
MhistoryGraph.prototype.loadNewData = function()
Defined in resources/mhistory.js:1601
loadSideData
MhistoryGraph.prototype.loadSideData = function()
Defined in resources/mhistory.js:1154
mouseEvent
MhistoryGraph.prototype.mouseEvent = function(e)
Defined in resources/mhistory.js:1926
mouseWheelEvent
MhistoryGraph.prototype.mouseWheelEvent = function(e)
Defined in resources/mhistory.js:2412
receiveData
MhistoryGraph.prototype.receiveData = function(rpc)
Defined in resources/mhistory.js:1293
receiveDataBinned
MhistoryGraph.prototype.receiveDataBinned = function(rpc)
Defined in resources/mhistory.js:1422
redraw
MhistoryGraph.prototype.redraw = function(force)
Defined in resources/mhistory.js:2550
resetAxes
MhistoryGraph.prototype.resetAxes = function()
Defined in resources/mhistory.js:2507
resize
MhistoryGraph.prototype.resize = function()
Defined in resources/mhistory.js:2537
scrollRedraw
MhistoryGraph.prototype.scrollRedraw = function()
Defined in resources/mhistory.js:1661
setTimespan
MhistoryGraph.prototype.setTimespan = function(tMin, tMax, scroll)
Defined in resources/mhistory.js:2531
timeToX
MhistoryGraph.prototype.timeToX = function(t)
Defined in resources/mhistory.js:2560
timeToXInit
MhistoryGraph.prototype.timeToXInit = function()
Defined in resources/mhistory.js:2556
truncateInfinity
MhistoryGraph.prototype.truncateInfinity = function(v)
Defined in resources/mhistory.js:2564
updateLastWritten
MhistoryGraph.prototype.updateLastWritten = function()
Defined in resources/mhistory.js:679
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:1780
updateURL
MhistoryGraph.prototype.updateURL = function()
Defined in resources/mhistory.js:2744
valueToY
MhistoryGraph.prototype.valueToY = function(v)
Defined in resources/mhistory.js:2581
valueToYInit
MhistoryGraph.prototype.valueToYInit = function()
Defined in resources/mhistory.js:2574
xToTime
MhistoryGraph.prototype.xToTime = function(x)
Defined in resources/mhistory.js:2597
yToValue
MhistoryGraph.prototype.yToValue = function(y)
Defined in resources/mhistory.js:2601
Functions
binarySearch
function binarySearch(array, target)
Defined in resources/mhistory.js:1713
convertLastWritten
function convertLastWritten(last)
Defined in resources/mhistory.js:2730
createPinstripeCanvas
function createPinstripeCanvas()
Defined in resources/mhistory.js:2754
doQueryAB
function doQueryAB(t)
Defined in resources/mhistory.js:514
getUrlVars
function getUrlVars()
Defined in resources/mhistory.js:209
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:180
mhistory_create_var
function mhistory_create_var(parentElement, baseURL, historyVar, tMin, tMax, index)
Defined in resources/mhistory.js:195
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:1731
timeToLabel
function timeToLabel(sec, base, forceDate)
Defined in resources/mhistory.js:4118
timeToSec
function timeToSec(str)
Defined in resources/mhistory.js:494
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:4069
options2
let options2 = {…}
Defined in resources/mhistory.js:4075
options3
let options3 = {…}
Defined in resources/mhistory.js:4081
options4
let options4 = {…}
Defined in resources/mhistory.js:4087
options5
let options5 = {…}
Defined in resources/mhistory.js:4092
options6
let options6 = {…}
Defined in resources/mhistory.js:4097
options7
let options7 = {…}
Defined in resources/mhistory.js:4102
options8
let options8 = {…}
Defined in resources/mhistory.js:4107
options9
let options9 = {…}
Defined in resources/mhistory.js:4113