项目报表修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
264f00f5a8
commit
040814c3d6
|
|
@ -33,7 +33,7 @@
|
||||||
import BaseContainer from '@/components/BaseContainer'
|
import BaseContainer from '@/components/BaseContainer'
|
||||||
let echarts = require('echarts/lib/echarts');
|
let echarts = require('echarts/lib/echarts');
|
||||||
|
|
||||||
// require('echarts/lib/chart/line');
|
require('echarts/lib/component/markLine');
|
||||||
require('echarts/lib/chart/funnel');
|
require('echarts/lib/chart/funnel');
|
||||||
require('echarts/lib/chart/bar');
|
require('echarts/lib/chart/bar');
|
||||||
// 按需引入组件
|
// 按需引入组件
|
||||||
|
|
@ -158,7 +158,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
data: obj.legendData
|
data: obj.legendData,
|
||||||
|
bottom: 0
|
||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
|
|
@ -262,7 +263,9 @@ export default {
|
||||||
type: 'shadow'
|
type: 'shadow'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
legend: {},
|
legend: {
|
||||||
|
bottom: 0
|
||||||
|
},
|
||||||
xAxis: [
|
xAxis: [
|
||||||
{
|
{
|
||||||
type: 'category',
|
type: 'category',
|
||||||
|
|
@ -306,16 +309,17 @@ export default {
|
||||||
let obj2 = {
|
let obj2 = {
|
||||||
xAxisData: [],
|
xAxisData: [],
|
||||||
seriesData: [],
|
seriesData: [],
|
||||||
|
medianValue: 0,
|
||||||
unit: this.$t("trials:reportForms:cjart:unit:DaysDiff"),
|
unit: this.$t("trials:reportForms:cjart:unit:DaysDiff"),
|
||||||
titleText: this.$t("trials:reportForms:cjart:title:dataDistribution"),
|
titleText: this.$t("trials:reportForms:cjart:title:dataDistribution"),
|
||||||
}
|
}
|
||||||
if (OtherInfo.PDList && OtherInfo.PDList.length > 0) {
|
if (OtherInfo.PDList && OtherInfo.PDList.length > 0) {
|
||||||
OtherInfo.PDList.forEach(item => {
|
OtherInfo.PDList.forEach(item => {
|
||||||
obj.xAxisData.push(item.SubjectCode)
|
obj2.xAxisData.push(item.SubjectCode)
|
||||||
obj.seriesData.push(item.DaysDiff)
|
obj2.seriesData.push(item.DaysDiff)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
obj2.medianValue = this.calculateMedian(obj2.seriesData)
|
||||||
this.initChart_bottom(obj)
|
this.initChart_bottom(obj)
|
||||||
this.initChart_bottom_right(obj2)
|
this.initChart_bottom_right(obj2)
|
||||||
}
|
}
|
||||||
|
|
@ -373,29 +377,56 @@ export default {
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data: obj.xAxisData
|
data: obj.xAxisData
|
||||||
|
// data: ['aaa', 'bbb', 'ccc']
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
name: obj.unit,
|
name: obj.unit,
|
||||||
type: 'value'
|
type: 'value'
|
||||||
},
|
},
|
||||||
series: [
|
series: {
|
||||||
{
|
markLine: {
|
||||||
markLine: {
|
// symbol: ['none', 'none'], // 隐藏标记线两端的箭头
|
||||||
data: [
|
label: {
|
||||||
{
|
show: true,
|
||||||
type: 'average', name: this.$t("trials:reportForms:cjart:data:average")
|
position: 'end', // 将标签显示在线的起点
|
||||||
}
|
formatter: `${this.$t('trials:reportForms:cjart:data:median')}: {c}` // 使用 {c} 自动显示 yAxis 的值
|
||||||
]
|
|
||||||
},
|
},
|
||||||
data: obj.seriesData,
|
data: [
|
||||||
type: 'bar',
|
{
|
||||||
barWidth: 20,
|
name: this.$t('trials:reportForms:cjart:data:median'),
|
||||||
}
|
// yAxis 的值设置为我们计算出的中位数
|
||||||
]
|
yAxis: obj.medianValue,
|
||||||
|
lineStyle: {
|
||||||
|
type: 'dashed', // 设置为虚线
|
||||||
|
color: this.color[7]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
data: obj.seriesData,
|
||||||
|
// data: [1, 2, 3],
|
||||||
|
type: 'bar',
|
||||||
|
barWidth: 20,
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
// 4. 使用配置项渲染图表
|
// 4. 使用配置项渲染图表
|
||||||
this.chart_bottom_right.setOption(option);
|
this.chart_bottom_right.setOption(option);
|
||||||
},
|
},
|
||||||
|
calculateMedian(numbers) {
|
||||||
|
// 1. 创建副本并排序
|
||||||
|
const sorted = [...numbers].sort((a, b) => a - b);
|
||||||
|
const middle = Math.floor(sorted.length / 2);
|
||||||
|
|
||||||
|
// 2. 判断数组长度是奇数还是偶数
|
||||||
|
if (sorted.length % 2 === 0) {
|
||||||
|
// 偶数长度:取中间两个数的平均值
|
||||||
|
return (sorted[middle - 1] + sorted[middle]) / 2;
|
||||||
|
} else {
|
||||||
|
// 奇数长度:直接取中间的数
|
||||||
|
return sorted[middle];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue