UNPKG

@visactor/vmind

Version:

<div align="center"> <a href="https://github.com/VisActor#gh-light-mode-only" target="_blank"> <img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/logo_500_200_light.svg"/> </a> <a href="https://githu

35 lines (29 loc) 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.pipelineBoxPlot = exports.boxPlotStyle = exports.boxPlotField = void 0; const vutils_1 = require("@visactor/vutils"), dataTable_1 = require("../../../../utils/dataTable"), common_1 = require("./common"), boxPlotField = context => { const {cell: cell, dataTable: dataTable, spec: spec} = context, {x: x, y: y} = cell, data = (0, dataTable_1.isValidDataTable)(dataTable) ? dataTable : []; spec.xField = x, (0, vutils_1.array)(y).sort(((a, b) => { var _a, _b, _c, _d; return null !== (_d = null !== (_b = null === (_a = data[0]) || void 0 === _a ? void 0 : _a[a]) && void 0 !== _b ? _b : 0 - (null === (_c = data[0]) || void 0 === _c ? void 0 : _c[b])) && void 0 !== _d ? _d : 0; })); const yFieldsLen = y.length; return spec.minField = y[0], spec.q1Field = y[Math.min(1, yFieldsLen - 1)], spec.medianField = y[Math.floor((yFieldsLen - 1) / 2)], spec.q3Field = y[Math.max(0, yFieldsLen - 2)], spec.maxField = y[yFieldsLen - 1], { spec: spec }; }; exports.boxPlotField = boxPlotField; const boxPlotStyle = context => { const {spec: spec} = context; return spec.boxPlot = Object.assign(Object.assign({}, spec.boxPlot), { style: {} }), { spec: spec }; }; exports.boxPlotStyle = boxPlotStyle, exports.pipelineBoxPlot = [ common_1.data, common_1.color, exports.boxPlotField, exports.boxPlotStyle, common_1.discreteLegend ]; //# sourceMappingURL=boxplot.js.map