Browse Source

综合曲线

master
wally 4 years ago
parent
commit
4f62525ce3
  1. 19
      .idea/workspace.xml
  2. 8
      components/Common/Map.vue
  3. 34
      components/Common/Monitor.vue
  4. 30
      components/DataCenter/Address.vue
  5. 63
      components/DataCenter/ComplexChart.vue
  6. 18
      components/DataCenter/MapContainer.vue
  7. 5
      components/DataCenter/Right.vue
  8. 50
      components/DataCenter/YieldChart.vue
  9. 2
      config/layout/dataCenterBody.js
  10. 3
      package.json
  11. 6
      server/api/datas.ts
  12. 290
      server/mocks/datas.js
  13. 177
      utils/complexChart.js
  14. 202
      utils/complexConfig.js
  15. 9
      utils/map.js
  16. 5
      yarn.lock

19
.idea/workspace.xml

@ -6,12 +6,14 @@
<component name="ChangeListManager">
<list default="true" id="83558921-0a42-4f39-ab1d-d218d98a0f1e" name="变更" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app.vue" beforeDir="false" afterPath="$PROJECT_DIR$/app.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/components/DataCenter/Middle.vue" beforeDir="false" afterPath="$PROJECT_DIR$/components/DataCenter/Middle.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/components/Page/Header.vue" beforeDir="false" afterPath="$PROJECT_DIR$/components/Page/Header.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/components/Common/Map.vue" beforeDir="false" afterPath="$PROJECT_DIR$/components/Common/Map.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/components/DataCenter/ComplexChart.vue" beforeDir="false" afterPath="$PROJECT_DIR$/components/DataCenter/ComplexChart.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/components/DataCenter/MapContainer.vue" beforeDir="false" afterPath="$PROJECT_DIR$/components/DataCenter/MapContainer.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/components/DataCenter/Right.vue" beforeDir="false" afterPath="$PROJECT_DIR$/components/DataCenter/Right.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/components/DataCenter/YieldChart.vue" beforeDir="false" afterPath="$PROJECT_DIR$/components/DataCenter/YieldChart.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/layout/dataCenterBody.js" beforeDir="false" afterPath="$PROJECT_DIR$/config/layout/dataCenterBody.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/nuxt.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/nuxt.config.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/utils/map.js" beforeDir="false" afterPath="$PROJECT_DIR$/utils/map.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/yarn.lock" beforeDir="false" afterPath="$PROJECT_DIR$/yarn.lock" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -22,8 +24,8 @@
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="TypeScript File" />
<option value="Vue Single File Component" />
<option value="TypeScript File" />
<option value="JavaScript File" />
</list>
</option>
@ -61,7 +63,7 @@
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="nodejs_package_manager_path" value="yarn" />
<property name="prettierjs.PrettierConfiguration.Package" value="D:\Demo\vue3\nuxt3-app\node_modules\prettier" />
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.IDE.editor.colors.配色方案字体" />
<property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" />
<property name="ts.external.directory.path" value="C:\Users\Administrator\AppData\Local\JetBrains\Toolbox\apps\WebStorm\ch-1\213.5449.31\plugins\JavaScriptLanguage\jsLanguageServicesImpl\external" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
@ -89,7 +91,10 @@
<workItem from="1637636122018" duration="8300000" />
<workItem from="1637714189695" duration="17290000" />
<workItem from="1637797908551" duration="3913000" />
<workItem from="1637806782564" duration="11877000" />
<workItem from="1637806782564" duration="12090000" />
<workItem from="1637883404061" duration="1422000" />
<workItem from="1637887980805" duration="16198000" />
<workItem from="1637918094972" duration="756000" />
</task>
<servers />
</component>

8
components/Common/Map.vue

@ -7,16 +7,10 @@ import { initOptions } from '@/utils/map';
import { onMounted } from 'vue';
import ShanXiMap from 'config/map/shanxi';
console.log('ShanXiMap: ', ShanXiMap);
//
onMounted(() => {
// console.log(111);
const chartDom = document.getElementById('map');
console.log('chartDom: ', chartDom);
const myChart = echarts.init(chartDom);
// console.log('myChart: ', myChart);
//
echarts.registerMap('shanxi', ShanXiMap);
//
myChart.setOption(initOptions());

34
components/Common/Monitor.vue

@ -0,0 +1,34 @@
<template>
<div class="frame-container">
<iframe
src="https://www.tall.wiki/kangfu/v1/?key=230659446"
frameborder="0"
></iframe>
</div>
</template>
<script>
export default {
name: 'Monitor',
};
</script>
<style scoped>
.frame-container {
position: absolute;
right: 0;
bottom: 0;
width: 275rem;
height: 200rem;
box-sizing: content-box;
background: url('@/assets/images/border-s-2.png') no-repeat center center;
background-size: 100%;
padding: 5rem;
overflow: hidden;
}
iframe {
display: block;
width: 100%;
height: 100%;
}
</style>

30
components/DataCenter/Address.vue

@ -0,0 +1,30 @@
<template>
<div class="address-container">
<img src="../../assets/images/icon-location.png" alt="" />
我的位置山西省 > 太原市 > 晋祠农场
</div>
</template>
<script>
export default {
name: 'Address',
};
</script>
<style scoped>
.address-container {
position: absolute;
left: 0rem;
top: 0rem;
box-shadow: 0 0 9rem #00d9ff inset;
padding: 8rem 16rem;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 14rem;
}
.address-container img {
margin-right: 10rem;
}
</style>

63
components/DataCenter/ComplexChart.vue

@ -1,5 +1,62 @@
<template>综合曲线</template>
<template>
<div id="complex-container"></div>
</template>
<script setup></script>
<script setup>
import { nextTick } from 'vue';
import { generateChartOption } from '@/utils/complexChart';
<style scoped></style>
let myChart = null;
let data = [];
let defaultSelectedLegend = {
'室内温度(℃)': true,
'室外温度(℃)': true,
'土壤温度(℃)': true,
'室内湿度(RH%)': true,
'室外湿度(RH%)': true,
'土壤湿度(RH%)': true,
'风速(m/s)': true,
'CO2(%)': true,
'光照(klux)': true,
};
async function getData() {
try {
const { data: rawData } = await useFetch('/api/datas');
const { code, msg, data } = rawData.value;
if (code === 200) {
await nextTick();
initChart(data);
} else {
throw new Error(msg);
}
} catch (error) {
console.error(error);
}
}
//
function initChart(data) {
const chartDom = document.getElementById('complex-container');
myChart = echarts.init(chartDom);
render(data, defaultSelectedLegend);
myChart.on('legendselectchanged', event => {
defaultSelectedLegend = event.selected;
render(data, event.selected);
});
}
function render(data, selected) {
const option = generateChartOption(data, selected);
option && myChart.setOption(option);
}
getData();
</script>
<style scoped>
#complex-container {
height: 100%;
}
</style>

18
components/DataCenter/MapContainer.vue

@ -1,7 +1,21 @@
<template>
<CommonMap></CommonMap>
<div class="main-container">
<!-- 地图-->
<CommonMap></CommonMap>
<!-- 监控-->
<CommonMonitor></CommonMonitor>
<!-- 地址-->
<DataCenterAddress></DataCenterAddress>
</div>
</template>
<script setup></script>
<style scoped></style>
<style scoped>
.main-container {
position: relative;
width: 100%;
height: 100%;
}
</style>

5
components/DataCenter/Right.vue

@ -29,8 +29,7 @@ import { body } from '@/config/layout/dataCenterBody';
background-position: left top;
background-size: 100% 100%;
background-repeat: no-repeat;
}
.title {
font-weight: bold;
display: flex;
flex-direction: column;
}
</style>

50
components/DataCenter/YieldChart.vue

@ -1,9 +1,47 @@
<template>产量对比</template>
<template>
<div id="yield-chart"></div>
</template>
<script>
export default {
name: 'YieldChart',
};
<script setup>
import { onMounted } from 'vue';
onMounted(() => {
const chartDom = document.getElementById('yield-chart');
const myChart = echarts.init(chartDom);
const option = initOptions();
myChart.setOption(option);
});
function initOptions() {
const option = {
darkMode: true,
grid: {
top: 20,
bottom: 20,
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['2017', '2018', '2019', '2020', '2021'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [224, 218, 135, 147, 260],
type: 'line',
areaStyle: {},
},
],
};
return option;
}
</script>
<style scoped></style>
<style scoped>
#yield-chart {
width: 100%;
height: 100%;
}
</style>

2
config/layout/dataCenterBody.js

@ -62,7 +62,7 @@ export const body = {
align: 'center',
height: '40rem',
},
component: 'ComplexChart',
component: 'DataCenterComplexChart',
},
],
},

3
package.json

@ -13,6 +13,7 @@
"axios": "^0.24.0",
"dayjs": "^1.10.7",
"echarts": "^5.2.2",
"echarts-gl": "^2.0.8"
"echarts-gl": "^2.0.8",
"lodash": "^4.17.21"
}
}

6
server/api/datas.ts

@ -0,0 +1,6 @@
import type { IncomingMessage, ServerResponse } from 'http';
import { datas } from '../mocks/datas';
export default async (req: IncomingMessage, res: ServerResponse) => {
return { code: 200, msg: 'ok', data: datas };
};

290
server/mocks/datas.js

@ -0,0 +1,290 @@
export const datas = [
{
time: '00:00',
roomT: 19,
roomH: 60,
outT: '-5',
outH: 60,
soilT: 6,
soilH: 40,
windSpeed: 0,
co2: '0.01 ',
light: 3,
},
{
time: '01:00',
roomT: 19,
roomH: 70,
outT: '-6',
outH: 70,
soilT: 7,
soilH: 50,
windSpeed: 2,
co2: '0.02 ',
light: 2,
},
{
time: '02:00',
roomT: 19,
roomH: 80,
outT: '-7',
outH: 80,
soilT: 7,
soilH: 60,
windSpeed: 3,
co2: '0.03 ',
light: 1,
},
{
time: '03:00',
roomT: 19,
roomH: 90,
outT: '-8',
outH: 90,
soilT: 7,
soilH: 70,
windSpeed: 7,
co2: '0.04 ',
light: 1,
},
{
time: '04:00',
roomT: 18,
roomH: 100,
outT: '-9',
outH: 100,
soilT: 5,
soilH: 80,
windSpeed: 9,
co2: '0.05 ',
light: 4,
},
{
time: '05:00',
roomT: 18,
roomH: 95,
outT: '-10',
outH: 95,
soilT: 5,
soilH: 75,
windSpeed: 14,
co2: '0.06 ',
light: 8,
},
{
time: '06:00',
roomT: 19,
roomH: 90,
outT: '-5',
outH: 90,
soilT: 7,
soilH: 70,
windSpeed: 12,
co2: '0.07 ',
light: 10,
},
{
time: '07:00',
roomT: 19,
roomH: 85,
outT: '-1',
outH: 85,
soilT: 7,
soilH: 65,
windSpeed: 15,
co2: '0.08 ',
light: 20,
},
{
time: '08:00',
roomT: 20,
roomH: 80,
outT: 0,
outH: 80,
soilT: 10,
soilH: 60,
windSpeed: 13,
co2: '0.09 ',
light: 26,
},
{
time: '09:00',
roomT: 20,
roomH: 75,
outT: 1,
outH: 75,
soilT: 12,
soilH: 55,
windSpeed: 14,
co2: '0.09 ',
light: 35,
},
{
time: '10:00',
roomT: 21,
roomH: 70,
outT: 2,
outH: 70,
soilT: 14,
soilH: 50,
windSpeed: 9,
co2: '0.12 ',
light: 45,
},
{
time: '11:00',
roomT: 21,
roomH: 65,
outT: 3,
outH: 65,
soilT: 16,
soilH: 45,
windSpeed: 5,
co2: '0.14 ',
light: 50,
},
{
time: '12:00',
roomT: 23,
roomH: 60,
outT: 4,
outH: 60,
soilT: 19,
soilH: 40,
windSpeed: 8,
co2: '0.16 ',
light: 55,
},
{
time: '13:00',
roomT: 24,
roomH: 55,
outT: 5,
outH: 55,
soilT: 22,
soilH: 35,
windSpeed: 7,
co2: '0.18 ',
light: 65,
},
{
time: '14:00',
roomT: 28,
roomH: 50,
outT: 6,
outH: 50,
soilT: 23,
soilH: 30,
windSpeed: 6,
co2: '0.20 ',
light: 80,
},
{
time: '15:00',
roomT: 28,
roomH: 45,
outT: 6,
outH: 45,
soilT: 23,
soilH: 25,
windSpeed: 4,
co2: '0.19 ',
light: 70,
},
{
time: '16:00',
roomT: 26,
roomH: 40,
outT: 7,
outH: 40,
soilT: 20,
soilH: 20,
windSpeed: 11,
co2: '0.18 ',
light: 65,
},
{
time: '17:00',
roomT: 25,
roomH: 45,
outT: 5,
outH: 45,
soilT: 17,
soilH: 25,
windSpeed: 8,
co2: '0.17 ',
light: 55,
},
{
time: '18:00',
roomT: 24,
roomH: 50,
outT: 5,
outH: 50,
soilT: 14,
soilH: 30,
windSpeed: 5,
co2: '0.16 ',
light: 40,
},
{
time: '19:00',
roomT: 23,
roomH: 55,
outT: 1,
outH: 55,
soilT: 11,
soilH: 35,
windSpeed: 1,
co2: '0.15 ',
light: 35,
},
{
time: '20:00',
roomT: 22,
roomH: 60,
outT: 0,
outH: 60,
soilT: 8,
soilH: 40,
windSpeed: 5,
co2: '0.14 ',
light: 25,
},
{
time: '21:00',
roomT: 21,
roomH: 65,
outT: 0,
outH: 65,
soilT: 7,
soilH: 45,
windSpeed: 4,
co2: '0.13 ',
light: 6,
},
{
time: '22:00',
roomT: 20,
roomH: 70,
outT: '-3',
outH: 70,
soilT: 6,
soilH: 50,
windSpeed: 6,
co2: '0.12 ',
light: 5,
},
{
time: '23:00',
roomT: 20,
roomH: 75,
outT: '-4',
outH: 75,
soilT: 5,
soilH: 55,
windSpeed: 7,
co2: '0.11 ',
light: 4,
},
];

