微信扫码
添加专属顾问
我要投稿
利用Dify工具,轻松实现Excel数据可视化。 核心内容: 1. Dify工具的介绍及Demo流程图展示 2. 节点功能解析:从文件上传到图表生成的完整步骤 3. 代码执行节点:Echarts图表代码生成及应用
你是一个文档提取专家,请根据用户上传文档内容{文档提取器输出text}提取该表格里面的数据返回json格式数据。其中内容格式‘文章日阅读量’、‘Dify安装部署’、‘RAGFlow安装部署’、‘Dify联网查询’、‘Dify翻译小助手’、‘Dify创建知识库’字段返回信息,返回的结果信息以json格式返回返回数据格式如下:{"文章日阅读量": [{"date": "2025-3-1","Dify安装部署": 200,"RAGFlow安装部署": 300,"Dify联网查询": 125,"Dify翻译小助手": 351,“Dify创建知识库”: 123},{"date": "2025-3-2","Dify安装部署": 323,"RAGFlow安装部署": 335,"Dify联网查询": 1321,"Dify翻译小助手": 514,“Dify创建知识库”: 153},]}
import jsonimport osimport redef main(json_str: str) -> dict: try: # 预处理:清理非 JSON 部分 json_match = re.search(r'\{.*\}', json_str, re.DOTALL) if not json_match: return {"result": "Error: Invalid JSON format"} # 提取合法的 JSON 部分 cleaned_json_str = json_match.group(0) # 解析JSON数据 data = json.loads(cleaned_json_str) filename = data.get("filename", "stock_chart.html") stock_data = data.get("文章日阅读量", []) # 准备数据格式 dates = [item['date'].split(' ')[0] for item in stock_data] # 提取日期部分(去掉时间) articles_read_num1 = [item['Dify安装部署'] for item in stock_data] articles_read_num2 = [item['RAGFlow安装部署'] for item in stock_data] articles_read_num3 = [item['Dify联网查询'] for item in stock_data] articles_read_num4 = [item['Dify翻译小助手'] for item in stock_data] articles_read_num5 = [item['Dify创建知识库'] for item in stock_data] # 构建ECharts配置 echarts_config = { "title": { "text": "文章日阅读量" }, "legend": { "data": ["Dify安装部署", "RAGFlow安装部署", "Dify联网查询", "Dify翻译小助手", "Dify创建知识库"] }, "tooltip": {}, "dataset": { "source": [ ["日期", "Dify安装部署", "RAGFlow安装部署", "Dify联网查询", "Dify翻译小助手", "Dify创建知识库"], *[[dates[i], articles_read_num1[i], articles_read_num2[i], articles_read_num3[i], articles_read_num4[i], articles_read_num5[i]] for i in range(len(dates))] ] }, "xAxis": [ {"type": "category", "gridIndex": 0} ], "yAxis": [ { "gridIndex": 0, "name": "日阅读量(单位:次)" } ], "grid": [ {"bottom": "55%"}, {"top": "55%"} ], "series": [ # 折线图系列 # {"type": "line", "seriesLayoutBy": "row", "name": "Dify安装部署"}, # {"type": "line", "seriesLayoutBy": "row", "name": "RAGFlow安装部署"}, # {"type": "line", "seriesLayoutBy": "row", "name": "Dify联网查询"}, # {"type": "line", "seriesLayoutBy": "row", "name": "Dify翻译小助手"}, # {"type": "line", "seriesLayoutBy": "row", "name": "Dify创建知识库"} # 柱状图系列 {"type": "bar", "xAxisIndex": 0, "yAxisIndex": 0, "name": "Dify安装部署"}, {"type": "bar", "xAxisIndex": 0, "yAxisIndex": 0, "name": "RAGFlow安装部署"}, {"type": "bar", "xAxisIndex": 0, "yAxisIndex": 0, "name": "Dify联网查询"}, {"type": "bar", "xAxisIndex": 0, "yAxisIndex": 0, "name": "Dify翻译小助手"}, {"type": "bar", "xAxisIndex": 0, "yAxisIndex": 0, "name": "Dify创建知识库"} ] } # 生成输出文件 output = "```echarts\n" + json.dumps(echarts_config, indent=2, ensure_ascii=False) + "\n```" # 返回结果 return { "result": output } except Exception as e: return { "result": f"Error: {str(e)}" }53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-10-30
Dify流程暂停与人工干预:3种实现方案+避坑指南
2025-10-16
告别升级噩梦:Dify 二次开发的无缝适配策略与实战案例(基于 v1.9.1)
2025-10-13
用Dify搭建企业知识库:5个实战技巧提升检索准确率90%
2025-10-13
Dify接口调用实战指南:从入门到精通的避坑手册,收藏了!
2025-10-12
Dify1.6.0升级1.9.1步骤及踩坑记
2025-10-10
用 Dify 零代码搭建 AI 用研助理,5分钟完成100个虚拟用户调研
2025-09-30
重大消息,刚刚Dify 1.9.1发布了!我们聊聊带来了哪些吸引人的功能特性?
2025-09-26
内网环境下Dify1.9.0版本镜像构建过程记录
2025-10-13
2025-09-03
2025-09-16
2025-09-06
2025-08-19
2025-09-23
2025-09-02
2025-08-18
2025-09-04
2025-10-12
2025-09-30
2025-09-23
2025-09-06
2025-09-05
2025-08-29
2025-08-18
2025-08-02
2025-07-30