样式微调

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() {
this.createData();
this.initRightChart();
this.initGaugeCharts();
},
// 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
initRightChart() {
const chart = echarts.init(document.getElementById('right-echarts-new'));
const option = {
legend: {
icon: 'rect',
itemWidth: 20,
itemHeight: 20,
itemGap: 40,
data: ['合格率目标'],
textStyle: {
color: '#fff',
fontSize: 20,
fontWight:'bold'
}
},
grid: {
top: '10%',
top: '15%',
left: '5%',
right: '5%',
bottom: '5%',
bottom: '0%',
containLabel: true
},
xAxis: {
@ -308,7 +250,7 @@ export default {
data: this.rightChartData.map(item => item.name),
axisLabel: {
color: '#fff',
fontSize: 16,
fontSize: 20,
rotate: 30
},
axisLine: {
@ -354,7 +296,22 @@ export default {
color: '#fff',
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);
},
@ -367,6 +324,7 @@ export default {
this.initGaugeChart('gauge-chart-3', this.middleTopData.wholePassRate);
},
//
// initGaugeChart
initGaugeChart(id, value) {
const chart = echarts.init(document.getElementById(id));
const option = {
@ -396,7 +354,7 @@ export default {
width: 10,
offsetCenter: [0, '-40%'],
itemStyle: {
color: '#fff'
color: value < 90 ? '#FF0000' : '#fff' // 90
}
},
axisTick: {
@ -436,7 +394,7 @@ export default {
#right-echarts-new {
width: 100%;
padding: 40px 20px 0 0;
height: calc(100% - 120px);
height: calc(100% - 80px);
}
#left-rankchart {
width: 100%;
@ -481,7 +439,8 @@ export default {
top: 50%;
transform: translateY(-50%);
color: #fff;
font-size: 16px;
font-size: 20px;
font-weight: bold;
}
}
}
@ -511,14 +470,14 @@ export default {
justify-content: center;
.inspection-title {
font-size: 25px;
font-size: 28px;
color: #fff;
font-weight: bold;
margin-bottom: 10px;
}
.inspection-value {
font-size: 36px;
font-size: 40px;
color: #08e5ff;
font-weight: bold;
}

View File

@ -43,9 +43,19 @@ export default {
},
methods: {
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));
console.log(myChart)
this.option = {
title: {
// text: '',
@ -124,7 +134,7 @@ export default {
name: '反白',
type: 'line',
smooth: true,
data: Array.from({length: getCurrentMonthDates().length}, () => (Math.random() * 10).toFixed(2)),
data: generateData(),
lineStyle: { width: 4 },
symbolSize: 12,
},

View File

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

View File

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