@jbrowse/plugin-wiggle
Version:
JBrowse 2 wiggle adapters, tracks, etc.
29 lines (28 loc) • 1.19 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useMemo } from 'react';
import { measureText } from '@jbrowse/core/util';
import { observer } from 'mobx-react';
import MultiWiggleColorLegend from "./MultiWiggleColorLegend.js";
import MultiWiggleLegendBarWrapper from "./MultiWiggleLegendBarWrapper.js";
const MultiWiggleLegendBar = observer(function MultiWiggleLegendBar(props) {
const { model } = props;
const { canDisplayLegendLabels, rowHeight, sources } = model;
const svgFontSize = Math.min(rowHeight, 12);
const labelWidth = useMemo(() => {
if (!sources) {
return 0;
}
let maxWidth = 0;
for (const s of sources) {
const width = canDisplayLegendLabels
? measureText(s.name, svgFontSize) + 10
: 20;
if (width > maxWidth) {
maxWidth = width;
}
}
return maxWidth;
}, [sources, svgFontSize, canDisplayLegendLabels]);
return sources ? (_jsx(MultiWiggleLegendBarWrapper, { ...props, children: _jsx(MultiWiggleColorLegend, { model: model, labelWidth: labelWidth }) })) : null;
});
export default MultiWiggleLegendBar;