展示大屏练习

1.页面框架
<template>
  <div>
    <header>
      <h1>赣州房价分析平台</h1>
    </header>
    <!-- 大容器 -->
    <section class="container">
      <!-- 左容器 -->
      <section class="itemLeft">
        <TopTenPage>
          <ItemOne/>
        </TopTenPage>
        <PiePage>
          <ItemTwo/>
        </PiePage>
      </section>
      <!-- 中容器 -->
      <section class="itemCenter">
        <TimePage/>
        <CenterBottom>
          <MapPage/>
        </CenterBottom>
      </section>
      <!-- 右容器 -->
      <section class="itemRight">
        <ItemPage>
          <ItemThree/>
        </ItemPage>
        <ItemPage>
          <ItemFour/>
        </ItemPage>
      </section>
    </section>
  </div>
</template>

<script>
import ItemPage from "@/components/itemPage.vue"
import PiePage from "@/components/piePage.vue"
import TopTenPage from "@/components/topTenPage.vue"
import TimePage from "@/components/timePage.vue"
import CenterBottom from "@/components/centerBottom.vue"
import MapPage from "@/components/mapPage.vue"
import LinePage from "@/components/linePage.vue"
import ItemOne from "@/components/itemOne.vue"
import ItemTwo from "@/components/itemTwo.vue"
import ItemThree from "@/components/itemThree.vue"
import ItemFour from "@/components/itemFour.vue"
import MainPage from "@/components/views/main/mainPage.vue"
export default {
  name: 'homePage',
  data() {
    return {

    };
  },
  components:{
    ItemPage,
    PiePage,
    TopTenPage,
    TimePage,
    CenterBottom,
    MapPage,
    ItemOne,
    ItemTwo,
    ItemThree,
    ItemFour,
    LinePage,
    MainPage
  },
  computed:{

  },
  methods: {

},
};
</script>

<style lang="less" scoped>
  header{
    height: 1rem;
    width: 100%;
    margin: .625rem 0;
    background: url("~@/assets/headerbg.png");
    // background-color: rgba(14, 14, 225, 0.699);
    // 标题的文字样式
    h1{
      font-size: .625rem;
      color: #fff;
      text-align: center;
      line-height: 1rem;
      
    }
  }

  // 大容器的样式
  .container{
    // 最大最小的宽度
    min-width: 1200px;
    max-width: 2048px;
    margin: 0 auto;
    padding: .125rem .125rem 0;
    // background-color: gray;
    display: flex;
    // 设置左右在页面的份数
    .itemLeft,.itemRight{
      flex: 3.5;
    }
    .itemCenter{
      flex: 4;
      height: 10.5rpx;
      // border: 1px solid rgb(65, 152, 207);
      padding: 0.125rem;
      margin: .25rem;
    }
  }
</style>

2.柱状图
<template>
  <div>
    <dv-border-box-8 style="height:100% width:100%">
    <h2>赣州各区县房屋均价Top10(/)</h2>
    <div class="chart" id="topten">
        
    </div>
    </dv-border-box-8>
  </div>
</template>

