@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
38 lines (34 loc) • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.Volatility = void 0;
const vutils_1 = require("@visactor/vutils"), statistics_1 = require("../statistics"), type_1 = require("../../type"), types_1 = require("../../../../types"), utils_1 = require("../../utils"), volatilityAlgo = (context, optioins) => {
const {seriesDataMap: seriesDataMap, cell: cell, spec: spec} = context, {threshold: threshold = .8} = optioins || {}, {y: celly} = cell, yField = (0,
vutils_1.isArray)(celly) ? celly.flat() : [ celly ], result = [];
return Object.keys(seriesDataMap).forEach((series => {
const seriesDataset = seriesDataMap[series].map((d => d.dataItem));
yField.forEach((measureId => {
if ((0, utils_1.isPercenSeries)(spec, measureId)) return;
const measureSet = seriesDataset.map((d => Number(d[measureId]))), cv = (0, statistics_1.coefficientVariation)(measureSet);
Math.abs(cv) > threshold && result.push({
type: type_1.InsightType.Volatility,
fieldId: measureId,
value: cv,
significant: cv,
seriesName: series,
info: {
cv: cv
}
});
}));
})), result;
};
exports.Volatility = {
name: "volatility",
chartType: [ types_1.ChartType.LineChart, types_1.ChartType.DualAxisChart, types_1.ChartType.BarChart, types_1.ChartType.AreaChart ],
insightType: type_1.InsightType.Volatility,
algorithmFunction: volatilityAlgo,
supportStack: !0,
supportPercent: !1
};
//# sourceMappingURL=index.js.map