@netdata/charts
Version:
Netdata frontend SDK and chart utilities
38 lines (37 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _helpers = require("./helpers");
var textColorMap = {
warning: "#F9A825",
critical: "#FF4136",
clear: "#00AB44"
};
var _default = exports["default"] = function _default(chartUI, id) {
var overlays = chartUI.chart.getAttribute("overlays");
var _overlays$id = overlays[id],
when = _overlays$id.when,
status = _overlays$id.status;
var dygraph = chartUI.getDygraph();
var _dygraph$getArea = dygraph.getArea(),
h = _dygraph$getArea.h;
var ctx = dygraph.hidden_ctx_;
var area = (0, _helpers.getArea)(dygraph, [when, when]);
if (!area) return (0, _helpers.trigger)(chartUI, id);
var lineWidth = 2;
var from = area.from;
(0, _helpers.trigger)(chartUI, id, area);
ctx.save();
ctx.beginPath();
ctx.moveTo(from - lineWidth / 2, 0);
ctx.lineTo(from - lineWidth / 2, h);
ctx.globalAlpha = 1;
ctx.lineWidth = lineWidth;
ctx.setLineDash([4, 4]);
ctx.strokeStyle = textColorMap[status];
ctx.stroke();
ctx.closePath();
ctx.restore();
};