代码编程

11.硅谷甄选-中国地图

11.硅谷甄选-中国地图

11.硅谷甄选-中国地图 ### 1.效果 ![56745603d3a45c1a24df17eea2e1cdae.png](https://tp.xshareku.com/webdev/c521476e98bb4997b28aa6b660f0869e.png) ### 2.代码 china.json数据如下方式获取 https://datav.aliyun.com/portal/school/atlas/area_selector#&lat=33.50475906922609&lng=104.2822265625&zoom=4 ``` <template> <div class="box4" ref="map"> 我是地图组件 </div> </template> <script setup lang="ts"> import { ref, onMounted } from 'vue'; import * as echarts from 'echarts'; //引入中国地图的JSON数据 import chinaJSON from './china.json' //获取DOM元素 let map = ref(); //注册中国地图 echarts.registerMap('china', chinaJSON as any) onMounted(() => { let mychart = echarts.init(map.value); //设置配置项 mychart.setOption({ //地图组件 geo: { map: 'china',//中国地图 roam: true,//鼠标缩放的效果 //地图的位置调试 left: 150, top: 150, right: 150, zoom:1.2, bottom: 0, //地图上的文字的设置 label: { show: true,//文字显示出来 color: 'white', fontSize: 14 }, itemStyle: { //每一个多边形的样式 color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: 'red' // 0% 处的颜色 }, { offset: 1, color: 'blue' // 100% 处的颜色 }], global: false // 缺省为 false }, opacity: .8 }, //地图高亮的效果 emphasis: { itemStyle: { color: 'red' }, label: { fontSize: 40 } } }, //布局位置 grid: { left: 0, top: 0, right: 0, bottom: 0 }, series: [ { type: 'lines',//航线的系列 data: [ { coords: [ [116.405285, 39.904989], // 起点 [119.306239, 26.075302] // 终点 ], // 统一的样式设置 lineStyle: { color: 'orange', width: 5 } }, { coords: [ [116.405285, 39.904989], // 起点 [114.298572,30.584355] // 终点 ], // 统一的样式设置 lineStyle: { color: 'yellow', width: 5 } } ], //开启动画特效 effect: { show: true, symbol: 'arrow', color: 'black', symbolSize: 10 } } ] }) }); </script> <style scoped></style> ```

前端167 热度
admin
admin
2024年6月23日
VIP
10.硅谷甄选-饼状图

10.硅谷甄选-饼状图

10.硅谷甄选-饼状图 ### 1.效果 ![cfd51a17d2efe005de5821b83a4b7233.png](https://tp.xshareku.com/webdev/b05ef85d89bb409891660b28bd2e2f2a.png) ### 2.代码 ``` <template> <div class="box2"> <div class="title"> <p>年龄比例</p> <img src="../../images/dataScreen-title.png" alt=""> </div> <!-- 图形图标的容器 --> <div class="charts" ref="charts"></div> </div> </template> <script setup lang="ts"> import { ref, onMounted } from 'vue'; //引入echarts import * as echarts from 'echarts'; let charts = ref(); //组件挂载完毕初始化图形图标 onMounted(() => { let mychart = echarts.init(charts.value); //设置配置项 let option = { tooltip: { trigger: 'item' }, legend: { right: 30, top: 40, orient: 'vertical',//图例组件方向的设置 textStyle: { color: 'white', fontSize: 14 } }, series: [ { name: 'Access From', type: 'pie', radius: ['40%', '70%'], avoidLabelOverlap: false, itemStyle: { borderRadius: 10, borderColor: '#fff', borderWidth: 2 }, label: { show: true, position: 'inside', color:'white' }, labelLine: { show: false }, data: [ { value: 1048, name: '军事' }, { value: 735, name: '新闻' }, { value: 580, name: '直播' }, { value: 484, name: '娱乐' }, { value: 300, name: '财经' } ] } ], //调整图形图标的位置 grid: { left: 0, top: 0, right: 0, bottom: 0 } }; mychart.setOption(option); }); </script> <style scoped lang="scss"> .box2 { width: 100%; height: 100%; background: url(../../images/dataScreen-main-cb.png) no-repeat; background-size: 100% 100%; .title { margin-left: 20px; p { color: white; font-size: 20px; } } .charts { height: 260px; } } </style> ```

