|
@@ -19,6 +19,10 @@ export default {
|
|
|
type: String,
|
|
|
default: "270px",
|
|
|
},
|
|
|
+ list: {
|
|
|
+ type: Array,
|
|
|
+ default: [],
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -28,15 +32,39 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
initChart() {
|
|
|
+ let that = this;
|
|
|
const chart = echarts.init(this.$el);
|
|
|
+ const xData = [];
|
|
|
+ const fsData = [];
|
|
|
+ this.list.forEach((element) => {
|
|
|
+ xData.push(new Date(element.time).formatDate("hh时"));
|
|
|
+ fsData.push(element.fs + 5);
|
|
|
+ });
|
|
|
let option = {
|
|
|
grid: {
|
|
|
- top: 10,
|
|
|
+ top: 50,
|
|
|
bottom: 50,
|
|
|
+ left: 20,
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ formatter: function (params) {
|
|
|
+ const data = params[0]["data"];
|
|
|
+ new Date(data.time).formatDate("yyyy-MM-dd hh时");
|
|
|
+ return [
|
|
|
+ new Date(data.time).formatDate("yyyy-MM-dd hh时"),
|
|
|
+ "天气:" + data.tqmc + "",
|
|
|
+ "风速:" + data.fs + " m/s",
|
|
|
+ "风向:" + data.fx + " 度",
|
|
|
+ "气温:" + data.wd + " ℃",
|
|
|
+ "大气压强:" + data.dqyl + " pa",
|
|
|
+ "湿度:" + data.sd + " %",
|
|
|
+ ].join("<br>");
|
|
|
+ },
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: "category",
|
|
|
- data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
|
|
+ data: xData,
|
|
|
},
|
|
|
yAxis: [
|
|
|
{
|
|
@@ -45,57 +73,85 @@ export default {
|
|
|
axisLabel: { show: false },
|
|
|
splitLine: { show: false },
|
|
|
},
|
|
|
+ {
|
|
|
+ type: "value",
|
|
|
+ // max: 25,
|
|
|
+ axisLine: { show: false },
|
|
|
+ axisTick: { show: false },
|
|
|
+ axisLabel: { show: false },
|
|
|
+ splitLine: { show: false },
|
|
|
+ },
|
|
|
],
|
|
|
|
|
|
series: [
|
|
|
{
|
|
|
type: "custom",
|
|
|
renderItem: function (param, api) {
|
|
|
- return {
|
|
|
- type: "group",
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: "image",
|
|
|
- style: {
|
|
|
- image:
|
|
|
- require("@assets/icon/svg/weather/02.png"),
|
|
|
- x: 0,
|
|
|
- y: 0,
|
|
|
- width: 20,
|
|
|
- height: 20,
|
|
|
+ const spiltSize = 2;
|
|
|
+ if (param.dataIndex % spiltSize == 0 && that.list) {
|
|
|
+ const xx = param.coordSys.width / ((that.list.length / spiltSize) | 1);
|
|
|
+ const x = param.coordSys.x + xx * (param.dataIndex / spiltSize) * 1.05;
|
|
|
+ const y = param.coordSys.y - 30;
|
|
|
+ const image = require("@assets/icon/svg/weather/" + that.list[param.dataIndex]["tqtp"] + ".png");
|
|
|
+ return {
|
|
|
+ type: "group",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ type: "image",
|
|
|
+ style: {
|
|
|
+ image: image,
|
|
|
+ x: -5,
|
|
|
+ y: 0,
|
|
|
+ width: 30,
|
|
|
+ height: 30,
|
|
|
+ },
|
|
|
+ position: [x, y],
|
|
|
},
|
|
|
- position: [param.dataIndexInside * 80 +80, 0],
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
},
|
|
|
- data: [0, 10, 20],
|
|
|
+ data: this.list,
|
|
|
yAxisIndex: 0,
|
|
|
z: 11,
|
|
|
- },{
|
|
|
- type: 'custom',
|
|
|
- renderItem: function(param, api){
|
|
|
- return {
|
|
|
- type: 'path',
|
|
|
- shape: {
|
|
|
- pathData: 'M31 16l-15-15v9h-26v12h26v9z',
|
|
|
- x: 0,
|
|
|
- y: 0,
|
|
|
- width: 20,
|
|
|
- height: 20,
|
|
|
- },
|
|
|
- rotation: 0,
|
|
|
- position: [param.dataIndexInside * 80 +80, 200],
|
|
|
- style: api.style({
|
|
|
- stroke: '#555',
|
|
|
- lineWidth: 1
|
|
|
- })
|
|
|
- };
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "custom",
|
|
|
+ renderItem: function (param, api) {
|
|
|
+ const spiltSize = 2;
|
|
|
+ if (param.dataIndex % spiltSize == 0 && that.list) {
|
|
|
+ const xx = param.coordSys.width / ((that.list.length / spiltSize) | 1);
|
|
|
+ const x = param.coordSys.x + 8 + xx * (param.dataIndex / spiltSize) * 1.05;
|
|
|
+ const y = param.coordSys.y;
|
|
|
+ return {
|
|
|
+ type: "path",
|
|
|
+ shape: {
|
|
|
+ pathData: "M31 16l-15-15v9h-26v12h26v9z",
|
|
|
+ x: -15 / 2,
|
|
|
+ y: -15 / 2,
|
|
|
+ width: 15,
|
|
|
+ height: 15,
|
|
|
+ },
|
|
|
+ rotation: (Math.PI / 180) * (that.list[param.dataIndex]["fx"] + 90),
|
|
|
+ // rotation: (Math.PI / 180) * 45,
|
|
|
+ position: [x, 200],
|
|
|
+ style: api.style({
|
|
|
+ stroke: "#555",
|
|
|
+ lineWidth: 1,
|
|
|
+ }),
|
|
|
+ };
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- data: [10,20,30],
|
|
|
- z: 10
|
|
|
- }
|
|
|
+ data: that.list,
|
|
|
+ z: 10,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "line",
|
|
|
+ lineStyle: { normal: { color: "#303f6e" } },
|
|
|
+ data: fsData,
|
|
|
+ z: 1,
|
|
|
+ },
|
|
|
],
|
|
|
};
|
|
|
|
|
@@ -117,12 +173,16 @@ export default {
|
|
|
this.$el.style.width = this.width;
|
|
|
this.$el.style.height = this.height;
|
|
|
this.initChart();
|
|
|
- }, 1000);
|
|
|
+ }, 500);
|
|
|
});
|
|
|
},
|
|
|
updated() {
|
|
|
this.$nextTick(() => {
|
|
|
- this.initChart();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$el.style.width = this.width;
|
|
|
+ this.$el.style.height = this.height;
|
|
|
+ this.initChart();
|
|
|
+ }, 1000);
|
|
|
});
|
|
|
},
|
|
|
unmounted() {
|