index.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>图表生成器 - 快速创建专业数据可视化</title>
  7. <link rel="stylesheet" href="style.css">
  8. <link rel="icon" href="chart-icon.svg" type="image/svg+xml">
  9. <!-- 引入Chart.js及其插件 (改为本地引用) -->
  10. <script src="lib/chart.min.js"></script>
  11. <!-- 引入html2canvas库用于导出图片 (改为本地引用) -->
  12. <script src="lib/html2canvas.min.js"></script>
  13. <!-- 引入XLSX库用于解析Excel文件 (改为本地引用) -->
  14. <script src="lib/xlsx.full.min.js"></script>
  15. <!-- 引入Hammer.js用于图表交互 (改为本地引用) -->
  16. <script src="lib/hammer.min.js"></script>
  17. <!-- 引入Chart.js缩放插件 (改为本地引用) -->
  18. <script src="lib/chartjs-plugin-zoom.min.js"></script>
  19. <!-- 引入Chart.js数据标签插件 -->
  20. <script src="lib/chartjs-plugin-datalabels.min.js"></script>
  21. <script type="text/javascript" src="../static/vendor/evalCore.min.js"></script>
  22. </head>
  23. <body>
  24. <div class="wrapper" id="pageContainer">
  25. <div class="page-header">
  26. <a href="https://www.baidufe.com/fehelper/index/index.html" target="_blank" class="header-link">
  27. <img src="../static/img/fe-16.png" alt="fehelper"/>
  28. <span class="fehelper-text">FeHelper</span>
  29. </a>
  30. <span class="page-title-suffix">:图表生成器</span>
  31. <a href="#" class="x-donate-link"><i class="nav-icon">❤&nbsp;</i>打赏鼓励</a>
  32. <a class="x-other-tools"><i class="icon-plus-circle"></i> 探索更多实用工具 <span class="tool-market-badge">工具市场</span></a>
  33. </div>
  34. </div>
  35. <main class="container">
  36. <div class="app-container">
  37. <!-- 左侧面板:数据输入区 -->
  38. <div class="sidebar">
  39. <div class="panel">
  40. <h2>数据输入</h2>
  41. <div class="input-group">
  42. <label>数据输入方式</label>
  43. <div class="input-methods">
  44. <label><input type="radio" name="data-input-method" value="manual" checked> 手动录入</label>
  45. <label><input type="radio" name="data-input-method" value="upload-csv"> 上传Excel/CSV</label>
  46. </div>
  47. </div>
  48. <div class="input-group" id="manual-format-container" style="display: none;">
  49. <label for="manual-format">选择数据格式</label>
  50. <select id="manual-format">
  51. <option value="simple">简单数据 (标签,数值)</option>
  52. <option value="series">系列数据 (多组)</option>
  53. <option value="csv">CSV格式</option>
  54. </select>
  55. </div>
  56. <div class="input-group" id="simple-data-container">
  57. <label for="data-input">输入数据 (每行一条,格式: 标签,数值)</label>
  58. <textarea id="data-input" rows="8" placeholder="产品A,120&#10;产品B,80&#10;产品C,60&#10;产品D,40&#10;产品E,30"></textarea>
  59. </div>
  60. <div class="input-group" id="series-data-container" style="display: none;">
  61. <label for="series-data-input">输入系列数据 (每行一个系列,格式: 系列名,值1,值2...)</label>
  62. <textarea id="series-data-input" rows="8" placeholder="一季度,120,80,60,40,30&#10;二季度,130,70,65,45,35&#10;三季度,140,90,55,48,38"></textarea>
  63. <label for="series-labels">标签 (逗号分隔)</label>
  64. <input type="text" id="series-labels" placeholder="产品A,产品B,产品C,产品D,产品E">
  65. </div>
  66. <div class="input-group" id="csv-data-container" style="display: none;">
  67. <label for="csv-data-input">粘贴CSV数据 (首行为标题)</label>
  68. <textarea id="csv-data-input" rows="8" placeholder="类别,一季度,二季度,三季度&#10;产品A,120,130,140&#10;产品B,80,70,90&#10;产品C,60,65,55&#10;产品D,40,45,48"></textarea>
  69. <div class="csv-options">
  70. <label>
  71. <input type="checkbox" id="first-row-header" checked>
  72. 第一行为标题
  73. </label>
  74. <label>
  75. <input type="checkbox" id="first-col-labels" checked>
  76. 第一列为标签
  77. </label>
  78. </div>
  79. </div>
  80. <div class="input-group">
  81. <input type="file" id="file-upload" accept=".csv, .xlsx">
  82. <label for="file-upload">选择CSV/Excel文件</label>
  83. </div>
  84. <div class="input-group">
  85. <button id="generate-btn" class="btn btn-primary">生成图表</button>
  86. <button id="sample-data-btn" class="btn btn-secondary">加载样例数据</button>
  87. </div>
  88. </div>
  89. <div class="panel">
  90. <h2>图表设置</h2>
  91. <input type="hidden" id="chart-type" value="bar">
  92. <div class="input-group">
  93. <label for="chart-title">图表标题</label>
  94. <input type="text" id="chart-title" placeholder="图表标题">
  95. </div>
  96. <div class="input-group">
  97. <label for="x-axis-label">X轴标签</label>
  98. <input type="text" id="x-axis-label" placeholder="X轴标签">
  99. </div>
  100. <div class="input-group">
  101. <label for="y-axis-label">Y轴标签</label>
  102. <input type="text" id="y-axis-label" placeholder="Y轴标签">
  103. </div>
  104. <div class="input-group">
  105. <label for="color-scheme">颜色方案</label>
  106. <select id="color-scheme">
  107. <option value="default">默认方案</option>
  108. <option value="pastel">柔和色系</option>
  109. <option value="bright">明亮色系</option>
  110. <option value="cool">冷色调</option>
  111. <option value="warm">暖色调</option>
  112. <option value="corporate">企业风格</option>
  113. <option value="contrast">高对比度</option>
  114. <option value="rainbow">彩虹色系</option>
  115. <option value="earth">大地色系</option>
  116. <option value="ocean">海洋色系</option>
  117. <option value="vintage">复古色系</option>
  118. </select>
  119. </div>
  120. <div class="input-group">
  121. <label for="legend-position">图例位置</label>
  122. <select id="legend-position">
  123. <option value="top">顶部</option>
  124. <option value="right">右侧</option>
  125. <option value="bottom">底部</option>
  126. <option value="left">左侧</option>
  127. <option value="none">不显示</option>
  128. </select>
  129. </div>
  130. <div class="input-group checkbox-group">
  131. <!-- 删除"显示网格线"和"启用动画"复选框 -->
  132. </div>
  133. </div>
  134. </div>
  135. <!-- 右侧面板:图表显示区域 -->
  136. <div class="main-content">
  137. <div class="chart-container">
  138. <div class="chart-actions">
  139. <div class="checkbox-group" style="text-align: left;">
  140. <label><input type="checkbox" id="show-grid-lines" checked> 显示网格线</label>
  141. <label><input type="checkbox" id="animate-chart" checked> 启用动画</label>
  142. </div>
  143. <button id="export-png-btn" class="btn btn-primary" disabled>导出PNG</button>
  144. <button id="export-jpg-btn" class="btn btn-primary" disabled>导出JPG</button>
  145. <button id="copy-img-btn" class="btn btn-secondary" disabled>复制图像</button>
  146. </div>
  147. <div id="chart-wrapper">
  148. <canvas id="chart-canvas"></canvas>
  149. </div>
  150. <div class="chart-type-gallery">
  151. <h3>图表类型选择</h3>
  152. <div class="chart-type-scroller">
  153. <div class="chart-type-group">
  154. <h4>基础图表</h4>
  155. <div class="chart-type-items">
  156. <div class="chart-type-item" data-chart-type="bar">
  157. <svg width="60" height="60" viewBox="0 0 60 60">
  158. <rect x="10" y="10" width="8" height="40" fill="#4e73df" />
  159. <rect x="26" y="20" width="8" height="30" fill="#4e73df" />
  160. <rect x="42" y="30" width="8" height="20" fill="#4e73df" />
  161. </svg>
  162. <span>柱状图</span>
  163. </div>
  164. <div class="chart-type-item" data-chart-type="horizontalBar">
  165. <svg width="60" height="60" viewBox="0 0 60 60">
  166. <rect x="10" y="10" width="40" height="8" fill="#4e73df" />
  167. <rect x="10" y="26" width="30" height="8" fill="#4e73df" />
  168. <rect x="10" y="42" width="20" height="8" fill="#4e73df" />
  169. </svg>
  170. <span>水平柱状图</span>
  171. </div>
  172. <div class="chart-type-item" data-chart-type="line">
  173. <svg width="60" height="60" viewBox="0 0 60 60">
  174. <polyline points="10,45 25,15 40,30 55,10" stroke="#4e73df" stroke-width="2" fill="none" />
  175. <circle cx="10" cy="45" r="3" fill="#4e73df" />
  176. <circle cx="25" cy="15" r="3" fill="#4e73df" />
  177. <circle cx="40" cy="30" r="3" fill="#4e73df" />
  178. <circle cx="55" cy="10" r="3" fill="#4e73df" />
  179. </svg>
  180. <span>折线图</span>
  181. </div>
  182. <div class="chart-type-item" data-chart-type="area">
  183. <svg width="60" height="60" viewBox="0 0 60 60">
  184. <path d="M10,45 L25,15 L40,30 L55,10 L55,50 L10,50 Z" fill="#4e73df" opacity="0.3" />
  185. <polyline points="10,45 25,15 40,30 55,10" stroke="#4e73df" stroke-width="2" fill="none" />
  186. <circle cx="10" cy="45" r="3" fill="#4e73df" />
  187. <circle cx="25" cy="15" r="3" fill="#4e73df" />
  188. <circle cx="40" cy="30" r="3" fill="#4e73df" />
  189. <circle cx="55" cy="10" r="3" fill="#4e73df" />
  190. </svg>
  191. <span>面积图</span>
  192. </div>
  193. </div>
  194. </div>
  195. <div class="chart-type-group">
  196. <h4>饼图/环形图</h4>
  197. <div class="chart-type-items">
  198. <div class="chart-type-item" data-chart-type="pie">
  199. <svg width="60" height="60" viewBox="0 0 60 60">
  200. <path d="M30,30 L30,5 A25,25 0 0,1 55,30 Z" fill="#4e73df" />
  201. <path d="M30,30 L55,30 A25,25 0 0,1 30,55 Z" fill="#1cc88a" />
  202. <path d="M30,30 L30,55 A25,25 0 0,1 5,30 Z" fill="#36b9cc" />
  203. <path d="M30,30 L5,30 A25,25 0 0,1 30,5 Z" fill="#f6c23e" />
  204. </svg>
  205. <span>饼图</span>
  206. </div>
  207. <div class="chart-type-item" data-chart-type="doughnut">
  208. <svg width="60" height="60" viewBox="0 0 60 60">
  209. <path d="M30,30 L30,5 A25,25 0 0,1 55,30 L45,30 A15,15 0 0,0 30,15 Z" fill="#4e73df" />
  210. <path d="M30,30 L55,30 A25,25 0 0,1 30,55 L30,45 A15,15 0 0,0 45,30 Z" fill="#1cc88a" />
  211. <path d="M30,30 L30,55 A25,25 0 0,1 5,30 L15,30 A15,15 0 0,0 30,45 Z" fill="#36b9cc" />
  212. <path d="M30,30 L5,30 A25,25 0 0,1 30,5 L30,15 A15,15 0 0,0 15,30 Z" fill="#f6c23e" />
  213. </svg>
  214. <span>环形图</span>
  215. </div>
  216. <div class="chart-type-item" data-chart-type="polarArea">
  217. <svg width="60" height="60" viewBox="0 0 60 60">
  218. <path d="M30,30 L30,10 A20,20 0 0,1 50,30 Z" fill="#4e73df" />
  219. <path d="M30,30 L50,30 A20,20 0 0,1 30,50 Z" fill="#1cc88a" />
  220. <path d="M30,30 L30,50 A20,20 0 0,1 10,30 Z" fill="#36b9cc" />
  221. <path d="M30,30 L10,30 A20,20 0 0,1 30,10 Z" fill="#f6c23e" />
  222. </svg>
  223. <span>极地面积图</span>
  224. </div>
  225. </div>
  226. </div>
  227. <div class="chart-type-group">
  228. <h4>高级图表</h4>
  229. <div class="chart-type-items">
  230. <div class="chart-type-item" data-chart-type="scatter">
  231. <svg width="60" height="60" viewBox="0 0 60 60">
  232. <circle cx="15" cy="20" r="3" fill="#4e73df" />
  233. <circle cx="25" cy="40" r="3" fill="#4e73df" />
  234. <circle cx="35" cy="15" r="3" fill="#4e73df" />
  235. <circle cx="45" cy="30" r="3" fill="#4e73df" />
  236. <circle cx="20" cy="45" r="3" fill="#4e73df" />
  237. </svg>
  238. <span>散点图</span>
  239. </div>
  240. <div class="chart-type-item" data-chart-type="radar">
  241. <svg width="60" height="60" viewBox="0 0 60 60">
  242. <polygon points="30,10 45,20 40,40 20,40 15,20" stroke="#4e73df" stroke-width="1" fill="#4e73df" fill-opacity="0.2" />
  243. <line x1="30" y1="30" x2="30" y2="10" stroke="#ccc" />
  244. <line x1="30" y1="30" x2="45" y2="20" stroke="#ccc" />
  245. <line x1="30" y1="30" x2="40" y2="40" stroke="#ccc" />
  246. <line x1="30" y1="30" x2="20" y2="40" stroke="#ccc" />
  247. <line x1="30" y1="30" x2="15" y2="20" stroke="#ccc" />
  248. </svg>
  249. <span>雷达图</span>
  250. </div>
  251. <div class="chart-type-item" data-chart-type="bubble">
  252. <svg width="60" height="60" viewBox="0 0 60 60">
  253. <circle cx="15" cy="25" r="5" fill="#4e73df" fill-opacity="0.7" />
  254. <circle cx="30" cy="15" r="7" fill="#4e73df" fill-opacity="0.7" />
  255. <circle cx="45" cy="35" r="4" fill="#4e73df" fill-opacity="0.7" />
  256. <circle cx="25" cy="45" r="6" fill="#4e73df" fill-opacity="0.7" />
  257. </svg>
  258. <span>气泡图</span>
  259. </div>
  260. <div class="chart-type-item" data-chart-type="stackedBar">
  261. <svg width="60" height="60" viewBox="0 0 60 60">
  262. <rect x="10" y="10" width="8" height="15" fill="#4e73df" />
  263. <rect x="10" y="25" width="8" height="15" fill="#1cc88a" />
  264. <rect x="26" y="20" width="8" height="10" fill="#4e73df" />
  265. <rect x="26" y="30" width="8" height="10" fill="#1cc88a" />
  266. <rect x="42" y="30" width="8" height="5" fill="#4e73df" />
  267. <rect x="42" y="35" width="8" height="5" fill="#1cc88a" />
  268. </svg>
  269. <span>堆叠柱状图</span>
  270. </div>
  271. <div class="chart-type-item" data-chart-type="stackedArea">
  272. <svg width="60" height="60" viewBox="0 0 60 60">
  273. <path d="M10,45 L25,35 L40,30 L55,20 L55,50 L10,50 Z" fill="#4e73df" opacity="0.3" />
  274. <path d="M10,30 L25,20 L40,20 L55,10 L55,20 L40,30 L25,35 L10,45 Z" fill="#1cc88a" opacity="0.3" />
  275. <polyline points="10,30 25,20 40,20 55,10" stroke="#1cc88a" stroke-width="2" fill="none" />
  276. <polyline points="10,45 25,35 40,30 55,20" stroke="#4e73df" stroke-width="2" fill="none" />
  277. </svg>
  278. <span>堆叠面积图</span>
  279. </div>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. <div class="tips-panel">
  286. <h3>使用提示</h3>
  287. <ul>
  288. <li>选择适合您数据的图表类型:数值比较用柱状图,趋势用折线图,占比用饼图</li>
  289. <li>点击图表类型预览图可以直接切换图表</li>
  290. <li>生成图表后可以导出为PNG或JPG格式,方便插入PPT或Word文档</li>
  291. <li>使用"数据标签"功能可以在图表上直接显示数值</li>
  292. <li>尝试不同的颜色方案,为您的报告增添专业感</li>
  293. </ul>
  294. </div>
  295. </div>
  296. </div>
  297. </main>
  298. <script src="main.js"></script>
  299. <script src="chart-generator.js"></script>
  300. </body>
  301. </html>