前端74 热度
admin
admin
2024年6月23日
VIP
9.硅谷甄选-折线图

9.硅谷甄选-折线图

9.硅谷甄选-折线图 ### 1.效果 ![833823118a4c8a0737a9b2ec6ae52a97.png](https://tp.xshareku.com/webdev/4c6ebe0f91db44a687392ca97f2d11c3.png) ### 2.代码 ``` <template> <div class="box5"> <div class="title"> <p>未来七天游客数量趋势图</p> <img src="../../images/dataScreen-title.png" alt=""> </div> <div class="charts" ref='line'></div> </div> </template> <script setup lang="ts"> import * as echarts from 'echarts'; import { ref, onMounted } from 'vue'; //获取图形图标的节点 let line = ref(); onMounted(() => { let mycharts = echarts.init(line.value); //设置配置项 mycharts.setOption({ //标题组件 title: { text: '访问量' }, //x|y轴 xAxis: { type: 'category', //两侧不留白 boundaryGap: false, //分割线不要 splitLine: { show: false }, data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], //轴线的设置 axisLine: { show: true }, //刻度 axisTick: { show: true } }, yAxis: { splitLine: { show: false }, //轴线的设置 axisLine: { show: true }, //刻度 axisTick: { show: true } }, grid: { left: 40, top: 0, right: 20, bottom: 20 }, //系列 series: [ { type: 'line', data: [120, 1240, 66, 2299, 321, 890, 1200], //平滑曲线的设置 smooth: true, //区域填充样式 areaStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: 'red' // 0% 处的颜色 }, { offset: 1, color: 'blue' // 100% 处的颜色 }], global: false // 缺省为 false } } } ] }) }) </script> <style scoped lang="scss"> .box5 { width: 100%; height: 100%; background: url(../../images/dataScreen-main-cb.png) no-repeat; background-size: 100% 100%; margin: 0px 20px; .title { margin-left: 10px; p { color: white; font-size: 20px; } } .charts { height: calc(100% - 40px); } } </style> ```

前端49 热度
admin
admin
2024年6月23日
VIP
8.硅谷甄选-雷达图

8.硅谷甄选-雷达图

8.硅谷甄选-雷达图 ### 1.效果 ![bd2c005b6fd3e625c01e2e22a06118e5.png](https://tp.xshareku.com/webdev/69b309e8044c4a0c910822e031011871.png) ### 2.代码 ``` <template> <div class="box8"> <div class="title"> <p>数据统计</p> <img src="../../images/dataScreen-title.png" alt=""> </div> <div class="charts" ref="charts"></div> </div> </template> <script setup lang="ts"> import * as echarts from 'echarts'; import { ref, onMounted } from 'vue'; //获取DOM节点 let charts = ref(); //组件挂载完毕 onMounted(() => { //一个容器可以同时展示多种类型的图形图标 let mychart = echarts.init(charts.value); let option = { title: { text: '游客消费统计', textStyle:{ color:'white' } }, radar: { // shape: 'circle', indicator: [ { name: '消费', max: 6500 }, { name: '好感', max: 16000 }, { name: '出行', max: 30000 }, { name: '小吃', max: 38000 }, { name: '爱好', max: 52000 }, { name: '景点', max: 25000 } ] }, series: [ { name: 'Budget vs spending', type: 'radar', data: [ { value: [4200, 3000, 20000, 35000, 50000, 18000], name: '购物' }, { value: [5000, 14000, 28000, 26000, 42000, 21000], name: '吃饭' } ] } ] }; //设置配置项 mychart.setOption(option) }) </script> <style scoped lang="scss"> .box8 { width: 100%; height: 100%; background: url(../../images/dataScreen-main-cb.png) no-repeat; background-size: 100% 100%; margin-top: 20px; .title { p { color: white; font-size: 18px; } } .charts { height: calc(100% - 30px); } } </style> ```

前端32 热度
admin
admin
2024年6月23日
VIP
7.硅谷甄选-散点图

7.硅谷甄选-散点图

7.硅谷甄选-散点图 ## 1.效果 ![3f31c8f867fdfb05f1dca3a22004f596.png](https://tp.xshareku.com/webdev/ba994efe470e46d3bf8d1937763d00e5.png) ### 2.代码 ``` <template> <div class="box7"> <div class="title"> <p>年度游客量对比</p> <img src="../../images/dataScreen-title.png" alt=""> </div> <div class="charts" ref="charts"></div> </div> </template> <script setup lang="ts"> import * as echarts from 'echarts'; import { ref, onMounted } from 'vue'; //获取DOM节点 let charts = ref(); //组件挂载完毕 onMounted(() => { //一个容器可以同时展示多种类型的图形图标 let mychart = echarts.init(charts.value); //设置配置项 mychart.setOption({ title: { text: '散点图', left: '40%', textStyle: { color: 'white' } }, xAxis: { type: 'category', show: true, }, yAxis: { show: false }, grid: { left: 20, top: 20, right: 0, bottom: 20 }, series: { type: 'scatter', data: [33, 88, 21, 9, 88, 234, 113, 1231, 674, 3, 88, 33, 21, 888, 3332, 313, 123, 5, 657, 7], //标记图形设置 symbol: 'diamond', symbolSize: 16, //图文标签 label: { show: true, position: 'top', color: 'red' }, //散点图标记的颜色 itemStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: 'red' // 0% 处的颜色 }, { offset: 1, color: 'blue' // 100% 处的颜色 }], global: false // 缺省为 false } } } }) }) </script> <style scoped lang="scss"> .box7 { width: 100%; height: 100%; background: url(../../images/dataScreen-main-cb.png) no-repeat; background-size: 100% 100%; margin: 20px 0px; .title { p { color: white; font-size: 18px; } } .charts { height: calc(100% - 30px); } } </style> ```

前端8 热度
admin
admin
2024年6月23日
VIP
6.硅谷甄选-柱状图

6.硅谷甄选-柱状图