177
utils/complexChart.js

@ -0,0 +1,177 @@
/* eslint-disable max-len,object-curly-newline */
import max from 'lodash/max';
import {
colors,
generateDefaultSeries,
itemColor,
legendData,
yAxisData,
} from './complexConfig';
/**
* 生成chart所需参数
* @param {Object[]} data 服务端返回数据
* @returns {{environmentTemperature: *[], corrosionXIN: *[], corrosionGANG: *[], corrosionTONG: *[], so2: *[], corrosionLV: *[], time: *[], saltT: *[], saltR: *[], environmentHumidity: *[]}}
*/
function generateParams(data) {
const result = {
time: [],
roomT: [],
roomH: [],
outT: [],
outH: [],
soilT: [],
soilH: [],
windSpeed: [],
co2: [],
light: [],
};
data.forEach(item => {
result.time.push(item.time);
result.roomT.push(+item.roomT);
result.roomH.push(+item.roomH);
result.outT.push(+item.outT);
result.outH.push(+item.outH);
result.soilT.push(+item.soilT);
result.soilH.push(+item.soilH);
result.windSpeed.push(+item.windSpeed);
result.co2.push(+item.co2);
result.light.push(+item.light);
});
return result;
}
/**
* 计算Y轴的显示
* @param {string} yName Y轴的name
* @param {Object} selectedLegend legends
* @returns {boolean}
*/
export function computeYAxisShow(yName, selectedLegend) {
// eslint-disable-next-line guard-for-in,no-restricted-syntax
for (const key in selectedLegend) {
if (key.includes(yName) && selectedLegend[key]) {
return true;
}
}
return false;
}
/**
* 生产y轴内容
* @param {Object} selectedLegend
* @returns {({axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string})[]}
*/
export function generateYAxis(selectedLegend) {
let leftIndex = 0;
let rightIndex = 0;
yAxisData.forEach(item => {
item.show = computeYAxisShow(item.name, selectedLegend);
if (item.show) {
if (item.position === 'left') {
item.offset = 40 * leftIndex;
leftIndex += 1;
} else {
item.offset = 40 * rightIndex;
rightIndex += 1;
}
}
});
return yAxisData;
}
/**
* 生成series数据
* @param {Object} data
* @param {Object[]} yAxis
* @returns {({data: ([]|number|string|*), name: string, type: string}|{data: ([]|number|BufferSource|string|*), name: string, type: string, yAxisIndex: number}|{data: ([]|string|*), name: string, type: string, yAxisIndex: number}|{data: ([]|string|*), name: string, type: string, yAxisIndex: number}|{data: [], name: string, type: string, yAxisIndex: number})[]|*[]}
*/
function generateSeries(data, yAxis) {
const seriesArr = generateDefaultSeries(data);
const showArr = seriesArr.filter(item =>
yAxis.find(y => y.name === item.name),
);
const hideArr = seriesArr.filter(
item => !yAxis.find(y => y.name === item.name),
);
const result = [...showArr, ...hideArr];
result.forEach(item => {
item.itemStyle = { color: itemColor[item.name] };
if (item.name.includes('温度')) {
item.yAxisIndex = 0;
} else if (item.name.includes('湿度')) {
item.yAxisIndex = 1;
} else if (item.name.includes('风速')) {
item.yAxisIndex = 2;
} else if (item.name.includes('CO2')) {
item.yAxisIndex = 3;
} else if (item.name.includes('光照')) {
item.yAxisIndex = 4;
}
});
return result || [];
}
/**
* 计算图表grid left right值
* @param {Object[]} yAxis
* @returns {{left: number, right: number}}
*/
function generateGrid(yAxis) {
const left = [];
const right = [];
yAxis.forEach(item => {
if (item.show) {
if (item.position === 'left') {
left.push(item.offset || 0);
} else {
right.push(item.offset || 0);
}
}
});
return {
left: max(left) + 40,
right: max(right) + 40,
bottom: 20,
};
}
/**
* 生成chart参数
* @param {Object[]} rawData 返回段返回的data数据
* @param {Object} selected 选中的legend
* @returns {{yAxis: ({axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string})[], xAxis: [{data: *[], axisTick: {alignWithLabel: boolean}, type: string}], color: [string,string,string,string,string,string,string,string,string], grid: {left: number, right: number}, legend: {data: [string,string,string,string,string,string,string,string,string], type: string, selected}, series: (({data: ([]|number|string|*), name: string, type: string}|{data: ([]|number|BufferSource|string|*), name: string, type: string, yAxisIndex: number}|{data: ([]|string|*), name: string, type: string, yAxisIndex: number}|{data: [], name: string, type: string, yAxisIndex: number})[]|*[]), tooltip: {axisPointer: {type: string, snap: boolean}, trigger: string}, dataZoom: [{type: string},{type: string}]}}
*/
export function generateChartOption(rawData, selected) {
const data = generateParams(rawData);
const yAxis = generateYAxis(selected);
const series = generateSeries(data, yAxis);
const grid = generateGrid(yAxis);
const option = {
color: colors,
darkMode: true,
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
snap: true,
},
},
grid,
legend: {
type: 'scroll',
selected,
data: legendData,
},
xAxis: [
{
type: 'category',
axisTick: { alignWithLabel: true },
data: data.time,
},
],
yAxis,
series,
};
return option;
}

202
utils/complexConfig.js

@ -0,0 +1,202 @@
/* eslint-disable max-len */
export const colors = [
'#EAB308',
'#F97316',
'#EC4899',
'#F43F5E',
'#D946EF',
'#06B6D4',
'#B45309',
'#1E40AF',
'#166534',
];
export const itemColor = {
'室内温度(℃)': colors[5],
'室外温度(℃)': colors[6],
'土壤温度(℃)': colors[7],
'室内湿度(RH%)': colors[8],
'室外湿度(RH%)': colors[0],
'土壤湿度(RH%)': colors[1],
'风速(m/s)': colors[2],
'CO2(%)': colors[3],
'光照(klux)': colors[4],
};
export const legendData = [
{
name: '室外湿度(RH%)',
itemStyle: { color: colors[0] },
listStyle: { color: colors[0] },
},
{
name: '土壤湿度(RH%)',
itemStyle: { color: colors[1] },
listStyle: { color: colors[1] },
},
{
name: '风速(m/s)',
itemStyle: { color: colors[2] },
listStyle: { color: colors[2] },
},
{
name: 'CO2(%)',
itemStyle: { color: colors[3] },
listStyle: { color: colors[3] },
},
{
name: '光照(klux)',
itemStyle: { color: colors[4] },
listStyle: { color: colors[4] },
},
{
name: '室内温度(℃)',
itemStyle: { color: colors[5] },
listStyle: { color: colors[5] },
},
{
name: '室外温度(℃)',
itemStyle: { color: colors[6] },
listStyle: { color: colors[6] },
},
{
name: '土壤温度(℃)',
itemStyle: { color: colors[7] },
listStyle: { color: colors[7] },
},
{
name: '室内湿度(RH%)',
itemStyle: { color: colors[8] },
listStyle: { color: colors[8] },
},
];
// y轴定义
export const yAxisData = [
{
type: 'value',
name: '温度',
offset: 0,
position: 'left',
axisLine: {
show: true,
lineStyle: { color: colors[7] },
},
axisLabel: { formatter: '{value}' },
axisPointer: { show: false },
},
{
type: 'value',
name: '湿度',
offset: 70,
position: 'left',
axisLine: {
show: true,
lineStyle: { color: colors[1] },
},
axisLabel: { formatter: '{value}' },
axisPointer: { show: false },
},
{
type: 'value',
name: '风速',
offset: 0,
position: 'right',
axisLine: {
show: true,
lineStyle: { color: colors[2] },
},
axisLabel: { formatter: '{value}' },
axisPointer: { show: false },
},
{
type: 'value',
name: 'CO2',
position: 'right',
show: false,
offset: 80,
axisLine: {
show: true,
lineStyle: { color: colors[3] },
},
axisLabel: { formatter: '{value}' },
axisPointer: { show: false },
},
{
type: 'value',
name: '光照',
show: false,
position: 'right',
offset: 160,
axisLine: {
show: true,
lineStyle: { color: colors[4] },
},
axisLabel: { formatter: '{value}' },
axisPointer: { show: false },
},
];
/**
* 生成默认数据
* @param {Object} data
* @returns {[{data: (number|[]|string|*), name: string, type: string},{data: (number|[]|BufferSource|string|*), name: string, type: string, yAxisIndex: number},{data: ([]|string|*), name: string, type: string, yAxisIndex: number},{data: ([]|string|*), name: string, type: string, yAxisIndex: number},{data: [], name: string, type: string, yAxisIndex: number},null,null,null]}
*/
export function generateDefaultSeries(data) {
return [
{
name: '室内温度(℃)',
type: 'line',
yAxisIndex: 0,
data: data.roomT,
},
{
name: '室外温度(℃)',
type: 'line',
yAxisIndex: 0,
data: data.outT,
},
{
name: '土壤温度(℃)',
type: 'line',
yAxisIndex: 0,
data: data.soilT,
},
{
name: '室内湿度(RH%)',
type: 'line',
yAxisIndex: 0,
data: data.roomH,
},
{
name: 'CO2(%)',
type: 'line',
yAxisIndex: 1,
data: data.co2,
},
{
name: '风速(m/s)',
type: 'line',
yAxisIndex: 1,
data: data.windSpeed,
},
{
name: '光照(klux)',
type: 'line',
yAxisIndex: 2,
data: data.light,
},
{
name: '室外湿度(RH%)',
type: 'line',
yAxisIndex: 3,
data: data.outH,
},
{
name: '土壤湿度(RH%)',
type: 'line',
yAxisIndex: 4,
data: data.soilH,
},
];
}

9
utils/map.js

@ -35,8 +35,7 @@ function initValues() {
export function initOptions() {
return {
zoom: 0.4,
backgroundColor: 'transparent',
visualMap: {
show: true,
min: 0,
@ -74,15 +73,15 @@ export function initOptions() {
[
{
offset: 0,
color: '#00aa32', // 天空颜色
color: '#0c2771', // 天空颜色
},
{
offset: 0.7,
color: '#998866', // 地面颜色
color: '#026fab', // 地面颜色
},
{
offset: 1,
color: '#000', // 地面颜色
color: '#01285c', // 地面颜色
},
],
false,

5
yarn.lock

@ -3274,6 +3274,11 @@ lodash@^4.17.20:
resolved "https://registry.npm.taobao.org/lodash/download/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha1-Z5WRxWTDv/quhFTPCz3zcMPWkRw=
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.nlark.com/lodash/download/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha1-Z5WRxWTDv/quhFTPCz3zcMPWkRw=
log-symbols@^5.0.0:
version "5.0.0"
resolved "https://registry.nlark.com/log-symbols/download/log-symbols-5.0.0.tgz#7720d3c6a56c365e1f658916069ba18d941092ca"

Loading…
Cancel
Save