index.html 20 KB

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