6.硅谷甄选-柱状图 ## 1.男女比例 ### 1.1效果 ![f95576159b082757326b7602dff4b48e.png](https://tp.xshareku.com/webdev/2d3ba79cb2254949b9732ed2fb162c4e.png) ### 1.2.代码 ``` <template> <div class="box1"> <div class="title"> <p>男女比例</p> <img src="../../images/dataScreen-title.png" alt=""> </div> <div class="sex"> <div class="man"> <img src="../../images/man.png" alt=""> </div> <div class="women"> <img src="../../images/woman.png" alt=""> </div> </div> <div class="rate"> <p>男士58%</p> <p>女士42%</p> </div> <div class="charts" ref='charts'></div> </div> </template> <script setup lang="ts"> import { ref, onMounted } from 'vue'; import * as echarts from 'echarts'; //获取图形图标的DOM节点 let charts = ref(); onMounted(() => { //初始化echarts实例 let mycharts = echarts.init(charts.value); //设置配置项 mycharts.setOption({ //组件标题 title: { text: '男女比例',//主标题 textStyle: {//主标题颜色 color: 'skyblue' }, left: '40%' }, //x|y xAxis: { show: false, min: 0, max: 100 }, yAxis: { show: false, type: 'category' }, series: [ { type: 'bar', data: [58], barWidth: 20, z: 100, itemStyle: { color: 'skyblue', borderRadius: 20 } } , { type: 'bar', data: [100], barWidth: 20, //调整女士柱条位置 barGap: '-100%', itemStyle: { color: 'pink', borderRadius: 20 } } ], grid: { left: 0, top: 0, right: 0, bottom: 0 } }); }) </script> <style scoped lang="scss"> .box1 { width: 100%; height: 100%; background: url(../../images/dataScreen-main-cb.png) no-repeat; background-size: 100% 100%; margin: 20px 0px; .title { margin-left: 20px; p { color: white; font-size: 20px; } } .sex { display: flex; justify-content: center; .man { margin: 20px; width: 111px; height: 115px; background: url(../../images/man-bg.png) no-repeat; display: flex; justify-content: center; align-items: center; } .women { margin: 20px; width: 111px; height: 115px; background: url(../../images/woman-bg.png) no-repeat; display: flex; justify-content: center; align-items: center; } } .rate { display: flex; justify-content: space-between; color: white; } .charts { height: 100px; } } </style> ``` ## 2.热门景区排行 ### 2.1效果 ![0a043ac93020e49cda9aab160ae07254.png](resources/aec53ecb7e224d78ba8995715c03f749.png) ### 2.2 代码 ``` <template> <div class="box6"> <div class="title"> <p>热门景区排行</p> <img src="../../images/dataScreen-title.png" alt=""> </div> <!-- 图形图标的容器 --> <div class="charts" ref='charts'></div> </div> </template> <script setup lang="ts"> import * as echarts from 'echarts'; import { ref, onMounted } from 'vue'; //获取DOM节点 let charts = ref(); //组件挂载完毕 onMounted(() => { //一个容器可以同时展示多种类型的图形图标 let mychart = echarts.init(charts.value); //设置配置项 mychart.setOption({ //标题组件 title: { //主标题 text: '景区排行', link: 'http://www.baidu.com', //标题的位置 left: '50%', //主标题文字样式 textStyle: { color: 'yellowgreen', fontSize: 20 }, //子标题 subtext: "各大景区排行", //子标题的样式 subtextStyle: { color: 'yellowgreen', fontSize: 16 } }, //x|y轴组件 xAxis: { type: 'category',//图形图标在x轴均匀分布展示 }, yAxis: {}, //布局组件 grid: { left: 20, bottom: 20, right: 20 }, //系列:决定显示图形图标是哪一种的 series: [ { type: 'bar', data: [10, 20, 30, 40, 50, 60, 70], //柱状图的:图形上的文本标签, label: { show: true, //文字的位置 position: 'insideTop', //文字颜色 color: 'yellowgreen' }, //是否显示背景颜色 showBackground: true, backgroundStyle: { //底部背景的颜色 color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: 'black' // 0% 处的颜色 }, { offset: 1, color: 'blue' // 100% 处的颜色 }], global: false // 缺省为 false } }, //柱条的样式 itemStyle: { borderRadius:[10, 10, 0, 0], //柱条颜色 color:function(data:any){ //给每一个柱条这是背景颜色 let arr =['red','orange','yellowgreen','green','purple','hotpink','skyblue'] return arr[data.dataIndex]; } } }, { type:'line', data:[10,20,30,40,50,60,90], smooth:true,//平滑曲线 }, { type: 'bar', data: [10, 20, 30, 40, 50, 60, 70], //柱状图的:图形上的文本标签, label: { show: true, //文字的位置 position: 'insideTop', //文字颜色 color: 'yellowgreen' }, //是否显示背景颜色 showBackground: true, backgroundStyle: { //底部背景的颜色 color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: 'black' // 0% 处的颜色 }, { offset: 1, color: 'blue' // 100% 处的颜色 }], global: false // 缺省为 false } }, //柱条的样式 itemStyle: { borderRadius:[10, 10, 0, 0], //柱条颜色 color:function(data:any){ //给每一个柱条这是背景颜色 let arr =['red','orange','yellowgreen','green','purple','hotpink','skyblue'] return arr[data.dataIndex]; } } }, ], tooltip:{ backgroundColor:'rgba(50,50,50,0.7)' } }) }) </script> <style scoped lang="scss"> .box6 { width: 100%; height: 100%; background: url(../../images/dataScreen-main-cb.png) no-repeat; background-size: 100% 100%; margin: 20px 0px; .title { margin-left: 5px; p { color: white; font-size: 20px; } } .charts { height: calc(100% - 30px); } } </style> ```

前端10 热度
admin
admin
2024年6月23日
VIP
5.硅谷甄选-水滴图

5.硅谷甄选-水滴图

