From 0796eebe3520fafb0ac5d36ee584af81506d7e9c Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期六, 20 九月 2025 14:05:52 +0800 Subject: [PATCH] 2025.9.20 数据产品(待完成) --- src/utils/echart-util.js | 75 +++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 1 deletions(-) diff --git a/src/utils/echart-util.js b/src/utils/echart-util.js index ad12e65..7f907dd 100644 --- a/src/utils/echart-util.js +++ b/src/utils/echart-util.js @@ -69,6 +69,79 @@ }; } +function barChartOption() { + return { + title: { + text: `鏌辩姸鍥鹃粯璁ゅ悕绉癭, + left: 'center' // 鏍囬灞呬腑鏄剧ず + }, + // 娣诲姞宸ュ叿鏍忛厤缃紝鍖呭惈涓嬭浇鍔熻兘 + toolbox: { + show: true, + feature: { + saveAsImage: { + show: true, + title: '涓嬭浇鍥捐〃', + type: 'png', + pixelRatio: 2 // 鎻愰珮鍥剧墖娓呮櫚搴� + } + } + }, + tooltip: { + trigger: 'axis', // 鏌辩姸鍥句娇鐢╝xis瑙﹀彂tooltip + axisPointer: { + type: 'shadow' // 鏄剧ず闃村奖鎸囩ず鍣� + }, + formatter: '{b}: {c}' // 鏄剧ず鏍煎紡锛氬悕绉�: 鏁伴噺 + }, + legend: { + show: true, + orient: 'horizontal', + bottom: '0%', // 鍥句緥搴曢儴姘村钩鎺掑垪 + }, + grid: { + // left: '3%', + // right: '4%', + bottom: '10%', + top: '15%', + containLabel: true + }, + xAxis: { + name: '鍧愭爣杞�', + type: 'category', + data: ['sample1', 'sample2', 'sample3'], // X杞存暟鎹� + axisTick: { + alignWithLabel: true + }, + axisLabel: { + rotate: 45, + } + }, + yAxis: { + type: 'value', + name: '鏁伴噺', // Y杞村悕绉� + axisLine: { + show: true + }, + axisLabel: { + formatter: '{value}' + } + }, + series: [ + { + name: 'sample', + type: 'bar', // 鍥捐〃绫诲瀷鏀逛负鏌辩姸鍥� + data: [100, 200, 300], // 鏁版嵁鍊� + label: { + show: true, + position: 'top', // 鏍囩鏄剧ず鍦ㄦ煴瀛愰《閮� + formatter: '{c}' // 鏍囩鏍煎紡锛氭暟閲� + } + } + ] + }; +} + // 閫氳繃 ECharts API 涓嬭浇鍥剧墖鐨勫嚱鏁� function downloadChartImage(chart, fileName) { if (!chart) return; // 纭繚鍥捐〃宸插垵濮嬪寲 @@ -92,4 +165,4 @@ document.body.removeChild(link); } -export { pieChartOption, downloadChartImage }; +export { pieChartOption, barChartOption, downloadChartImage }; -- Gitblit v1.9.3