Commit 5704fa52 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Use variable classes.perDataRootContainer to set the class name

parent 5f7e628c
...@@ -10,6 +10,7 @@ import { GenomeBrowserData, BrushableAxisData, SelectedChromosomeData } from ".. ...@@ -10,6 +10,7 @@ import { GenomeBrowserData, BrushableAxisData, SelectedChromosomeData } from "..
export default function () { export default function () {
const classes = { const classes = {
perDataRootContainer: "genome-browser",
chromosomeRuler: "chromosome-ruler", chromosomeRuler: "chromosome-ruler",
selectedChromosome: "selected-chromosomes" selectedChromosome: "selected-chromosomes"
}; };
...@@ -19,22 +20,21 @@ export default function () { ...@@ -19,22 +20,21 @@ export default function () {
let width = 900; let width = 900;
let genomesBrowserU: Selection<SVGGElement, GenomeBrowserData, SVGElement, any> | null = null; let genomesBrowserU: Selection<SVGGElement, GenomeBrowserData, SVGElement, any> | null = null;
function genomeBrowser( function genomeBrowser(
_selection: Selection<SVGGElement, Array<GenomeBrowserData>, HTMLElement, any> _selection: Selection<SVGGElement, Array<GenomeBrowserData>, HTMLElement, any>
) { ) {
// width = w;
_selection.each(function (_data: Array<GenomeBrowserData>) { _selection.each(function (_data: Array<GenomeBrowserData>) {
const container = select(this); const container = select(this);
const genomeBrowser = container const genomeBrowser = container
.selectAll<SVGGElement, GenomeBrowserData>(".genome-browser") .selectAll<SVGGElement, GenomeBrowserData>("." + classes.perDataRootContainer)
.data(_data); .data(_data);
//ENTER //ENTER
const genomeBrowserE = genomeBrowser const genomeBrowserE = genomeBrowser
.enter() .enter()
.append<SVGGElement>("g") .append<SVGGElement>("g")
.classed("genome-browser", true); .classed(classes.perDataRootContainer, true);
genomeBrowserE.append("g").classed(classes.chromosomeRuler, true); genomeBrowserE.append("g").classed(classes.chromosomeRuler, true);
genomeBrowserE.append("g") genomeBrowserE.append("g")
...@@ -47,24 +47,19 @@ export default function () { ...@@ -47,24 +47,19 @@ export default function () {
//UPDATE //UPDATE
genomesBrowserU = genomeBrowser.merge(genomeBrowserE); genomesBrowserU = genomeBrowser.merge(genomeBrowserE);
genomesBrowserU.each(function (data) { genomesBrowserU.each(function (data) {
const { const { chromosome: { ruler: chromosomeRule }, selectedChromosome } = data;
chromosome: { ruler: chromosomeRule },
selectedChromosome: { genes: selectedGenes, ruler: selectedChromosomeRule },
// axis: { chromosome, global }
} = data;
updateWholeChromosomeAxis(chromosomeRule); updateWholeChromosomeAxis(chromosomeRule);
updateSelectedChromosome(data); updateSelectedChromosome(selectedChromosome);
}); });
}); });
} }
function updateSelectedChromosome(data: GenomeBrowserData) { function updateSelectedChromosome(data: SelectedChromosomeData) {
if (genomesBrowserU !== null) { if (genomesBrowserU !== null) {
genomesBrowserU genomesBrowserU
.select<SVGGElement>("." + classes.selectedChromosome) .select<SVGGElement>("." + classes.selectedChromosome)
.datum<SelectedChromosomeData[]>([data.selectedChromosome]) .datum<SelectedChromosomeData[]>([data])
.call(selectedChromosomeComponent, width); .call(selectedChromosomeComponent, width);
} }
} }
...@@ -78,6 +73,7 @@ export default function () { ...@@ -78,6 +73,7 @@ export default function () {
} }
} }
genomeBrowser.updateSelectedChromosome = updateSelectedChromosome; genomeBrowser.updateSelectedChromosome = updateSelectedChromosome;
genomeBrowser.updateWholeChromosomeAxis = updateWholeChromosomeAxis;
return genomeBrowser; return genomeBrowser;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment