Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Remi PLANEL
bioviz-js
Commits
5a14d15c
Commit
5a14d15c
authored
Apr 02, 2019
by
Remi PLANEL
Browse files
Handle when gene width is smaller that arrow width
parent
b6331c57
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/scripts/component/sequence/gene-shapes.ts
View file @
5a14d15c
import
{
GeneData
}
from
"
./gene
"
;
import
{
ScaleLinear
}
from
"
d3-scale
"
;
export
function
arrowShape
(
data
:
GeneData
,
xScale
:
ScaleLinear
<
number
,
number
>
,
geneHeight
:
number
)
{
const
geneWidth
=
xScale
(
data
.
length
);
return
"
M 0 0 V
"
+
(
-
geneHeight
)
+
"
H
"
+
geneWidth
+
"
V
"
+
geneHeight
+
"
H
"
+
(
-
geneWidth
)
+
"
Z
"
;
import
{
GeneData
,
PositionedGeneData
}
from
"
./gene
"
;
import
{
path
}
from
"
d3-path
"
;
export
function
arrowShape
(
data
:
PositionedGeneData
,
geneHeight
:
number
,
arrowWidth
:
number
=
20
)
{
const
{
position
:
{
x
,
y
,
width
}
}
=
data
;
const
genePath
=
path
();
if
(
width
<
arrowWidth
)
{
genePath
.
moveTo
(
0
,
geneHeight
/
2
);
genePath
.
lineTo
(
width
,
geneHeight
);
genePath
.
lineTo
(
width
,
0
);
genePath
.
closePath
();
}
else
{
genePath
.
moveTo
(
0
,
geneHeight
/
2
);
genePath
.
lineTo
(
arrowWidth
,
geneHeight
);
genePath
.
lineTo
(
width
,
geneHeight
);
genePath
.
lineTo
(
width
,
0
);
genePath
.
lineTo
(
arrowWidth
,
0
);
genePath
.
closePath
();
}
return
genePath
.
toString
();
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment