[PR #6961] Add ECharts feature ( #6385 ) #25514

Closed
opened 2026-02-21 20:25:05 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/6961

State: closed
Merged: Yes


Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

Close #6385
Added support for drawing with ECharts during output, which can directly output interactive images.
Use Json format for transmission in Markdown, just convert the information in option into json format and pass it in.
cd52fde1603be31ce6db8a970a5be56

Example:

Code

```echarts
{
  "xAxis": {
    "type": "category",
    "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
  },
  "yAxis": {
    "type": "value"
  },
  "series": [
    {
      "data": [120, 200, 150, 80, 70, 110, 130],
      "type": "bar",
      "showBackground": true,
      "backgroundStyle": {
        "color": "rgba(180, 180, 180, 0.2)"
      }
    }
  ]
}
```

For a more complex interactive ECharts chart, you can use the following code to test it:

Code

```echarts
{
    "title": {
        "textStyle": {
            "align": "center",
            "color": "#fff",
            "fontSize": 20
        },
        "top": "3%",
        "left": "10%"
    },
    "backgroundColor": "#0B1346",
    "grid": {
        "top": "25%",
        "bottom": "10%"
    },
    "tooltip": {
        "trigger": "axis",
        "axisPointer": {
            "type": "shadow",
            "label": {
                "show": false
            }
        }
    },
    "legend": {
        "data": [
            "库存",
            "需求"
        ],
        "top": "15%",
        "textStyle": {
            "color": "#ffffff"
        }
    },
    "xAxis": {
        "data": [
            "C15喷射",
            "C25组",
            "C36水泵送",
            "C85补偿收缩"
        ],
        "axisLine": {
            "show": true,
            "symbol": [
                "none",
                "arrow"
            ],
            "lineStyle": {
                "color": "#CBDDF4"
            }
        },
        "axisTick": {
            "show": true
        },
        "axisLabel": {
            "show": true,
            "rotate": 0,
            "textStyle": {
                "color": "#CBDDF4"
            }
        }
    },
    "yAxis": [
        {
            "type": "value",
            "splitLine": {
                "show": true
            },
            "axisTick": {
                "show": false
            },
            "axisLine": {
                "show": true,
                "symbol": [
                    "none",
                    "arrow"
                ],
                "lineStyle": {
                    "color": "#CBDDF4"
                }
            },
            "axisLabel": {
                "show": true,
                "textStyle": {
                    "color": "#BADBFB"
                }
            }
        }
    ],
    "series": [
        {
            "name": "库存",
            "type": "bar",
            "barWidth": 15,
            "smooth": true,
            "showAllSymbol": true,
            "symbol": "circle",
            "itemStyle": {
                "normal": {
                    "color": "#6392F4"
                }
            },
            "data": [
                1,
                2,
                3,
                2
            ]
        },
        {
            "name": "需求",
            "type": "line",
            "barWidth": 15,
            "showSymbol": true,
            "symbolSize": 10,
            "itemStyle": {
                "normal": {
                    "color": "#80BD95"
                }
            },
            "data": [
                4,
                4,
                4,
                4
            ]
        }
    ]
}
```
```

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
    Tested using the above code

  • Test B

**Original Pull Request:** https://github.com/langgenius/dify/pull/6961 **State:** closed **Merged:** Yes --- # Checklist: > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [x] Please open an issue before creating a PR or link to an existing issue - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods # Description Close #6385 Added support for drawing with ECharts during output, which can directly output interactive images. Use Json format for transmission in Markdown, just convert the information in `option` into json format and pass it in. ![cd52fde1603be31ce6db8a970a5be56](https://github.com/user-attachments/assets/bde1b0e1-360f-430c-9f48-7191965d8ca8) Example: <details><summary>Code</summary> <pre><code> ```echarts { "xAxis": { "type": "category", "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] }, "yAxis": { "type": "value" }, "series": [ { "data": [120, 200, 150, 80, 70, 110, 130], "type": "bar", "showBackground": true, "backgroundStyle": { "color": "rgba(180, 180, 180, 0.2)" } } ] } ``` </code></pre> </details> For a more complex interactive ECharts chart, you can use the following code to test it: <details><summary>Code</summary> <pre><code> ```echarts { "title": { "textStyle": { "align": "center", "color": "#fff", "fontSize": 20 }, "top": "3%", "left": "10%" }, "backgroundColor": "#0B1346", "grid": { "top": "25%", "bottom": "10%" }, "tooltip": { "trigger": "axis", "axisPointer": { "type": "shadow", "label": { "show": false } } }, "legend": { "data": [ "库存", "需求" ], "top": "15%", "textStyle": { "color": "#ffffff" } }, "xAxis": { "data": [ "C15喷射", "C25组", "C36水泵送", "C85补偿收缩" ], "axisLine": { "show": true, "symbol": [ "none", "arrow" ], "lineStyle": { "color": "#CBDDF4" } }, "axisTick": { "show": true }, "axisLabel": { "show": true, "rotate": 0, "textStyle": { "color": "#CBDDF4" } } }, "yAxis": [ { "type": "value", "splitLine": { "show": true }, "axisTick": { "show": false }, "axisLine": { "show": true, "symbol": [ "none", "arrow" ], "lineStyle": { "color": "#CBDDF4" } }, "axisLabel": { "show": true, "textStyle": { "color": "#BADBFB" } } } ], "series": [ { "name": "库存", "type": "bar", "barWidth": 15, "smooth": true, "showAllSymbol": true, "symbol": "circle", "itemStyle": { "normal": { "color": "#6392F4" } }, "data": [ 1, 2, 3, 2 ] }, { "name": "需求", "type": "line", "barWidth": 15, "showSymbol": true, "symbolSize": 10, "itemStyle": { "normal": { "color": "#80BD95" } }, "data": [ 4, 4, 4, 4 ] } ] } ``` ``` </code></pre> </details> ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [ ] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement - [ ] Dependency upgrade # Testing Instructions Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [x] Test A Tested using the above code - [x] Test B
yindo added the pull-request label 2026-02-21 20:25:05 -05:00
yindo closed this issue 2026-02-21 20:25:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#25514