@jbrowse/plugin-linear-genome-view
Version:
JBrowse 2 linear genome view
36 lines (35 loc) • 1.7 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { getSession, getTickDisplayStr } from '@jbrowse/core/util';
import { Typography } from '@mui/material';
import { observer } from 'mobx-react';
import { makeStyles } from 'tss-react/mui';
import { HEADER_OVERVIEW_HEIGHT } from '../consts';
import { chooseGridPitch } from '../util';
const useStyles = makeStyles()({
scalebarLabel: {
height: HEADER_OVERVIEW_HEIGHT,
position: 'absolute',
display: 'flex',
justifyContent: 'center',
pointerEvents: 'none',
},
});
const OverviewScalebarTickLabels = observer(function ({ block, scale, overview, model, }) {
const { classes } = useStyles();
const { start, end, reversed, refName, assemblyName } = block;
const { majorPitch } = chooseGridPitch(scale, 120, 15);
const { assemblyManager } = getSession(model);
const assembly = assemblyManager.get(assemblyName);
const refNameColor = assembly === null || assembly === void 0 ? void 0 : assembly.getRefNameColor(refName);
const tickLabels = [];
for (let i = 0; i < Math.floor((end - start) / majorPitch); i++) {
const offsetLabel = (i + 1) * majorPitch;
tickLabels.push(reversed ? end - offsetLabel : start + offsetLabel);
}
return tickLabels.map((tickLabel, labelIdx) => (_jsx(Typography, { className: classes.scalebarLabel, variant: "body2", style: {
left: ((labelIdx + 1) * majorPitch) / scale,
pointerEvents: 'none',
color: refNameColor,
}, children: getTickDisplayStr(tickLabel, overview.bpPerPx) }, `${JSON.stringify(block)}-${tickLabel}-${labelIdx}`)));
});
export default OverviewScalebarTickLabels;