How alibaba/bizcharts works
Main Components
• Core Engine and API:
• The chart “core” (found in src/core.ts and related modules) that initializes and manages chart instances.
• The createPlot.tsx and src/index.tsx that serve as entry points.
• Presentation/UI Components:
• Chart and View components (in src/components/Chart, src/components/View).
• g-components and geometry components (e.g., src/g-components, src/geometry) which render lower-level graphics.
• Plot Types:
• A rich set of specific chart types (in src/plots) for area, bar, line, pie, scatter, etc.
• Adapters and Connectors:
• Adapters (in src/adapter) which translate or bridge data and configuration.
• Connectors (in src/connector) that likely help in setting up cross-component interactions such as tooltips.
• Context and State Management:
• Context providers (in src/context) that manage shared state such as canvas, view, and group.
• Utils and Helpers:
• Data transformation utilities (in src/utils/ and src/utils/data-transform) that aid in processing input data.
• Theming and Extensions:
• The theme management files (in src/theme) that define default styles and potentially allow injection of custom themes.
Testing and Demos
• Demo Files (demos folder) serve as usage examples and proofs-of-concept for various charts and features.
• Storybook and Story files (in __stories__ and .storybook) show UI states and component interactions.
• Tests (uitest and unittest) indicate how the system is verified at multiple layers (unit tests for components, integration tests for charts).
Relationships and Interactions
• The Core Engine receives initialization from createPlot and then orchestrates rendering by invoking geometry components and graphics (g-components).
• Adapters and Context Providers are used throughout to propagate configuration and data updates.
• Utility functions (for data transformation) support the data flow from raw input to visualization.
• The system’s extensibility and error resilience is supported through boundaries (ErrorBoundary components) and connectors that manage cross-component communication (e.g., for synchronized tooltips).
Architectural Patterns and Design Principles
• Modular separation: distinct directories (components, g-components, geometry, plots) show that BizCharts is architected in a highly modular fashion.
• Layered abstraction: core engine -> UI components (presentational) -> charts (specific implementations) following a loose “MVC-ish” or “view-controller” separation.
• React Composition: emphasis on reusable, composable components, as seen by the use of numerous React components and context providers.
• Extensibility: the extend folder and adapter patterns suggest a design made to be extended or customized by third-party developers.
Details
• Use call-outs or annotations to note the use of React, and mark libraries or frameworks (e.g., the explicit reliance on React, integration with Storybook for component testing, and extensive unit/UITest support).
• Don’t shy away from highlighting the testing infrastructure (“uitest,” “unittest”) separately if it’s relevant to overall system quality assurance.