I'm relativly new in SVG and i didn't find any solution online for my problem..
I have a line called link. In the end of it I have a marker - Arrow Head. My line should be colored according to his settings and the head as well. But I didn't find a dynamic way to bind this color to the head.
I'm using NGX-GRAPH to draw my graph, and according to the documentation, we have to do a template with svg:path
having the class line
. So it is not possible to create a multi path or any other workaround (at least what i've tried failed). It must be a path
. Using the marker-end
with url
I've managed to put in the end of the line the head. but cannot control its color dynamically.
<ng-template>
<svg:marker id="arrowHead" viewBox="0 -5 10 10" refX="8" refY="0" markerWidth="8" markerHeight="8" orient="auto">
<svg:path d="M0,-5L10,0L0,5" class="arrow-head" />
</svg:marker>
</ng-template>
...
<ng-template #linkTemplate let-link>
<svg:path class="line" [ngClass]="{'highlighted-item' : highlights.has(link.id)}"
[attr.stroke]="link.color" marker-end="url(#arrowHead)" >
</svg:path>
</ng-template>