Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cassiopée
nghyd
Commits
02a019d0
Commit
02a019d0
authored
2 years ago
by
François Grand
Browse files
Options
Downloads
Patches
Plain Diff
fix: parametric sections graph: overlapping levels text
refs
#497
parent
698e52e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!171
Resolve "Section paramétrée - profil de section: option axes orthonormés"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/components/section-canvas/section-canvas.component.ts
+56
-11
56 additions, 11 deletions
...app/components/section-canvas/section-canvas.component.ts
with
56 additions
and
11 deletions
src/app/components/section-canvas/section-canvas.component.ts
+
56
−
11
View file @
02a019d0
...
...
@@ -241,6 +241,9 @@ export class SectionCanvasComponent extends ResultsComponentDirective implements
this
.
_levels
.
push
({
val
,
label
,
rgb
});
}
/**
* trie les tirants par niveau d'eau croissant
*/
private
sortLevels
()
{
this
.
_levels
.
sort
((
a
,
b
)
=>
{
if
(
a
[
"
val
"
]
<
b
[
"
val
"
])
{
...
...
@@ -533,26 +536,68 @@ export class SectionCanvasComponent extends ResultsComponentDirective implements
throw
new
Error
(
"
SectionCanvasComponent.drawSection() : type de section non pris en charge
"
);
}
private
drawLevels
()
{
let
left
=
true
;
/**
* dessin des niveaux en gérant le chevauchement
* @param levels liste des niveaux à tracer
* @param textHeight hauteur minimal entre le texte des niveaux (m)
* @param left true pour tracer le texte à gauche du niveau, false à droite
*/
private
drawLevelsWithoutOverlap
(
levels
:
any
,
textHeight
:
number
,
left
:
boolean
)
{
for
(
let
i
=
levels
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
l
=
levels
[
i
];
// chevauchement avec le précédent ?
if
(
i
<
levels
.
length
-
1
)
{
let
yprec
=
levels
[
i
+
1
].
y
;
const
ycurr
=
l
.
y
;
if
(
yprec
-
ycurr
<
textHeight
)
{
l
.
y
=
yprec
-
textHeight
;
}
}
// tracé du tirant courant
const
col
=
l
[
"
rgb
"
];
this
.
setStrokeColor
(
col
[
"
r
"
],
col
[
"
g
"
],
col
[
"
b
"
]);
this
.
drawSectionLine
(
0
,
l
.
val
,
this
.
_Wsect_m
,
l
.
val
);
this
.
setFillColor
(
col
[
"
r
"
],
col
[
"
g
"
],
col
[
"
b
"
]);
if
(
left
)
{
this
.
drawText
(
l
[
"
label
"
],
0
,
l
.
y
,
"
right
"
);
}
else
{
this
.
drawText
(
l
[
"
label
"
],
this
.
_Wsect_m
,
l
.
y
,
"
left
"
);
}
}
}
private
drawLevels
()
{
this
.
resetLineDash
();
this
.
setLineWidth
(
1
);
this
.
setFont
(
"
12px sans- serif
"
);
this
.
setFont
(
"
12px sans-serif
"
);
// hauteur des caractères
const
tm
:
TextMetrics
=
this
.
_context2d
.
measureText
(
"
Ag
"
);
const
charHeightPix
=
tm
.
actualBoundingBoxAscent
+
tm
.
actualBoundingBoxDescent
;
const
charHeightMeter
=
charHeightPix
/
this
.
_scaleY
;
// sépare les niveaux de gauche/droite
const
leftLevels
=
[];
const
rightLevels
=
[];
let
left
=
true
;
for
(
const
l
of
this
.
_levels
)
{
const
y
=
l
[
"
val
"
];
const
col
=
l
[
"
rgb
"
];
this
.
setStrokeColor
(
col
[
"
r
"
],
col
[
"
g
"
],
col
[
"
b
"
]);
this
.
drawSectionLine
(
0
,
y
,
this
.
_Wsect_m
,
y
);
this
.
setFillColor
(
col
[
"
r
"
],
col
[
"
g
"
],
col
[
"
b
"
]);
Object
.
assign
(
l
,
{
"
y
"
:
y
});
// y = ordonnée de tracé
if
(
left
)
{
this
.
drawText
(
l
[
"
label
"
],
0
,
y
,
"
right
"
);
leftLevels
.
push
(
l
);
}
else
{
this
.
drawText
(
l
[
"
label
"
],
this
.
_Wsect_m
,
y
,
"
left
"
);
rightLevels
.
push
(
l
);
}
left
=
!
left
;
}
// dessin des textes
this
.
drawLevelsWithoutOverlap
(
leftLevels
,
charHeightMeter
,
true
);
this
.
drawLevelsWithoutOverlap
(
rightLevels
,
charHeightMeter
,
false
);
}
// contour du canvas
...
...
@@ -578,7 +623,7 @@ export class SectionCanvasComponent extends ResultsComponentDirective implements
this
.
_context2d
.
fillStyle
=
col
;
}
p
ublic
setFont
(
f
:
string
)
{
p
rivate
setFont
(
f
:
string
)
{
this
.
_context2d
.
font
=
f
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment