@netdata/charts
Version:
Netdata frontend SDK and chart utilities
41 lines (39 loc) • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _heatmap = require("../../../helpers/heatmap");
var _default = exports["default"] = function _default(chartUI) {
return function (plotter) {
if (!chartUI) return;
// We need to handle all the series simultaneously.
if (plotter.seriesIndex !== 0) return;
var g = plotter.dygraph;
var ctx = plotter.drawingContext;
var sets = plotter.allSeriesPoints;
var series = g.layout_.setNames;
var minWidthSep = Infinity;
sets.forEach(function (points) {
var widthSep = points[1].canvasx - points[0].canvasx;
if (widthSep < minWidthSep) minWidthSep = widthSep;
});
var barWidth = Math.floor(minWidthSep);
var getColor = (0, _heatmap.makeGetColor)(chartUI.chart);
series.forEach(function (seriesName, j) {
var index = chartUI.chart.getHeatmapYIndex(seriesName);
if (index === -1) return;
var height = Math.abs(index === 0 ? g.toDomYCoord(index + 1) - g.toDomYCoord(index) : g.toDomYCoord(index) - g.toDomYCoord(index - 1));
sets[j].forEach(function (p, i) {
var rowIndex = Number.isInteger(p.idx) ? p.idx : i;
var value = chartUI.chart.getDimensionValue(seriesName, rowIndex, {
allowNull: true
});
ctx.fillStyle = getColor(value);
ctx.fillRect(p.canvasx - barWidth / 2, g.toDomYCoord(index) - height / 2, barWidth, height);
ctx.strokeStyle = "transparent";
ctx.strokeRect(p.canvasx - barWidth / 2, g.toDomYCoord(index) - height / 2, barWidth, height);
});
});
};
};