V2.0 五大核心增强: 锚点定位/原生图表/插件架构/WebSocket/LLM智能

This commit is contained in:
2026-05-29 14:14:53 +08:00
parent 5546e5fca1
commit 8618867f92
51 changed files with 3368 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
from plugins.base_generator import BaseGenerator
import pandas as pd
import numpy as np
from typing import Dict, Any
class CPIGenerator(BaseGenerator):
generator_id = "cpi_chart"
generator_name = "CPI/PPI通胀图表生成器"
description = "生成CPI与PPI原生图表数据"
version = "2.0.0"
def fetch_data(self, params: Dict[str, Any] = None) -> bool:
months = ['1月', '2月', '3月', '4月', '5月', '6月']
self._data = pd.DataFrame({
'month': months,
'CPI同比': [0.7, 0.8, 0.9, 1.0 + np.random.randn() * 0.1,
0.95 + np.random.randn() * 0.1, None],
'PPI同比': [-2.5, -2.3, -2.1, -1.9 + np.random.randn() * 0.15,
-1.8 + np.random.randn() * 0.15, None]
})
self._data.loc[4:5, 'CPI同比'] = [0.9 + np.random.randn() * 0.1, 0.95 + np.random.randn() * 0.1]
self._data.loc[4:5, 'PPI同比'] = [-1.7 + np.random.randn() * 0.15, -1.5 + np.random.randn() * 0.15]
self.logger.info("CPI/PPI数据获取成功")
return True
def render(self) -> Dict[str, Any]:
if self._data is None:
self.fetch_data()
categories = self._data['month'].tolist()
series = {
'CPI(%)': self._data['CPI同比'].round(2).tolist(),
'PPI(%)': self._data['PPI同比'].round(2).tolist()
}
return {
'chart_type': 'line_markers',
'categories': categories,
'series': series,
'dataframe': self._data,
'anchor': 'chart_cpi',
'title': 'CPI与PPI走势'
}