feat: 问卷分析页面功能实现
- 修复路径别名问题 - 添加问卷类型映射工具 - 实现饼图数据格式化功能 - 优化图表组件传参方式 - 重构分析信息展示组件
This commit is contained in:
@@ -9,27 +9,27 @@ const pieChart = ref();
|
||||
/**
|
||||
* 定义数据集
|
||||
*/
|
||||
const series = ref<dataOption[]>([
|
||||
{
|
||||
name: 'Access From',
|
||||
type: 'pie',
|
||||
radius: '50%',
|
||||
data: [
|
||||
{ value: 1048, name: 'Search Engine' },
|
||||
{ value: 735, name: 'Direct' },
|
||||
{ value: 580, name: 'Email' },
|
||||
{ value: 484, name: 'Union Ads' },
|
||||
{ value: 300, name: 'Video Ads' }
|
||||
],
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
// const series = ref<dataOption[]>([
|
||||
// {
|
||||
// name: 'Access From',
|
||||
// type: 'pie',
|
||||
// radius: '50%',
|
||||
// data: [
|
||||
// { value: 1048, name: 'Search Engine' },
|
||||
// { value: 735, name: 'Direct' },
|
||||
// { value: 580, name: 'Email' },
|
||||
// { value: 484, name: 'Union Ads' },
|
||||
// { value: 300, name: 'Video Ads' }
|
||||
// ],
|
||||
// emphasis: {
|
||||
// itemStyle: {
|
||||
// shadowBlur: 10,
|
||||
// shadowOffsetX: 0,
|
||||
// shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ]);
|
||||
|
||||
/**
|
||||
* 饼图的 option
|
||||
@@ -38,18 +38,18 @@ const option = ref(pieOption);
|
||||
|
||||
function useSetPieChart(
|
||||
dom: Readonly<ShallowRef<HTMLSpanElement | null>>,
|
||||
data: any[],
|
||||
series: any,
|
||||
opts: optsType = {}
|
||||
): void {
|
||||
for (let item in opts) {
|
||||
if (!series) return;
|
||||
for (const item in opts) {
|
||||
if (item === 'legend') !opts[item] && deleteLegend();
|
||||
else if (item === 'title') !opts[item] && deleteTitle();
|
||||
}
|
||||
|
||||
// 检测边界范围 dom 和 data 是否存在
|
||||
onMounted(() => {
|
||||
// console.log(dom);
|
||||
if (!dom || data.length === 0) return;
|
||||
if (!dom || series.data.length === 0) return;
|
||||
// 在 dom 挂载之后,显示饼图
|
||||
pieChart.value = chart.init(dom.value);
|
||||
pieChart.value.setOption(option.value, opts);
|
||||
|
||||
Reference in New Issue
Block a user