<script>
import Border from "@/components/border.vue"
import axios from "axios";
export default {
  name: "",
  data() {
    return {
      price: [],
      xprice: [],
      district: []
    };
  },
  components: {},
  computed: {},
  methods: {
    myEcharts() {
      let _this = this;
      // 基于准备好的dom,初始化echarts实例
      var myChart = this.$echarts.init(document.getElementById("topten"));

      // 指定图表的配置项和数据
      var option;
      axios.get("https://4o977191w3.goho.co/rank").then(
        res => {
          console.log(res.data.data.rank[0]);
          console.log(res);
          let ydata = res.data.data.rank[0].ydata;
          let xdata = res.data.data.rank[0].xdata;
          option = {
            tooltip: {
              trigger: "axis",
              formatter(params){
                return '<div><p>'+params[0].name+'<br/>'+params[0].marker+params[0].value+' 元/㎡</p></div>'
              }
            },
            grid: {
              left: "70",
              right: "20",
              bottom: "20",
              top: "20",
              containLabel: false
            },
            xAxis: {
              type: "value",
              show: false,
              max: "dataMax"
            },
            yAxis: {
              type: "category",
              data: ydata,
              inverse: true,
              axisLine: {
                show: false
              },
              axisTick: {
                show: false
              },
              axisLabel: {
                margin: 55,
                width: 60,
                align: "left",
                overflow: "truncate",
                formatter: function(value, index) {
                  let ind = index + 1;
                  if (ind + 9 == ydata.length) {
                    return "{one|" + (index + 1) + "} {a|" + value + "}";
                  } else if (ind + 8 == ydata.length) {
                    return "{two|" + (index + 1) + "} {b|" + value + "}";
                  } else if (ind + 7 == ydata.length) {
                    return "{three|" + (index + 1) + "} {c|" + value + "}";
                  }
                  if (ydata - index < 8) {
                    return "{five|"  + (index + 1) + "} {d|" + value + "}";
                  }
                  return "{four|"  + (index + 1) + "} {d|" + value + "}";
                },
                rich: {
                  a: {
                    color: "#59c9f9"
                  },
                  b: {
                    color: "#59c9f9"
                  },
                  c: {
                    color: "#59c9f9"
                  },
                  d: {
                    color: "#59c9f9"
                  },
                  // 第一名
                  one: {
                    backgroundColor: "#E86452",
                    color: "white",
                    width: 12,
                    height: 16,
                    padding: [1, 0, 0, 5],
                    borderRadius: 10,
                    fontSize: 11
                  },
                  // 第二名
                  two: {
                    backgroundColor: "#FF9845",
                    color: "white",
                    width: 12,
                    height: 16,
                    padding: [1, 0, 0, 5],
                    borderRadius: 10,
                    fontSize: 11
                  },
                  // 第三名
                  three: {
                    backgroundColor: "#F6BD16",
                    color: "white",
                    width: 12,
                    height: 16,
                    padding: [1, 0, 0, 5],
                    borderRadius: 10,
                    fontSize: 11
                  },
                  // 一位数
                  four: {
                    backgroundColor: "#009dff",
                    color: "white",
                    width: 12,
                    height: 16,
                    padding: [1, 0, 0, 5],
                    borderRadius: 10,
                    fontSize: 11
                  },
                  // 两位数
                  five: {
                    backgroundColor: "#009dff",
                    color: "white",
                    width: 16,
                    height: 16,
                    padding: [1, 0, 0, 1],
                    borderRadius: 10,
                    fontSize: 13
                  }
                }
              }
            },
            series: [
              {
                type: "bar",
                showBackground: true,
                realtimeSort: true,
                label: {
                  show: true,
                  position: "center",
                  color: "#fff",
                  fontSize: 18
                },
                barWidth: 25,
                itemStyle: {
                  color: "#5B8FF9"
                },
                data: xdata
              }
            ]
          };

          // 使用刚指定的配置项和数据显示图表。
          myChart.setOption(option);
        },
        res => {
          console.log("error");
        }
      );
    }
  },
  mounted() {
    this.myEcharts();
  }
};
</script>

<style lang='less' scoped>
h2 {
  height: 0.5rem;
  color: #fff;
  line-height: 0.5rem;
  font-size: 0.3rem;
  text-align: center;
}
.chart {
  height: 4.5rem;
}
</style>

在这里插入图片描述

3.饼状图
<template>
  <div class="box" id="piechart">
     <!-- <h2>hhhhh</h2> -->
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "",
  data() {
    return {};
  },
  components: {},
  computed: {},
  mounted() {
    this.myEcharts();
  },
  methods: {
    myEcharts() {
      var chartDom = document.getElementById("piechart");
      var myChart = this.$echarts.init(chartDom);
      var option;

      axios.get("https://4o977191w3.goho.co/count").then(
        res => {
          console.log(res);
          let count = res.data.data.data;

          option = {
            title: {
              text: "房价区间分布(元/㎡)",
              left: "center",
              textStyle:{
                color:"#fff"
              }
            },
            tooltip: {
              trigger: "item",
              formatter(params){
                // alert(JSON.stringify(params))
                return '<div><p>'+params.name+' 元/㎡   '+'<br/>'+params.marker+params.value+'个楼盘</p></div>'
              }
            },
            legend: {
              orient: "vertical",
              left: "left",
              top:"bottom",
              textStyle:{
                color:"#fff"
              }
            },
            series: [
              {
                name: "房价区间分布(元/㎡)",
                type: "pie",
                radius: "55%",
                data: count,
                label:{
                  color:"#fff",
                  fontSize:15
                },
                labelLine:{
                  show:true,
                  length:40,
                  length:20
                },
                emphasis: {
                  itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: "rgba(0, 0, 0, 0.5)"
                  }
                }
              }
            ]
          };

          myChart.setOption(option);
        },
        res => {
          console.log("error");
        }
      );

    }
  }
};
</script>

<style lang='less' scoped>
.box {
  // margin: 0 auto;
  width: 6.5rem;
  height: 5.5rem;
  // background-color: #457dcb1a;
}
</style>

在这里插入图片描述

4.折线图
<template>
  <div id="chart">
            <!-- <h3>{{ Title }}</h3> -->
            <el-select v-model="value" placeholder="切换地区" @change="onchange" >
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
            <div ref="myChart3" id="myChart3" style="height:100%;width:100%;"></div>
        </div>
</template>


<script>
import axios from "axios";
import MenuPage from "@/components/menuPage.vue";
import LinePage from "@/components/linePage.vue";
export default {
  name: "",
  data() {
    return {
      // Title: 'echarts实现下拉框选值',
      value: "",
      datas: [
      ],
      seltValue: [
      ],
      options: [
        {
          value: "0",
          label: "赣州"
        },
        {
          value: "1",
          label: "上犹"
        },
        {
          value: "2",
          label: "于都"
        },
        {
          value: "3",
          label: "会昌"
        },
        {
          value: "4",
          label: "信丰"
        },
        {
          value: "5",
          label: "全南"
        },
        {
          value: "6",
          label: "兴国"
        },
        {
          value: "7",
          label: "南康"
        },
        {
          value: "8",
          label: "大余"
        },
        {
          value: "9",
          label: "宁都"
        },
        {
          value: "10",
          label: "定南"
        },
        {
          value: "11",
          label: "寻乌"
        },
        {
          value: "12",
          label: "崇义"
        },
        {
          value: "13",
          label: "开发区"
        },
        {
          value: "14",
          label: "瑞金"
        },
        {
          value: "15",
          label: "石城"
        },
        {
          value: "16",
          label: "站北"
        },
        {
          value: "17",
          label: "章江新区"
        },
        {
          value: "18",
          label: "章贡"
        },
        {
          value: "19",
          label: "赣县"
        },
        {
          value: "20",
          label: "龙南"
        }
      ]
    };
  },
  methods: {
    onchange(value) {
      this.datas.map((item, index) => {
        if (index == value) {
          this.downSelect(this.seltValue[index]);
        }
      });
    },
    downSelect(seltValue) {
      console.log(seltValue);
      // 基于准备好的dom,初始化echarts实例
      let myChart3 = this.$echarts.init(document.getElementById("myChart3"));
      var lineStyle = {
        normal: {
          width: 1,
          opacity: 0.5
        }
      };

      axios.get("https://4o977191w3.goho.co/line").then(
        res => {
          console.log(res);
          this.datas = res.data.data;
          this.seltValue = res.data.data;

          // 绘制图表
          myChart3.setOption({
            xAxis: {
              type: "category",
              data: ["2022/2", "2022/3", "2022/4", "2022/5", "2022/6"],
              axisTick: {
                alignWithLabel: true
              },
              axisLabel: {
                color: "#fff",
                fontSize: 13
              }
            },
            yAxis: {
              type: "value",
              // color: "#fff",
              max: "dataMax",
              min: "dataMin",
              axisTick: {
                alignWithLabel: true,
                show:true
              },
              axisLine: {
                show: true
              },
              axisLabel: {
                color: "#fff",
                fontSize: 13,
                shouw:true
              },
              splitLine: {
                show: false
              }
            },
            tooltip: {
              show:true,
              trigger: "axis",
              showContent:true,
            },
            series: [
              {
                name: "平均房价(元/㎡)",
                type: "line",
                silent: true,
                axisLabel: {
                  color: "#fff"
                },
                lineStyle: {
                  normal: {
                    type: "solid",
                    color: "#00ddff",
                    width: 2.5,
                    opacity: 1
                  }
                },
                data: seltValue,
                itemStyle: {
                  normal: {
                    opacity: 0
                  }
                },
                areaStyle: {
                  normal: {
                    color: "#0d6dba",
                    opacity: 0.1
                  }
                }
              }
            ]
          });
        },
        res => {
          console.log("error");
        }
      );
    }
  },

  mounted() {
    this.downSelect(this.seltValue[0]);
  }
};
</script>

<style lang='less' scoped>
#chart {
  // width: 6.5rem;
  // height: 5rem;
  height: 5.125rem;
  // border: 1px solid #00ddff;
}
</style>

在这里插入图片描述

5.轮播表格
<template>
  <div class="box">
    <dv-scroll-board :config="config" style="width:100%;height:100%" />
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: '',
  data() {
    return {
      config:{
      header: ['楼盘名称', '地址', '房屋单价(元/㎡)'],
      headerBGC	:"rgb(65, 152, 207)",
      data: [],
      index: true,
      columnWidth: [50],
      align: ['center']
    }
  }
  },
  components:{

  },
  mounted(){
      this.getData();
  },
  methods: {
      getData(){
        axios.get('https://4o977191w3.goho.co/all').then(res => {
                    console.log(res)
                    console.log(res.data.data.data[155])
                    // this.config.data=res.data.data.data
                    this.config={
                    header: ['楼盘名称', '房屋单价', '地址'],
                    headerBGC	:"rgb(65, 152, 207)",
                    data: res.data.data.data,
                    index: true,
                    columnWidth: [50],
                    align: ['center'],
                    waitTime:1500,
                    indexHeader:''
                  }
                }, res => {
                    console.log("error");
                });
      }
},
};
</script>

<style lang='less' scoped>
.box {
  width: 100%;
  height: 100%;
}
</style>

在这里插入图片描述

6.地图
<template>
  <div class="item">
    <div ref="map" style="width:100%;height:100%;"></div>
  </div>
</template>

<script>
import axios from "axios";
import gzMap from "@/assets/ganzhou.json";
export default {
  data() {
    return {
      data: ""
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      //初始化echarts实例
      var myChart = this.$echarts.init(this.$refs.map);
      //注入这个表
      this.$echarts.registerMap("ganzhou", gzMap);

      axios.get('https://4o977191w3.goho.co/map').then(res => {
                    console.log(res)

                    //指定图表配置项及数据
      var option = {
        title: {
          // text: "赣州市房价地图",
          left: "left",
          // bottom:'90%',
          textStyle: {
            fontSize: 25,
            color: "#fff"
          }
        },
        tooltip: {
          trigger: "item",
          enterable: true,
          // formatter: '{b0}: <br />{b1}: {c1}'
          formatter: function(params) {
            // alert(JSON.stringify(params))
            return '<div><p>'+params.name+'<br/>'+params.marker+params.value+'  元/㎡</p></div>'
          }
        },
        series: [
          {
            name:'房价地图',
            type: "map",
            map: "ganzhou",
            zoom: "1.25",
            data: res.data.data,
            label: {
              show: "true",
              textStyle: {
                color: "#fff"
              }
            },
            itemStyle: {
              normal: {
                areaColor: "#5595bc"
              },
              emphasis: {
                areaColor: "#f4aad6",
              }
            }
          }
        ]
      };
      //使用刚指定的配置项及数据
      myChart.setOption(option);
                }, res => {
                    console.log("error");
                });

    }
  }
};
</script>

<style lang="less" scoped>
.item {
  height: 7.125rem;
  // border: 1px solid #f4aad6;
  margin-top: .625rem;
  // background-color: rgba(12,130,255,.85)
}
</style>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值