态势感知平台-武汉市开源生态建设-中国城市开源项目数量对比接口对接
This commit is contained in:
@@ -311,7 +311,7 @@ import * as echarts from 'echarts';
|
||||
import { usePageResize } from '@/utils/hooks/usePageResize';
|
||||
import StatsBar from './components/StatsBar.vue';
|
||||
import HarmonyEcoCharts from './components/HarmonyEcoCharts.vue';
|
||||
import { wuhanGithubProjectsPage3 } from '@/api/jyh/situation';
|
||||
import { wuhanGithubProjectsPage3, cityProjectPage3 } from '@/api/jyh/situation';
|
||||
|
||||
const { widthType } = usePageResize();
|
||||
|
||||
@@ -395,6 +395,35 @@ const fetchGithubProjects = async() => {
|
||||
}
|
||||
};
|
||||
|
||||
// 中国城市开源项目数量备用数据
|
||||
const setCityProjectDefaultData = () => {
|
||||
chartData.value.cityProject.xAxis = ['北京', '上海', '深圳', '杭州', '广州', '成都', '武汉', '南京', '西安', '重庆'];
|
||||
chartData.value.cityProject.data = [757259, 678614, 343417, 315406, 177003, 168300, 120827, 111593, 58678, 56564];
|
||||
isEmpty.value.cityProject = false;
|
||||
};
|
||||
|
||||
// 获取中国城市开源项目数量数据
|
||||
const fetchCityProjectData = async() => {
|
||||
try {
|
||||
const response = await cityProjectPage3();
|
||||
const data = response.data;
|
||||
if (data?.code === 200 && data?.data) {
|
||||
// 更新图表数据
|
||||
chartData.value.cityProject.xAxis = data.data.map(item => item.name);
|
||||
chartData.value.cityProject.data = data.data.map(item => item.data);
|
||||
|
||||
// 设置非空状态
|
||||
isEmpty.value.cityProject = false;
|
||||
} else {
|
||||
console.error('获取中国城市开源项目数量数据失败:', data?.msg || '未知错误');
|
||||
setCityProjectDefaultData();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('请求中国城市开源项目数量数据时发生错误:', error);
|
||||
setCityProjectDefaultData();
|
||||
}
|
||||
};
|
||||
|
||||
const activeTab = ref(0);
|
||||
|
||||
const excellentProjects = ref([
|
||||
@@ -488,8 +517,8 @@ const developerNames = ['白纯骢', '陆红旭', '慕冬亮', '张继德', '蒋
|
||||
// 图表数据
|
||||
const chartData = ref({
|
||||
cityProject: {
|
||||
xAxis: ['北京', '上海', '深圳', '杭州', '广州', '成都', '武汉', '南京', '西安', '重庆'],
|
||||
data: [757259, 678614, 343417, 315406, 177003, 168300, 120827, 111593, 58678, 56564]
|
||||
xAxis: [],
|
||||
data: []
|
||||
},
|
||||
talent: {
|
||||
xAxis: ['北京', '上海', '广州', '深圳', '成都', '杭州', '武汉', '南京', '郑州', '长沙'],
|
||||
@@ -672,6 +701,7 @@ const initCommunityRankChart = () => {
|
||||
const el = document.getElementById('communityRankChart');
|
||||
if (!el) return;
|
||||
const myChart = echarts.init(el);
|
||||
chartInstances.value.communityRank = myChart;
|
||||
myChart.setOption({
|
||||
tooltip: { trigger: 'axis', valueFormatter: (val: any) => val + ' 个' },
|
||||
grid: { left: '3%', right: '4%', bottom: '15px', top: '22%', containLabel: true },
|
||||
@@ -797,8 +827,9 @@ watch(widthType, () => {
|
||||
init();
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchGithubProjects(); // 先获取数据
|
||||
onMounted(async() => {
|
||||
await fetchGithubProjects();
|
||||
await fetchCityProjectData(); // 获取城市项目数据
|
||||
init(); // 再初始化图表
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user