5.硅谷甄选-水滴图 + 需要安装echarts和echarts-liquidfill ## 1.效果 ![e579380b78ca95140911e7c85560c736.png](https://tp.xshareku.com/webdev/501c44e4f07c4cc1990b88a108be0236.png) ## 2.代码 ``` <template> <div class="box"> <div class="top"> <p class="title">实时游客统计</p> <p class="bg"></p> <p class="right">可预约总量<span>99999</span>人</p> </div> <div class="number"> <span v-for="(item, index) in people" :key="index">{{ item }}</span> </div> <!-- 盒子将来echarts展示图形图标的节点 --> <div class="charts" ref="charts">123</div> </div> </template> <script setup lang="ts"> //水球图拓展插件 import 'echarts-liquidfill' import * as echarts from 'echarts'; import { ref, onMounted } from 'vue'; let people = ref('215908人'); //获取节点 let charts = ref(); onMounted(() => { //获取echarts类的实例 let mycharts = echarts.init(charts.value); //设置实例的配置项 mycharts.setOption({ //标题组件 title: { text: '水球图' }, //x|y轴组件 xAxis: {}, yAxis: {}, //系列:决定你展示什么样的图形图标 series: { type: 'liquidFill',//系列 data: [0.6, 0.4, 0.2],//展示的数据 waveAnimation: true,//动画 animationDuration: 3, animationDurationUpdate: 0, radius: '100%',//半径 outline: {//外层边框颜色设置 show: true, borderDistance: 8, itemStyle: { color: 'skyblue', borderColor: '#294D99', borderWidth: 8, shadowBlur: 20, shadowColor: 'rgba(0, 0, 0, 0.25)' } }, }, //布局组件 grid: { left: 0, right: 0, top: 0, bottom: 0 } }) }) </script> <style scoped lang="scss"> .box { background: url(../../images/dataScreen-main-lb.png) no-repeat; background-size: 100% 100%; margin-top: 10px; .top { margin-left: 20px; .title { color: white; font-size: 20px; } .bg { width: 68px; height: 7px; background: url(../../images/dataScreen-title.png) no-repeat; background-size: 100% 100%; margin-top: 10px; } .right { float: right; color: white; font-size: 20px; span { color: yellowgreen; } } } .number { padding: 10px; margin-top: 30px; display: flex; span { flex: 1; height: 40px; text-align: center; line-height: 40px; background: url(../../images/total.png) no-repeat; background-size: 100% 100%; color: #29fcff; } } .charts { width: 100%; height: 270px; } } </style> ```

前端15 热度
admin
admin
2024年6月23日
VIP
4.硅谷甄选-大屏适配

4.硅谷甄选-大屏适配

+ 使用scale实现数据大屏适配 ``` <template> <div class="container"> <!-- 数据大屏展示内容区域 --> <div class="screen" ref="screen"> <!-- 数据大屏顶部 --> <div class="top"> <Top /> </div> <div class="bottom"> <div class="left"> <Tourist class="tourist"></Tourist> <Sex class="sex"></Sex> <Age class="age"></Age> </div> <div class="center"> <Map class="map"></Map> <Line class="line"></Line> </div> <div class="right"> <Rank class="rank"></Rank> <Year class="year"></Year> <Counter class="count"></Counter> </div> </div> </div> </div> </template> <script setup lang="ts"> import { ref, onMounted } from "vue"; //引入顶部的子组件 import Top from './components/top/index.vue'; //引入左侧三个子组件 import Tourist from './components/tourist/index.vue'; import Sex from './components/sex/index.vue'; import Age from './components/age/index.vue' //引入中间两个子组件 import Map from './components/map/index.vue'; import Line from './components/line/index.vue'; //引入右侧三个子组件 import Rank from './components/rank/index.vue'; import Year from './components/year/index.vue'; import Counter from './components/couter/index.vue' //获取数据大屏展示内容盒子的DOM元素 let screen = ref(); onMounted(() => { screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)` }); //定义大屏缩放比例 function getScale(w = 1920, h = 1080) { const ww = window.innerWidth / w; const wh = window.innerHeight / h; return ww < wh ? ww : wh; } //监听视口变化 window.onresize = () => { screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)` } </script> <style scoped lang="scss"> .container { width: 100vw; height: 100vh; background: url(./images/bg.png) no-repeat; background-size: cover; .screen { position: fixed; width: 1920px; height: 1080px; left: 50%; top: 50%; transform-origin: left top; .top { width: 100%; height: 40px; } .bottom { display: flex; .right { flex: 1; display: flex; flex-direction: column; margin-left: 40px; .rank { flex: 1.5; } .year { flex: 1; } .count { flex: 1; } } .left { flex: 1; height: 1040px; display: flex; flex-direction: column; .tourist { flex: 1.2; } .sex { flex: 1; } .age { flex: 1; } } .center { flex: 1.5; display: flex; flex-direction: column; .map { flex: 4; } .line { flex: 1; } } } } } </style> ```

前端12 热度
admin
admin
2024年6月23日
  • 1
  • 2