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

36 lines (30 loc) 1.13 kB
import { registerVennChart } from "@visactor/vchart"; import { color, discreteLegend } from "./common"; export const vennData = context => { const {dataTable: dataTable, spec: spec, cell: cell} = context, id2dataMap = {}, setsField = cell.color[0], nameField = cell.color[1]; return dataTable.forEach((data => { id2dataMap[data[setsField]] ? id2dataMap[data[setsField]].sets.push(data[nameField]) : id2dataMap[data[setsField]] = { sets: [ data[nameField] ], value: data[cell.size] }; })), spec.data = { values: Object.values(id2dataMap) }, { spec: spec }; }; export const vennField = context => { const {spec: spec} = context; return spec.valueField = "value", spec.categoryField = "sets", spec.seriesField = "sets", { spec: spec }; }; export const registerChart = context => { const {spec: spec} = context; return "venn" === spec.type && registerVennChart(), { spec: spec }; }; export const pipelineVenn = [ registerChart, vennData, color, vennField, discreteLegend ]; //# sourceMappingURL=venn.js.map