样式微调

This commit is contained in:
ljx 2025-04-17 11:30:26 +08:00
parent f5ab5c09b4
commit 63ff05e0da
4 changed files with 55 additions and 85 deletions

View File

@ -217,90 +217,32 @@ export default {
}, },
// mounted() // mounted()
mounted() { mounted() {
this.createData();
this.initRightChart(); this.initRightChart();
this.initGaugeCharts(); this.initGaugeCharts();
}, },
// methods // methods
methods: { methods: {
createData() {
// %
const rawData = this.rightData.map(item=>{return item.value});
const categories = this.rightData.map(item=>{return item.name});
// 10%
const generateStackData = (value) => {
const segments = [];
let remaining = value;
for (let i = 0; i < 10; i++) { // 10 100%
const segmentValue = remaining >= 10 ? 10 : remaining;
if (segmentValue <= 0) break;
segments.push(segmentValue);
remaining -= segmentValue;
}
return segments;
};
//
const series = [];
for (let i = 0; i < 10; i++) { // 10
series.push({
type: 'bar',
stack: 'total', //
data: rawData.map(value => {
const segments = generateStackData(value);
return i < segments.length ? segments[i] : 0; // 0
}), //
barWidth: '40%', // 40% ,
itemStyle: {
color: `rgba(135, 206, 235, ${i * 0.1+0.2})`, // ,
borderColor: 'transparent',
borderWidth: 3,
},
barGap: '0%', //
barCategoryGap: '20%' //
});
}
var myChart = echarts.init(document.getElementById('echarts-new'));
this.option = {
xAxis: {
type: 'category',
data: categories,
axisLabel: {
fontSize: 23, // Y
color: '#fff', //
fontWight:'bold',
interval: 0 //
},
},
yAxis: {
type: 'value',
max: 100,
axisLine: { show: true },
splitLine: {
show: false, // y 线
},
axisLabel: {
fontSize: 25, // Y
color: '#fff', //
fontWight:'bold',
formatter: '{value}%' // %
},
},
series: series
}
myChart.setOption(this.option);
},
// y // y
initRightChart() { initRightChart() {
const chart = echarts.init(document.getElementById('right-echarts-new')); const chart = echarts.init(document.getElementById('right-echarts-new'));
const option = { const option = {
legend: {
icon: 'rect',
itemWidth: 20,
itemHeight: 20,
itemGap: 40,
data: ['合格率目标'],
textStyle: {
color: '#fff',
fontSize: 20,
fontWight:'bold'
}
},
grid: { grid: {
top: '10%', top: '15%',
left: '5%', left: '5%',
right: '5%', right: '5%',
bottom: '5%', bottom: '0%',
containLabel: true containLabel: true
}, },
xAxis: { xAxis: {
@ -308,7 +250,7 @@ export default {
data: this.rightChartData.map(item => item.name), data: this.rightChartData.map(item => item.name),
axisLabel: { axisLabel: {
color: '#fff', color: '#fff',
fontSize: 16, fontSize: 20,
rotate: 30 rotate: 30
}, },
axisLine: { axisLine: {
@ -354,7 +296,22 @@ export default {
color: '#fff', color: '#fff',
fontSize: 18 fontSize: 18
} }
}] },
// 线
{
name: '合格率目标',
type: 'line',
data: [98, 98, 98, 98, 98, 98,98],
symbolSize: 10,
itemStyle: {
color: '#FFA500' // 线
},
lineStyle: {
width: 3,
type: 'solid'
}
}
]
}; };
chart.setOption(option); chart.setOption(option);
}, },
@ -367,6 +324,7 @@ export default {
this.initGaugeChart('gauge-chart-3', this.middleTopData.wholePassRate); this.initGaugeChart('gauge-chart-3', this.middleTopData.wholePassRate);
}, },
// //
// initGaugeChart
initGaugeChart(id, value) { initGaugeChart(id, value) {
const chart = echarts.init(document.getElementById(id)); const chart = echarts.init(document.getElementById(id));
const option = { const option = {
@ -396,7 +354,7 @@ export default {
width: 10, width: 10,
offsetCenter: [0, '-40%'], offsetCenter: [0, '-40%'],
itemStyle: { itemStyle: {
color: '#fff' color: value < 90 ? '#FF0000' : '#fff' // 90
} }
}, },
axisTick: { axisTick: {
@ -436,7 +394,7 @@ export default {
#right-echarts-new { #right-echarts-new {
width: 100%; width: 100%;
padding: 40px 20px 0 0; padding: 40px 20px 0 0;
height: calc(100% - 120px); height: calc(100% - 80px);
} }
#left-rankchart { #left-rankchart {
width: 100%; width: 100%;
@ -481,7 +439,8 @@ export default {
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
color: #fff; color: #fff;
font-size: 16px; font-size: 20px;
font-weight: bold;
} }
} }
} }
@ -511,14 +470,14 @@ export default {
justify-content: center; justify-content: center;
.inspection-title { .inspection-title {
font-size: 25px; font-size: 28px;
color: #fff; color: #fff;
font-weight: bold; font-weight: bold;
margin-bottom: 10px; margin-bottom: 10px;
} }
.inspection-value { .inspection-value {
font-size: 36px; font-size: 40px;
color: #08e5ff; color: #08e5ff;
font-weight: bold; font-weight: bold;
} }

View File

@ -43,9 +43,19 @@ export default {
}, },
methods: { methods: {
createData() { createData() {
const dates = getCurrentMonthDates();
const today = new Date();
const currentDay = today.getDate();
// 0
const generateData = () => {
return dates.map((date, index) => {
const day = parseInt(date.split('-')[1]);
return day <= currentDay ? (Math.random() * 10).toFixed(2) : 0;
});
};
var myChart = echarts.init(document.getElementById(this.pieId)); var myChart = echarts.init(document.getElementById(this.pieId));
console.log(myChart)
this.option = { this.option = {
title: { title: {
// text: '', // text: '',
@ -124,7 +134,7 @@ export default {
name: '反白', name: '反白',
type: 'line', type: 'line',
smooth: true, smooth: true,
data: Array.from({length: getCurrentMonthDates().length}, () => (Math.random() * 10).toFixed(2)), data: generateData(),
lineStyle: { width: 4 }, lineStyle: { width: 4 },
symbolSize: 12, symbolSize: 12,
}, },

View File

@ -48,7 +48,7 @@ export default {
}, },
createData() { createData() {
// % // %
const rawData = [85, 92, 78, 95, 88, 90]; // P1-P6 const rawData = [95, 92, 98, 95, 98, 90]; // P1-P6
// 10% // 10%
const generateStackData = (value) => { const generateStackData = (value) => {
@ -126,7 +126,7 @@ export default {
{ {
name: '合格率目标', name: '合格率目标',
type: 'line', type: 'line',
data: [80, 85, 83, 77, 85, 79], data: [98, 98, 98, 98, 98, 98],
symbolSize: 10, symbolSize: 10,
itemStyle: { itemStyle: {
color: '#FFA500' // 线 color: '#FFA500' // 线

View File

@ -73,6 +73,7 @@
this.option = { this.option = {
title: { title: {
text: '本月不良指标数', text: '本月不良指标数',
top: '0',
left: 'center', left: 'center',
textStyle: { textStyle: {
color: '#fff', color: '#fff',
@ -87,7 +88,7 @@
splitNumber: 4, splitNumber: 4,
axisName: { axisName: {
color: '#fff', color: '#fff',
fontSize: 20 // 14px20px fontSize: 25 // 14px20px
}, },
splitArea: { splitArea: {
show: false, show: false,