当前位置: 首页 > news >正文

网站建设方案 规划/今日要闻

网站建设方案 规划,今日要闻,广州做网站最好的公司,做网站公司叫什么一、ECharts引入1.安装echarts包npm install echarts --save2.引入echarts这里就演示全局引入了,挂载到vue全局,后面使用时,直接使用 $echartsimport * as echarts from echarts Vue.prototype.$echarts echarts二、写echarts组件这里演示环…

一、ECharts引入

1.安装echarts包

npm install echarts --save

2.引入echarts

这里就演示全局引入了,挂载到vue全局,后面使用时,直接使用 $echarts

import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts

二、写echarts组件

这里演示环形图表吧,刚好项目中用了,兄弟们有时间可以去echarts 官网去看看API

TIPS: 官网地址贴着了 ECharts 官网

几个注意点简单说下:

  1. ECharts 的DOM盒子需要设定尺寸

要不然渲染不出来的;需要设置样式,那就套盒子,写样式;

  1. 数据改变时重新渲染问题;

当传入的数据改变时,需要重新渲染,这里我用watch 来监听 props 的值,改变时,就重新执行渲染函数;


先贴个效果吧:

下面就代码吧:

父组件中(引用组件)

这里的数据,后台在父组件中去请求后台去;这里不多赘述了哈;

 <div class="charts_box" v-if=" active == 1"><div class="charts" v-for="(item,index) in echartsList" :key="index"><EchartsBar :data="item" /></div>
</div>

echarts 组件

<template><div><div class="charts_item"><div class="echartsBar"><div ref="chart" style="width:140px;height:140px"></div></div><div class="info"><p>{{ this.data.residue }}</p><span v-if="data.name == 'CPU资源剩余量'">核</span><span v-else-if=" data.name =='GPU资源剩余量'">TFLOPS</span><span v-else>G</span><p>/</p><p>{{ this.data.total }}</p><span v-if="data.name =='CPU资源剩余量'">核</span><span v-else-if="data.name =='GPU资源剩余量'">TFLOPS</span><span v-else>G</span></div><div class="titleName" v-if="data.name =='CPU资源剩余量'">CPU资源剩余量</div><div class="titleName" v-else-if="data.name =='GPU资源剩余量'">GPU资源剩余量</div><div class="titleName" v-else-if="data.name =='内容资源剩余量'">内容资源剩余量</div><div class="titleName" v-else-if="data.name =='硬盘资源剩余量'">硬盘资源剩余量</div></div></div>
</template><script>
export default {name: "EchartsBar",components: {},props: {data: {type: Object,default: () => {return {name: "请传值",residue: 0,total: 100};}}},data() {return {};},watch: {// 当数据发生改变时,重新渲染echartsdata: {handler() {this.getEchartsData();},deep: true,immediate: true}},mounted() {this.getEchartsData();},methods: {getEchartsData() {const chart = this.$refs.chart;if (chart) {const myChart = this.$echarts.init(chart);const option = {title: {text: Math.round((this.data.residue / this.data.total) * 100) + "%",textStyle: {color: "#333333",fontSize: 18,fontWeight: "normal"},// subtext: "总分:100分",// subtextStyle: {//   color: "#909090"// },// itemGap: -10, // 主副标题距离left: "center",top: "center"},angleAxis: {max: this.data.total, // 满分clockwise: false, // 逆时针// 隐藏刻度线axisLine: {show: false},axisTick: {show: false},axisLabel: {show: false},splitLine: {show: false}},radiusAxis: {type: "category",// 隐藏刻度线axisLine: {show: false},axisTick: {show: false},axisLabel: {show: false},splitLine: {show: false}},polar: {center: ["50%", "50%"],radius: "160%" //图形大小},series: [{type: "bar",data: [{name: "资源剩余量",value: this.data.residue,itemStyle: {normal: {color:// 比分比低于30%时,显示橘色,否则显示绿色Math.round((this.data.residue / this.data.total) * 100) >= 30? this.$echarts.graphic.LinearGradient(1, 0, 0, 0, [{offset: 0,color: "#4FE884"},{offset: 1,color: "#00B759"}]): this.$echarts.graphic.LinearGradient(1, 0, 0, 0, [{offset: 0,color: "#ff4f1e"},{offset: 1,color: "#ff8a65"}])}}}],coordinateSystem: "polar",roundCap: true,barWidth: 20,barGap: "-100%", // 两环重叠z: 2},{// 灰色环type: "bar",data: [{value: this.data.total,itemStyle: {color: "#e9f1f3",shadowColor: "rgba(0, 0, 0, 0.2)",shadowBlur: 5,shadowOffsetY: 2}}],coordinateSystem: "polar",roundCap: true,barWidth: 20,barGap: "-100%", // 两环重叠z: 1}]};myChart.setOption(option);window.addEventListener("resize", function() {myChart.resize();});}}}
};
</script>
<style scoped lang='less'>
.charts_item {width: 100%;display: flex;flex-direction: column;justify-content: center;justify-items: center;.echartsBar {margin: 0 auto;}.info {width: 100%;display: flex;justify-content: center;align-items: baseline;color: #333333;padding: 20px 0 10px 0;p {text-align: center;font-size: 20px;font-weight: 500;padding: 0 3px;}span {font-size: 14px;font-weight: 400;}}.titleName {margin: 0 auto;font-size: 16px;color: #333333;text-align: center;}
}
</style>

觉得还行,收藏点赞哈

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~END~~~~~~~~~~~~~~~~~~~~~~~~~~~~

http://www.jmfq.cn/news/4809799.html

相关文章:

  • 个人建网站wordpress/seo关键词搜索和优化
  • 咨询手机网站建设平台/搜索引擎优化论文3000字
  • 企业做淘宝客网站有哪些/北京核心词优化市场
  • html插件代码大全/seo交流中心
  • 用wordpress做购物网站/培训机构排名
  • 做淘宝网站需要什么/google收录查询
  • wordpress加载特效插件/快速刷排名seo软件
  • 如何向谷歌提交网站/百度竞价是什么工作
  • 建设网站审批手续/广东: 确保科学精准高效推进疫情
  • 正规网站建设排行/品牌广告和效果广告
  • 怎么样备份网站数据/发免费广告电话号码
  • 抄袭别人网站的前端代码合法吗/重庆专业做网站公司
  • 苏州有哪些it大厂/汕头seo服务
  • 做家装家居网站/百度平台官网
  • 北京网站建设报价/什么样的人适合做策划
  • html5 metro风格网站/米拓建站
  • php做企业网站/百度seo排名培训优化
  • 网站设计流程是什么/百度网站网址是多少
  • python做网站还是数据库/网站开发的步骤
  • 专门做护理PDCA的网站/淘数据
  • photoshop 网站设计/优化公司网站
  • 网站怎么做长尾词/如何进行关键词分析
  • 阿里云上用wordpress/青岛seo网站关键词优化
  • 成都手机网站建设/关键词seo价格
  • wordpress E405/站长之家seo
  • 迷你世界怎么做网站期/搜索引擎查重
  • 东莞网络优化排名/什么是优化
  • 云南网站建设一度科技公司/微信小程序怎么做
  • 做网站还有用/外链屏蔽逐步解除
  • 校园网站建设软件/怎么制作网页页面