Commit 819ff3ad authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Change data type from [number, number] to GenericAxisData

parent 6f6459c9
...@@ -2,32 +2,33 @@ import { axisTop } from "d3-axis"; ...@@ -2,32 +2,33 @@ import { axisTop } from "d3-axis";
import { Selection, select } from "d3-selection"; import { Selection, select } from "d3-selection";
import { scaleLinear, ScaleLinear } from "d3-scale"; import { scaleLinear, ScaleLinear } from "d3-scale";
import { format } from "d3-format"; import { format } from "d3-format";
import { GenericAxisData } from "../../types";
export default function () { export default function () {
let xScale = scaleLinear() let xScale = scaleLinear()
.domain([0, 0]) .domain([0, 0])
.range([0,0]) .range([0, 0])
function genomeAxis( function genomeAxis(
_selection: Selection<SVGElement, [number, number], SVGElement, any>, _selection: Selection<SVGElement, GenericAxisData, SVGElement, any>,
width: number, width: number,
yPosition: number = 0 yPosition: number = 0
) { ) {
_selection.each(function (_data: [number, number]) { _selection.each(function (_data) {
const container = select(this) const container = select(this)
.attr("transform", "translate(0," + yPosition + ")"); .attr("transform", "translate(0," + yPosition + ")");
const title = "Genome XXX (bp)";
xScale = scaleLinear() xScale = scaleLinear()
.domain([_data[0], _data[1]]) .domain(_data.interval)
.range([0, width]) .range([0, width])
const genomeAxisComponent = axisTop(xScale) const genomeAxisComponent = axisTop(xScale)
.tickFormat(format(".3s")); .tickFormat(format(".3s"));
const genomeAxisSelection = container const genomeAxisSelection = container
.selectAll<SVGElement, [number, number]>("g.genome-axis") .selectAll<SVGElement, GenericAxisData>("g.genome-axis")
.data([_data]); .data([_data]);
// ENTER // ENTER
...@@ -57,8 +58,8 @@ export default function () { ...@@ -57,8 +58,8 @@ export default function () {
.select<SVGTextElement>(".title > text") .select<SVGTextElement>(".title > text")
.style("fill", "black") .style("fill", "black")
.style("font-family", "monospace") .style("font-family", "monospace")
.attr("transform", "translate(" + (width / 2 + title.length * 8 / 2) + ",20)") .attr("transform", d => "translate(" + (width / 2 + d.title.length * 8 / 2) + ",20)")
.text(title); .text(d => d.title);
genomeAxisSelectionUpdate genomeAxisSelectionUpdate
......
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