Skip to content

希望能扩展前端渲染Echarts的工具箱功能 #6269

Description

@ToukoYui

例行检查

  • 我已确认目前没有类似 features
  • 我已确认我已升级到最新版本
  • 我已完整查看过项目 README,已确定现有版本无法满足需求
  • 我理解并愿意跟进此 features,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 features 可能会被无视或直接关闭

功能描述
已知平台支持通过echart的json代码的渲染展示,支持toolbox的saveAsImage导出图片功能。但似乎dataView数据视图、magicType类型切换和restore还原的功能并不支持。

应用场景
增强交互性

相关示例
期待示例:

Image

实际示例:

Image

代码如下:

import json


def main():
    echarts_config = {
        "title": {
            "left": "center",
            "text": "分布情况"
        },
        "tooltip": {
            "trigger": "axis",
            "axisPointer": {
                "type": "cross"
            }
        },
        "grid": {
            "bottom": "80px",
            "left": "50px",
            "right": "50px",
            "top": "60px",
            "containLabel": True
        },
        "legend": {
            "show": True,
            "top": "10%"
        },
        "xAxis": {
            "type": "category",
            "data": [
                "2026-01-10",
                "2026-01-11",
                "2026-01-12"
            ],
            "axisLabel": {
                "rotate": 30,
                "interval": 0
            }
        },
        "yAxis": {
            "type": "value"
        },
        "color": [
            "#5470c6"
        ],
        "series": [
            {
                "data": [
                    3,
                    1,
                    12,
                ],
                "type": "line",
                "smooth": True,
                "name": "分布情况",
                "symbol": "circle",
                "symbolSize": 6,
                "lineStyle": {
                    "width": 3
                }
            }
        ],
        "dataZoom": [
            {
                "type": "slider",
                "xAxisIndex": 0,
                "show": True,
                "height": 15,
                "bottom": 25,
                "fillerColor": "rgba(135,206,250,0.2)",
                "borderColor": "#ccc"
            }
        ],
        "toolbox": {
            "show": True,
            "feature": {
                "dataView": {
                    "show": True,
                    "title": "数据视图",
                    "readOnly": False
                },
                "magicType": {
                    "show": True,
                    "type": [
                        "line",
                        "bar"
                    ],
                    "title": {
                        "line": "折线图",
                        "bar": "柱状图"
                    },
                    "option": {
                        "series": {
                            "smooth": True,
                            "symbol": "circle",
                            "symbolSize": 6,
                            "lineStyle": {
                                "width": 3
                            }
                        }
                    }
                },
                "restore": {
                    "show": True,
                    "title": "还原"
                },
                "saveAsImage": {
                    "show": True,
                    "title": "保存图片"
                }
            }
        }
    }

    return {
        "result": "```echarts\n" + json.dumps(echarts_config, ensure_ascii=False) + "\n```"
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions