Commit 6e1ae1a0 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Set the gene color in the data

parent 1165597e
...@@ -2,6 +2,7 @@ import { GeneData } from "./component/sequence/gene"; ...@@ -2,6 +2,7 @@ import { GeneData } from "./component/sequence/gene";
import { select, event } from "d3-selection"; import { select, event } from "d3-selection";
import { scaleLinear } from "d3-scale"; import { scaleLinear } from "d3-scale";
import GenomeBrowser, { GenomeBrowserData } from "./component/genome-browser"; import GenomeBrowser, { GenomeBrowserData } from "./component/genome-browser";
import { color } from "d3";
const width = 1500; const width = 1500;
const height = 300; const height = 300;
...@@ -18,7 +19,7 @@ const geneData: GeneData[] = [ ...@@ -18,7 +19,7 @@ const geneData: GeneData[] = [
name: "gene 2", name: "gene 2",
strand: "+", strand: "+",
begin: 21181, begin: 21181,
end: 21399, end: 21465,
gene: "yaaY", gene: "yaaY",
}, },
{ {
...@@ -34,7 +35,29 @@ const geneData: GeneData[] = [ ...@@ -34,7 +35,29 @@ const geneData: GeneData[] = [
begin: 22391, begin: 22391,
end: 25207, end: 25207,
gene: "ileS" gene: "ileS"
} },
{
name: "gene 4",
strand: "-",
begin: 25304,
end: 25956,
gene: "foo"
},
{
name: "gene 4",
strand: "+",
begin: 26004,
end: 26329,
gene: "foo"
},
{
name: "gene 4",
strand: "+",
begin: 29004,
end: 29429,
gene: "foo"
},
]; ];
const genomeBrowserData: GenomeBrowserData[] = [{ const genomeBrowserData: GenomeBrowserData[] = [{
...@@ -108,10 +131,16 @@ function draw() { ...@@ -108,10 +131,16 @@ function draw() {
const newGenomeBrowser = { const newGenomeBrowser = {
...genomesBrowser, ...genomesBrowser,
genes: visibleGenes.map(function (gene) { genes: visibleGenes.map(function (gene) {
gene.eventHandler = { const fill = gene.strand === "+" ? color("darkred") : color("darkblue");
click: clickHandler const stroke = (fill) ? fill.darker(1).toString() : "lighgray"
}; return {
return gene; ...gene,
eventHandler: {
click: clickHandler
},
fill: (fill) ? fill.toString() : "lightgray",
stroke
}
}), }),
scale: xScale, scale: xScale,
eventHandler: { eventHandler: {
......
Supports Markdown
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