UNPKG

@jbrowse/plugin-wiggle

Version:

JBrowse 2 wiggle adapters, tracks, etc.

29 lines (28 loc) 2.01 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from 'react'; import { observer } from 'mobx-react'; import Tooltip from '../../Tooltip'; import { toP } from '../../util'; const en = (n) => n.toLocaleString('en-US'); const TooltipContents = forwardRef(function TooltipContents2({ model, feature }, ref) { const start = feature.get('start'); const end = feature.get('end'); const refName = feature.get('refName'); const coord = start === end ? en(start) : `${en(start)}..${en(end)}`; const sources = feature.get('sources'); const source = feature.get('source'); const summary = feature.get('summary'); const obj = Object.fromEntries(model.sources.map(ent => [ent.name, ent])); return (_jsxs("div", { ref: ref, children: [[refName, coord].filter(f => !!f).join(':'), _jsx("br", {}), sources ? (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "color" }), _jsx("th", { children: "source" }), _jsx("th", { children: "score" })] }) }), _jsx("tbody", { children: Object.entries(sources).map(([source, data]) => (_jsxs("tr", { children: [_jsx("td", { children: _jsx("div", { style: { width: 16, height: 16, background: obj[source].color, } }) }), _jsx("td", { children: source }), _jsx("td", { children: toP(data.score) })] }, source))) })] })) : (_jsxs("span", { children: [source, ' ', summary ? `min:${toP(feature.get('minScore'))} avg:${toP(feature.get('score'))} max:${toP(feature.get('maxScore'))}` : toP(feature.get('score'))] }))] })); }); const WiggleTooltip = observer((props) => { return _jsx(Tooltip, { useClientY: true, TooltipContents: TooltipContents, ...props }); }); export default WiggleTooltip; export { default as Tooltip } from '../../Tooltip';