@jbrowse/plugin-wiggle
Version:
JBrowse 2 wiggle adapters, tracks, etc.
24 lines (23 loc) • 1.1 kB
JavaScript
import { renderToAbstractCanvas, updateStatus } from '@jbrowse/core/util';
import { rpcResult } from '@jbrowse/core/util/librpc';
import { collectTransferables } from '@jbrowse/core/util/offscreenCanvasPonyfill';
import { drawLine } from "../drawLine.js";
import { getColorCallback, serializeWiggleFeature } from "../util.js";
export async function renderLinePlot(renderProps, features) {
const { config, height, regions, bpPerPx, statusCallback = () => { }, } = renderProps;
const region = regions[0];
const width = (region.end - region.start) / bpPerPx;
const colorCallback = getColorCallback(config, { defaultColor: 'grey' });
const { reducedFeatures, ...rest } = await updateStatus('Rendering plot', statusCallback, () => renderToAbstractCanvas(width, height, renderProps, ctx => drawLine(ctx, {
...renderProps,
features,
colorCallback,
})));
const serialized = {
...rest,
features: reducedFeatures.map(serializeWiggleFeature),
height,
width,
};
return rpcResult(serialized, collectTransferables(rest));
}