@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
32 lines (26 loc) • 1.28 kB
JavaScript
import { array } from "@visactor/vutils";
import { isValidDataTable } from "../../../../utils/dataTable";
import { color, data, discreteLegend } from "./common";
export const boxPlotField = context => {
const {cell: cell, dataTable: dataTable, spec: spec} = context, {x: x, y: y} = cell, data = isValidDataTable(dataTable) ? dataTable : [];
spec.xField = x, 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
};
};
export const boxPlotStyle = context => {
const {spec: spec} = context;
return spec.boxPlot = Object.assign(Object.assign({}, spec.boxPlot), {
style: {}
}), {
spec: spec
};
};
export const pipelineBoxPlot = [ data, color, boxPlotField, boxPlotStyle, discreteLegend ];
//# sourceMappingURL=boxplot.js.map