File tree Expand file tree Collapse file tree 6 files changed +18
-11
lines changed
Expand file tree Collapse file tree 6 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export function diagramToGraphviz(
5757 attributes : {
5858 id,
5959 label : [ label , overLabel ] . filter ( ( s ) => s ) . join ( " : " ) ,
60- class : graphStyles . svgCssClasses ( meta ) . join ( " " ) ,
60+ class : graphStyles . svgNodeCssClasses ( meta ) . join ( " " ) ,
6161 fontname : graphStyles . graphvizFontname ( meta ) ,
6262 } ,
6363 } ) ;
@@ -79,7 +79,7 @@ export function diagramToGraphviz(
7979 attributes : {
8080 id,
8181 label : overLabel ?? "" ,
82- class : graphStyles . svgCssClasses ( meta ) . join ( " " ) ,
82+ class : graphStyles . svgEdgeCssClasses ( meta ) . join ( " " ) ,
8383 fontname : graphStyles . graphvizFontname ( meta ) ,
8484 } ,
8585 } ) ;
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export function modelToGraphviz(
5454 attributes : {
5555 id,
5656 label : ob . label ?. join ( "." ) ?? "" ,
57- class : graphStyles . svgCssClasses ( meta ) . join ( " " ) ,
57+ class : graphStyles . svgNodeCssClasses ( meta ) . join ( " " ) ,
5858 fontname : graphStyles . graphvizFontname ( meta ) ,
5959 } ,
6060 } ) ;
@@ -74,7 +74,7 @@ export function modelToGraphviz(
7474 attributes : {
7575 id,
7676 label,
77- class : graphStyles . svgCssClasses ( meta ) . join ( " " ) ,
77+ class : graphStyles . svgEdgeCssClasses ( meta ) . join ( " " ) ,
7878 fontname : graphStyles . graphvizFontname ( meta ) ,
7979 // Not recognized by Graphviz but will be passed through!
8080 arrowstyle : meta ?. arrowStyle ?? "default" ,
Original file line number Diff line number Diff line change @@ -129,7 +129,6 @@ function StockFlowSVG(props: {
129129 return result ;
130130 } ;
131131
132- const linkClass = [ "edge" , svgStyles [ "link" ] ] . join ( " " ) ;
133132 return (
134133 < svg
135134 ref = { props . ref }
@@ -144,7 +143,7 @@ function StockFlowSVG(props: {
144143 < For each = { props . layout ?. edges ?? [ ] } > { ( edge ) => < EdgeSVG edge = { edge } /> } </ For >
145144 < For each = { linkPaths ( ) } >
146145 { ( data ) => (
147- < g class = { linkClass } >
146+ < g class = { svgStyles [ "link" ] } >
148147 < path marker-end = { `url(#arrowhead-${ linkMarker } )` } d = { data } />
149148 </ g >
150149 ) }
Original file line number Diff line number Diff line change @@ -28,8 +28,14 @@ export const defaultEdgeAttributes: Required<Viz.Graph>["edgeAttributes"] = {
2828export const graphvizFontname = ( meta ?: BaseTypeMeta ) : string =>
2929 meta ?. textClasses ?. includes ( textStyles . code ) ? "Courier" : "Helvetica" ;
3030
31- // XXX: This should probably go somewhere else.
32- export const svgCssClasses = ( meta ?: BaseTypeMeta ) : string [ ] => [
33- ...( meta ?. svgClasses ?? [ ] ) ,
31+ /** CSS classes applied to a node in an SVG graph. */
32+ export const svgNodeCssClasses = ( meta ?: BaseTypeMeta ) : string [ ] => [
33+ ...( meta ?. svgClasses ?? [ "node" ] ) ,
34+ ...( meta ?. textClasses ?? [ ] ) ,
35+ ] ;
36+
37+ /** CSS classes applied to an edge in an SVG graph. */
38+ export const svgEdgeCssClasses = ( meta ?: BaseTypeMeta ) : string [ ] => [
39+ ...( meta ?. svgClasses ?? [ "edge" ] ) ,
3440 ...( meta ?. textClasses ?? [ ] ) ,
3541] ;
Original file line number Diff line number Diff line change 1212}
1313
1414.link path {
15+ fill : none;
1516 stroke : blue;
17+ stroke-width : 1.2 ;
1618}
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export function NodeSVG<Id>(props: { node: GraphLayout.Node<Id> }) {
4646 } = destructure ( props , { deep : true } ) ;
4747
4848 return (
49- < g class = { `node ${ props . node . cssClass ?? "" } ` } >
49+ < g class = { props . node . cssClass ?? "node" } >
5050 < rect x = { x ( ) - width ( ) / 2 } y = { y ( ) - height ( ) / 2 } width = { width ( ) } height = { height ( ) } />
5151 < Show when = { props . node . label } >
5252 < text class = "label" x = { x ( ) } y = { y ( ) } dominant-baseline = "middle" text-anchor = "middle" >
@@ -89,7 +89,7 @@ export function EdgeSVG<Id>(props: { edge: GraphLayout.Edge<Id> }) {
8989 } ;
9090
9191 return (
92- < g class = { `edge ${ props . edge . cssClass ?? "" } ` } >
92+ < g class = { props . edge . cssClass ?? "edge" } >
9393 < Switch fallback = { defaultPath ( ) } >
9494 < Match when = { props . edge . style === "double" } >
9595 < path class = "double-outer" d = { path ( ) } />
You can’t perform that action at this time.
0 commit comments