微信扫码
添加专属顾问
我要投稿
利用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-04-30
知识融合新范式:Cherry Studio×dify 知识库联动全解析
2025-04-29
Dify 平台集成 Palo Alto Networks 安全插件,为 AI 应用注入企业级安全防护
2025-04-29
Dify→ LLM 节点 说明
2025-04-28
速看!最新版 Dify 连接 Ollama 与 vLLM 全攻略
2025-04-27
Docker 部署 dify 连接 ollama 模型报错?
2025-04-27
Dify 工作流→ 节点及相关功能
2025-04-26
java对接Dify的工作流API(实战篇)
2025-04-26
关于一次dify的渗透
2024-12-24
2024-04-25
2024-07-16
2024-07-20
2024-04-24
2024-06-21
2024-05-08
2024-11-15
2024-05-09
2024-08-06
2025-04-27
2025-04-15
2025-03-20
2024-12-19
2024-09-13
2024-09-13
2024-08-28
2024-04-24