...

Source file src/edge-infra.dev/pkg/f8n/warehouse/lift/cmd/graph/dot_style.go

Documentation: edge-infra.dev/pkg/f8n/warehouse/lift/cmd/graph

     1  package graph
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  	"os"
     7  
     8  	"edge-infra.dev/pkg/lib/text/drawing"
     9  )
    10  
    11  func dotNodeByType(ref string, mediaType string) (*drawing.DotNode, error) {
    12  	var shape string
    13  	var color string
    14  	switch mediaType {
    15  	case idxNode:
    16  		shape = "folder"
    17  		color = `"#90a188"`
    18  	case imgNode:
    19  		shape = "box3d"
    20  		color = `"#e895cb"`
    21  	case layerNode:
    22  		shape = "note"
    23  		color = `"#dbe4f1"`
    24  	case objectsNode:
    25  		shape = "component"
    26  		color = "invis"
    27  	default:
    28  		return nil, errUnsupportedDotNodeType
    29  	}
    30  
    31  	return &drawing.DotNode{
    32  		Data: ref,
    33  		Attributes: map[string]string{
    34  			"shape":     shape,
    35  			"fillcolor": color,
    36  			"style":     "filled",
    37  		},
    38  	}, nil
    39  }
    40  
    41  type palletLegend struct{}
    42  
    43  func (l *palletLegend) Print() {
    44  	l.Fprint(os.Stdout)
    45  }
    46  
    47  func (l *palletLegend) Fprint(w io.Writer) {
    48  	legend := `subgraph cluster_legend {
    49  	style=dotted
    50  	Index [shape=folder fillcolor="#90a188" style=filled]
    51  	Image [shape=box3d fillcolor="#e895cb" style=filled]
    52  	Layer [shape=note fillcolor="#dbe4f1" style=filled]
    53  	Objects [shape=component fillcolor=invis style=filled]
    54  	Index -> Image -> Layer -> Objects [style="invis"]
    55  }`
    56  
    57  	fmt.Fprintln(w, legend)
    58  }
    59  

View as plain text