UNPKG

perfrunner-reporters

Version:

Home of the perfrunner reporters

45 lines (44 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MarksChartReporter = void 0; const abstract_chart_1 = require("./abstract.chart"); const utils_1 = require("../../../utils"); class MarksChartReporter extends abstract_chart_1.AbstractChart { constructor() { super(...arguments); this.name = 'marks'; this.type = 'chart'; this.title = 'Performance Marks'; this.yAxesLabelCalback = abstract_chart_1.msLabel; this.getViewData = (rawData) => { if (!Array.isArray(rawData)) { throw new Error('data is not in array format'); } const length = rawData.length; const result = { labels: (0, utils_1.initWithEmptyString)(length), runParams: this.runParams(rawData), data: {}, timeStamp: (0, utils_1.init0)(length), }; return rawData.reduce((acc, v, i) => { const marks = v.performanceEntries.filter((x) => x.entryType === 'mark'); marks.forEach((m) => { const name = m.name; const startTime = m.startTime; if (acc.data[name] == null) { acc.data[name] = (0, utils_1.init0)(length); } acc.data[name][i] = startTime; }); acc.labels[i] = this.getLabel(i, rawData[i].comment); acc.timeStamp[i] = rawData[i].timeStamp; return acc; }, result); }; this.getDatasetEntries = (viewData) => { return Object.entries(viewData).map(([key, entries], i) => this.withDefaults(key, entries, (0, utils_1.color)(i))); }; } } exports.MarksChartReporter = MarksChartReporter;