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

66 lines (61 loc) 2.14 kB
import { color, sunburstOrTreemapField } from "./common"; export const sunburstData = context => { const {dataTable: dataTable, cell: cell, spec: spec} = context; return spec.data = { id: "data", values: getSunburstData(dataTable, cell.color, 0, cell.size) }, { spec: spec }; }; export const getSunburstData = (dataTable, colorField, index, sizeField) => { if (colorField.length - 1 === index) return Array.from(new Set(dataTable.map((data => ({ name: data[colorField[index]], value: data[sizeField] }))))); return Array.from(new Set(dataTable.map((data => data[colorField[index]])))).map((value => { const currentDataset = dataTable.filter((data => data[colorField[index]] === value)); return { name: value, children: getSunburstData(currentDataset, colorField, index + 1, sizeField) }; })); }; export const sunburstDisplayConf = context => { const {spec: spec} = context; return spec.offsetX = 0, spec.offsetY = 0, spec.outerRadius = 1, spec.innerRadius = 0, spec.gap = 5, spec.drill = !0, spec.sunburst = { visible: !0, style: { fillOpacity: datum => datum.isLeaf ? .4 : .8 } }, spec.label = { visible: !0, style: { fontSize: 12, fillOpacity: datum => datum.isLeaf ? .4 : .8 } }, spec.tooltip = { mark: { title: { value: val => { var _a; return null === (_a = null == val ? void 0 : val.datum) || void 0 === _a ? void 0 : _a.map((data => data.name)).join(" / "); } } } }, spec.animationEnter = { easing: "cubicInOut", duration: 1e3 }, spec.animationExit = { easing: "cubicInOut", duration: 1e3 }, spec.animationUpdate = { easing: "cubicInOut", duration: 1e3 }, { spec: spec }; }; export const pipelineSunburst = [ sunburstData, color, sunburstOrTreemapField, sunburstDisplayConf ]; //# sourceMappingURL=sunburst.js.map