UNPKG

@formant/ava

Version:

A framework for automated visual analytics.

44 lines (43 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dataCheck = void 0; var utils_1 = require("../utils"); var utils_2 = require("../../utils"); exports.dataCheck = { id: 'data-check', type: 'HARD', docs: { lintText: 'Data must satisfy the data prerequisites.', }, trigger: function () { return true; }, validator: function (args) { var result = 0; var dataProps = args.dataProps, chartType = args.chartType, chartWIKI = args.chartWIKI; if (dataProps && chartType && chartWIKI[chartType]) { result = 1; var dataPres_1 = chartWIKI[chartType].dataPres || []; dataPres_1.forEach(function (dataPre) { if (!(0, utils_1.verifyDataProps)(dataPre, dataProps)) { result = 0; } }); var fieldsLOMs = dataProps.map(function (info) { return info.levelOfMeasurements; }); fieldsLOMs.forEach(function (fieldLOM) { var flag = false; dataPres_1.forEach(function (dataPre) { if (fieldLOM && (0, utils_2.intersects)(fieldLOM, dataPre.fieldConditions)) { flag = true; } }); if (!flag) { result = 0; } }); } return result; }, };