UNPKG

@jbrowse/plugin-wiggle

Version:

JBrowse 2 wiggle adapters, tracks, etc.

43 lines (42 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = SetColorDialogRowPalettizer; const jsx_runtime_1 = require("react/jsx-runtime"); const colors_1 = require("@jbrowse/core/ui/colors"); const color_1 = require("@jbrowse/core/util/color"); const material_1 = require("@mui/material"); function SetColorDialogRowPalettizer({ setCurrLayout, currLayout, }) { if (!currLayout.length || !currLayout[0]) { return null; } const fields = Object.keys(currLayout[0]).filter(f => f !== 'name' && f !== 'color' && f !== 'source' && f !== 'label' && f !== 'id' && f !== 'HP'); return ((0, jsx_runtime_1.jsxs)("div", { children: ["Create color palette based on...", fields.map(r => ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "inherit", onClick: () => { const map = new Map(); for (const row of currLayout) { const val = map.get(row[r]); if (!val) { map.set(row[r], 1); } else { map.set(row[r], val + 1); } } const ret = Object.fromEntries([...map.entries()] .sort((a, b) => a[1] - b[1]) .map((r, idx) => [r[0], colors_1.set1[idx] || (0, color_1.randomColor)(r[0])])); setCurrLayout(currLayout.map(row => ({ ...row, color: ret[row[r]], }))); }, children: r }, r))), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => { setCurrLayout(currLayout.map(row => ({ ...row, color: undefined, }))); }, children: "Clear colors" })] })); }