pddl-gantt
Version:
Plan visualization for AI-Planning plans. The package includes HTML components for Gantt, swimlane and line plot visualization of plan originating from AI Planning solvers.
59 lines • 2 kB
JavaScript
;
/* --------------------------------------------------------------------------------------------
* Copyright (c) Jan Dolejsi 2020. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.drawChart = exports.isInViewport = void 0;
/**
* Tests whether _any_ portion of the el is visible.
* @param el HTML element
*/
function isInViewport(el) {
if (["hidden", "collapse"].includes(el.style.visibility)) {
return false;
}
const rect = el.getBoundingClientRect();
return rect.bottom >= 0 &&
rect.right >= 0 &&
rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.left <= (window.innerWidth || document.documentElement.clientWidth);
}
exports.isInViewport = isInViewport;
let chartDefined = false;
try {
google.charts.load('current', { packages: ['corechart', 'line'] });
chartDefined = true;
}
catch (err) {
const error = err;
console.warn((_a = error.message) !== null && _a !== void 0 ? _a : error);
}
function drawChart(chartDiv, functionName, unit, objects, columnData) {
if (!chartDefined) {
return;
}
const data = new google.visualization.DataTable();
data.addColumn('number', 'X');
objects.forEach(obj => {
data.addColumn('number', obj);
});
data.addRows(columnData);
const options = {
hAxis: {
title: 'Time',
minValue: 0
},
vAxis: {
title: unit,
scaleType: 'linear' //vAxisScaleType = 'log'
},
interpolateNulls: false,
title: functionName
};
const chart = new google.visualization.LineChart(chartDiv);
chart.draw(data, options);
}
exports.drawChart = drawChart;
//# sourceMappingURL=charts.js.map