Commit c874d72b authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Change name of type State to GenomeBrowserState

parent 8664afa7
import { State, GeneData } from "../types"; import { GenomeBrowserState, GeneData } from "../types";
import { event } from "d3-selection"; import { event } from "d3-selection";
import { format as d3Format } from "d3-format"; import { format as d3Format } from "d3-format";
...@@ -12,7 +12,7 @@ const geneColor = scaleOrdinal( ...@@ -12,7 +12,7 @@ const geneColor = scaleOrdinal(
schemeSet1 schemeSet1
); );
export default function genomeBrowserData( export default function genomeBrowserData(
state: State, state: GenomeBrowserState,
brushHandler: any, brushHandler: any,
clickHandler: any clickHandler: any
) { ) {
......
import { GeneData, GenomeBrowserData, State } from "./types"; import { GeneData, GenomeBrowserData, GenomeBrowserState } from "./types";
import { select, event, BaseEvent, ClientPointEvent } from "d3-selection"; import { select, event } from "d3-selection";
import { scaleOrdinal } from "d3-scale";
import GenomeBrowser from "./component/genome-browser"; import GenomeBrowser from "./component/genome-browser";
import { color } from "d3";
import { format as d3Format } from "d3-format";
import { schemeSet1 } from "d3-scale-chromatic";
import genomeBrowserLayout from "./layout/genome-browser"; import genomeBrowserLayout from "./layout/genome-browser";
const width = 1500; const width = 1500;
const height = 300; const height = 300;
const genomeBrowserComponent = GenomeBrowser(); const genomeBrowserComponent = GenomeBrowser();
const geneColor = scaleOrdinal(
// schemeDark2
// schemeCategory10
schemeSet1
);
const geneData: GeneData[] = [ const geneData: GeneData[] = [
{ {
name: "gene 1", name: "gene 1",
...@@ -78,7 +68,7 @@ const geneData: GeneData[] = [ ...@@ -78,7 +68,7 @@ const geneData: GeneData[] = [
]; ];
const state: State = { const state: GenomeBrowserState = {
width: 1500, width: 1500,
chromosomeSize: 75000, chromosomeSize: 75000,
window: [20000, 26000], window: [20000, 26000],
...@@ -115,24 +105,25 @@ select("#zoom-out").on("click", function () { ...@@ -115,24 +105,25 @@ select("#zoom-out").on("click", function () {
FUNCTIONS FUNCTIONS
*/ */
function draw() { function draw() {
// // Get the data
const computedGenomeBrowserData: GenomeBrowserData = const computedGenomeBrowserData: GenomeBrowserData =
genomeBrowserLayout(state, brushHandler, clickHandler); genomeBrowserLayout(state, brushHandler, clickHandler);
// Convert the data to DOM objects
genomeBrowsers genomeBrowsers
.datum([computedGenomeBrowserData]) .datum([computedGenomeBrowserData])
.call(genomeBrowserComponent, width, height); .call(genomeBrowserComponent, width, height);
} }
function clickHandler([begin, end]: [number, number], state: State) { function clickHandler([begin, end]: [number, number], state: GenomeBrowserState) {
const centerGene = (end + begin) / 2; const centerGene = (end + begin) / 2;
const sizeWindow = state.window[1] - state.window[0]; const sizeWindow = state.window[1] - state.window[0];
state.window = [centerGene - sizeWindow / 2, centerGene + sizeWindow / 2]; state.window = [centerGene - sizeWindow / 2, centerGene + sizeWindow / 2];
draw(); draw();
} }
function brushHandler(scale: any, state: State) { function brushHandler(scale: any, state: GenomeBrowserState) {
if (!event.sourceEvent) return; if (!event.sourceEvent) return;
if (event.selection) { if (event.selection) {
const { selection: [x1, x2] } = event; const { selection: [x1, x2] } = event;
......
...@@ -35,7 +35,7 @@ export interface BrushableAxisData extends GenericAxisData { ...@@ -35,7 +35,7 @@ export interface BrushableAxisData extends GenericAxisData {
} }
} }
export interface State { export interface GenomeBrowserState {
width: number, width: number,
chromosomeSize: number, chromosomeSize: number,
window: [number, number], window: [number, number],
......
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