Browse Source

fix:图表Y轴修改

master
guoapeng 3 days ago
parent
commit
e04c28bc16
  1. 16
      src/components/home/LineChart.vue
  2. 4
      src/views/home/chart.vue

16
src/components/home/LineChart.vue

@ -31,6 +31,8 @@ watch(
}, },
grid: { grid: {
top: 100, top: 100,
left: 100,
right: 100,
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -80,11 +82,17 @@ watch(
yAxis: [ yAxis: [
{ {
type: 'value', type: 'value',
name: '温/湿度',
name: 'H₂O₂浓度',
// nameRotate: 90, // yname90 使
// nameGap: 50, // yname线
nameLocation: 'end', // ynamey
}, },
{ {
type: 'value', type: 'value',
name: 'H₂O₂浓度/相对饱和度',
name: '温度/相对湿度/H₂O₂相对饱和度',
// nameRotate: 90, // yname90 使
// nameGap: 50, // yname线
// nameLocation: 'start', // ynamey
}, },
], ],
series: [ series: [
@ -94,6 +102,7 @@ watch(
data: newValue.data?.map(item => item.temp.toFixed(2)), data: newValue.data?.map(item => item.temp.toFixed(2)),
symbol: 'circle', symbol: 'circle',
symbolSize: 2, symbolSize: 2,
yAxisIndex: 1,
lineStyle: { lineStyle: {
color: '#1e90ff', color: '#1e90ff',
width: 1, width: 1,
@ -105,6 +114,7 @@ watch(
data: newValue.data?.map(item => item.rh.toFixed(2)), data: newValue.data?.map(item => item.rh.toFixed(2)),
symbol: 'circle', symbol: 'circle',
symbolSize: 2, symbolSize: 2,
yAxisIndex: 1,
lineStyle: { lineStyle: {
color: '#32cd32', color: '#32cd32',
width: 1, width: 1,
@ -116,7 +126,7 @@ watch(
data: newValue.data?.map(item => item.h2o2.toFixed(2)), data: newValue.data?.map(item => item.h2o2.toFixed(2)),
symbol: 'circle', symbol: 'circle',
symbolSize: 2, symbolSize: 2,
yAxisIndex: 1,
lineStyle: { lineStyle: {
color: '#ffd700', color: '#ffd700',
width: 1, width: 1,

4
src/views/home/chart.vue

@ -213,14 +213,14 @@ const formatSeconds = (seconds: number) => {
v-loading="chartLoading" v-loading="chartLoading"
element-loading-background="rgba(255, 255, 255, 0.1)" element-loading-background="rgba(255, 255, 255, 0.1)"
class="line-chart-content" class="line-chart-content"
:style="{ 'grid-template-columns': `repeat(${chartList.length},1fr)` }"
:style="{ 'grid-template-columns': `repeat(${Math.max(chartList.length, 2)},1fr)` }"
> >
<LineChart <LineChart
v-for="(item, index) in chartList" v-for="(item, index) in chartList"
ref="chartRefs" ref="chartRefs"
:key="index" :key="index"
class="chart-box" class="chart-box"
:style="{ width: `calc(100% / ${chartList.length} - 10px)` }"
:style="{ width: `calc(100% / ${Math.max(chartList.length, 2)} - 10px)` }"
:env-data="item" :env-data="item"
/> />
</div> </div>

Loading…
Cancel
Save