# hustcc/echarts-for-react architecture

> Architecture diagram of the GitHub repository hustcc/echarts-for-react, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hustcc/echarts-for-react
- Repository: https://github.com/hustcc/echarts-for-react

## Overview

##### Project type and purpose
- This is an open-source React component library (“echarts-for-react”) that wraps Apache ECharts into a React API.
- Its goal is to let any React app render ECharts charts by simply importing a component and passing ECharts option objects.

##### File structure
- Top-level:
- src/ – library source (core.tsx, index.ts, helper/, types.ts)
- __tests__/ – Jest/TS tests for core logic and helpers
- docs/ – example markdown, docs site under .umirc.js (Umi config)
- .github/workflows/build.yml – CI pipeline (test, build, coverage)
- package.json, tsconfig.json – package metadata and TypeScript config
- README.md – usage, API, examples for v3/v4/v5 of ECharts, Next.js notes
- Patterns:
- src/index.ts exports high-level ReactECharts component
- src/core.tsx implements ReactEChartsCore, handling lifecycle, ECharts init/update/resize
- src/helper contains pure utilities (is-equal, is-function, pick, etc.)
- docs/examples/*.md define usage cases and drive the documentation site
- CI runs tests ▶ builds ▶ publishes docs to GH Pages and package to npm

##### README for additional insights
- Describes two entry points: ReactECharts (auto-import ECharts) and ReactEChartsCore (manual ECharts module registration)
- Highlights peer dependencies (react, echarts, optionally echarts-gl)
- Covers supported props (option, notMerge, lazyUpdate, theme, onEvents, opts, autoResize)
- Notes Next.js transpile requirements

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Runtime Components
    subgraph "Runtime Components"
        direction TB
        ConsumerApp["Consumer React App"]:::runtime
        ReactECharts["ReactECharts (wrapper)"]:::runtime
        ReactEChartsCore["ReactEChartsCore (core)"]:::runtime
        EChartsEngine["Apache ECharts Engine"]:::runtime
        CanvasRenderer["CanvasRenderer"]:::runtime
        SVGRenderer["SVGRenderer"]:::runtime
        DOMContainer["DOM <div> Container"]:::runtime
        subgraph "Helper Utilities"
            direction TB
            IsEqual["is-equal.ts"]:::runtime
            IsFunction["is-function.ts"]:::runtime
            IsString["is-string.ts"]:::runtime
            Pick["pick.ts"]:::runtime
        end
        TypeDefs["types.ts"]:::runtime
    end

    ConsumerApp -->|"imports"| ReactECharts
    ReactECharts -->|"delegates to"| ReactEChartsCore
    ReactEChartsCore -->|"calls echarts.init()"| EChartsEngine
    EChartsEngine --> CanvasRenderer
    EChartsEngine --> SVGRenderer
    EChartsEngine -->|"renders"| DOMContainer
    ReactEChartsCore -->|"uses helpers"| IsEqual
    ReactEChartsCore -->|"uses helpers"| IsFunction
    ReactEChartsCore -->|"uses helpers"| IsString
    ReactEChartsCore -->|"uses helpers"| Pick
    ReactEChartsCore -->|"uses types"| TypeDefs

    %% Development Tools
    subgraph "Development Tools"
        direction TB
        TypeScript["TypeScript Compiler"]:::dev
        Jest["Jest Testing"]:::dev
        UmiJS["UmiJS (Docs Site)"]:::dev
    end

    %% Documentation Site
    subgraph "Documentation"
        direction TB
        DocsIndex["docs/index.md"]:::docs
        APIExample["api.md"]:::docs
        DynamicExample["dynamic.md"]:::docs
        EventExample["event.md"]:::docs
        GLExample["gl.md"]:::docs
        GraphExample["graph.md"]:::docs
        LoadingExample["loading.md"]:::docs
        LocaleExample["locale.md"]:::docs
        SimpleExample["simple.md"]:::docs
        SVGExample["svg.md"]:::docs
        ThemeExample["theme.md"]:::docs
        UMICfg[".umirc.js"]:::docs
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GitHubActions["GitHub Actions"]:::cicd
        TestsBuild["Test & Build"]:::cicd
        Publish["Publish to npm & GH Pages"]:::cicd
    end

    %% Build Config
    subgraph "Build Config"
        direction TB
        PackageJSON["package.json"]:::config
        TSConfig["tsconfig.json"]:::config
        README["README.md"]:::config
    end

    %% CI/CD flow
    GitHubActions -->|"runs"| TestsBuild
    TestsBuild -->|"publishes"| Publish

    %% Docs flow
    UmiJS -->|"builds site from"| DocsIndex
    UmiJS -->|"builds site from"| APIExample
    UmiJS -->|"builds site from"| DynamicExample
    UmiJS -->|"builds site from"| EventExample
    UmiJS -->|"builds site from"| GLExample
    UmiJS -->|"builds site from"| GraphExample
    UmiJS -->|"builds site from"| LoadingExample
    UmiJS -->|"builds site from"| LocaleExample
    UmiJS -->|"builds site from"| SimpleExample
    UmiJS -->|"builds site from"| SVGExample
    UmiJS -->|"builds site from"| ThemeExample
    UmiJS -->|"uses config"| UMICfg

    %% Dev Tools integration
    TypeScript --> ReactEChartsCore
    TypeScript --> HelperUtilities
    Jest --> TestsBuild
    UmiJS --> Documentation

    CI_CD -->|uses| GitHubActions

    %% Click Events
    click ReactECharts "https://github.com/hustcc/echarts-for-react/blob/master/src/index.ts"
    click ReactEChartsCore "https://github.com/hustcc/echarts-for-react/blob/master/src/core.tsx"
    click IsEqual "https://github.com/hustcc/echarts-for-react/blob/master/src/helper/is-equal.ts"
    click IsFunction "https://github.com/hustcc/echarts-for-react/blob/master/src/helper/is-function.ts"
    click IsString "https://github.com/hustcc/echarts-for-react/blob/master/src/helper/is-string.ts"
    click Pick "https://github.com/hustcc/echarts-for-react/blob/master/src/helper/pick.ts"
    click TypeDefs "https://github.com/hustcc/echarts-for-react/blob/master/src/types.ts"
    click DocsIndex "https://github.com/hustcc/echarts-for-react/blob/master/docs/index.md"
    click APIExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/api.md"
    click DynamicExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/dynamic.md"
    click EventExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/event.md"
    click GLExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/gl.md"
    click GraphExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/graph.md"
    click LoadingExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/loading.md"
    click LocaleExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/locale.md"
    click SimpleExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/simple.md"
    click SVGExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/svg.md"
    click ThemeExample "https://github.com/hustcc/echarts-for-react/blob/master/docs/examples/theme.md"
    click UMICfg "https://github.com/hustcc/echarts-for-react/blob/master/.umirc.js"
    click GitHubActions "https://github.com/hustcc/echarts-for-react/blob/master/.github/workflows/build.yml"
    click PackageJSON "https://github.com/hustcc/echarts-for-react/blob/master/package.json"
    click TSConfig "https://github.com/hustcc/echarts-for-react/blob/master/tsconfig.json"
    click README "https://github.com/hustcc/echarts-for-react/blob/master/README.md"

    %% Styles
    classDef runtime fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef dev fill:#E6FFDD,stroke:#28A745,color:#28A745;
    classDef docs fill:#F0E6FF,stroke:#6F42C1,color:#6F42C1;
    classDef cicd fill:#FFE8D6,stroke:#DE6A16,color:#DE6A16;
    classDef config fill:#F8F9FA,stroke:#6A737D,color:#24292E;
```
