Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer handles SVG generation
func NewRenderer ¶
func NewRenderer(config *decision_tree.Config) *Renderer
NewRenderer creates a new SVG renderer
func (*Renderer) RenderTree ¶
func (r *Renderer) RenderTree(root *decision_tree.Node) string
RenderTree generates SVG for the entire tree
func (*Renderer) SetCenterParent ¶
SetCenterParent sets whether parent nodes should be centered over their children
type Server ¶ added in v0.0.18
type Server struct {
// contains filtered or unexported fields
}
Server serves SVG content dynamically
func (*Server) Serve ¶ added in v0.0.18
func (s *Server) Serve(tree *decision_tree.Node) error
Serve starts serving the SVG content for the given tree. It automatically selects an available port starting from 12137, and prints the URL to console. The server runs until Stop is called or the process receives SIGINT/SIGTERM.
Example ¶
// Create a simple tree tree := &decision_tree.Node{ ID: "root", Label: "Root", Children: []*decision_tree.Node{ { ID: "child", Label: "Child", }, }, } // Create and start server server := NewServer(nil) go func() { if err := server.Serve(tree); err != http.ErrServerClosed { fmt.Printf("server error: %v\n", err) } }() // Wait a bit for server to start time.Sleep(100 * time.Millisecond) // Stop server after demonstration server.Stop() // Output will be something like: // SVG server running at: http://localhost:12137 // Server stop requested...
func (*Server) ServeFile ¶ added in v0.0.18
ServeFile starts serving SVG content from the given JSON file. The file should contain a JSON representation of a decision_tree.Node. The server will read the file on each request to ensure latest content.
func (*Server) SetPortNotifier ¶ added in v0.0.18
SetPortNotifier sets a channel to receive the port number when the server starts. This is primarily used for testing.
func (*Server) UpdateFile ¶ added in v0.0.18
UpdateFile updates the file path being served (when in file mode)
func (*Server) UpdateTree ¶ added in v0.0.18
func (s *Server) UpdateTree(tree *decision_tree.Node)
UpdateTree updates the tree being served (when in memory mode)