How ziqian-huang0607/devchart works
Main Components
• Table Module – This component is responsible for rendering data as formatted tables. It includes logic for setting headers, data, and configurable options such as border style, text alignment, and cell padding.
• Graph Module – This splits into two sub-components:
◦ Bar Graph – Handles vertical bar graph generation with customizations (width, bar character).
◦ Line Graph – Handles line graph generation with customizations (width, height, point character).
• Options – Both the Table component and the Graph components have dedicated “Options” structures (for table options, bar graph options, and line graph options) which configure rendering details.
Relationships and Data Flow
• The client code (a command-line application or any Go program) imports DevChart. It creates instances via constructors (e.g. NewTable, NewBarGraph, and NewLineGraph).
• The client sets data, options, and then calls a render method (Print or Render) to output the chart/table to the terminal.
• Data flows from the input provided by the user (in the client’s code) through the configuration components (options) and into the rendering engine of each module.
Architectural Patterns and Design Principles
• Modularity: The project is separated into two main packages (“table” and “graph”) which encapsulate distinct functionalities.
• Configurability: Both charting components use “Options” structs to allow customizable behavior.
• Separation of Concerns: Each module is responsible for only one output type (table or graph), making the library flexible and easy to extend.
• Simplicity: Given it is targeted for terminal output, the internal architecture remains straightforward with one main flow: configuration ➜ data setting ➜ rendering.