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

杭州仪器网站制作叶文语 厦门建设局

杭州仪器网站制作,叶文语 厦门建设局,怎么查网站开发的语言,专业网站建设好不好接口得到的数据如下 要经过排序 ,计算累计百分比得到数据 蓝色 柱状图数据: 取count字段值 横坐标:取 id值 折线图:根据柱状图的数据计算累计百分比 getInterface(data) {getParetoChart(data).then((res) > {if (res) {thi…

在这里插入图片描述

接口得到的数据如下

在这里插入图片描述
要经过排序 ,计算累计百分比得到数据

蓝色 柱状图数据: 取count字段值

横坐标:取 id值

折线图:根据柱状图的数据计算累计百分比

 getInterface(data) {getParetoChart(data).then((res) => {if (res) {this.xList = res.map(item => {return window.vm.$i18n.t(`MsgAlarmType.${item.id}`)});let data = res.map(item => {return item.count});// 对数据进行排序data.sort((a, b) => b - a);this.countList = data// 计算总和const total = data.reduce((sum, value) => sum + value, 0);// 计算累计百分比let cumulativePercentage = 0;this.percentList = data.map(value => {const percentage = (value / total) * 100;cumulativePercentage += percentage;return cumulativePercentage.toFixed(2);});}});},

完整代码

<template><div class="bkChart"><date-range-picker v-model="deviceFormData.time" class="date-item":start-placeholder="$t('NeoLight.startTime')" :end-placeholder="$t('NeoLight.endTime')"value-format="yyyy-MM-dd" @change="getList" /><lineChart :labelList="xList" :barValueList="countList" :lineValueList="percentList" /></div>
</template>
<script>
import lineChart from "../../../components/Echarts/paretoChart.vue";
import { getParetoChart } from "@/api/neolight/inventory";
export default {name: "paretoChart",components: { lineChart },data() {return {deviceFormData: {time: []},xList: [],// x轴,横坐标值countList: [],//柱状图数据percentList: [],//折线图数据,计算累计百分比};},mounted() {},methods: {getList() {let data = {createDate: this.deviceFormData.time,};this.getInterface(data)},getInterface(data) {getParetoChart(data).then((res) => {if (res) {this.xList = res.map(item => {return window.vm.$i18n.t(`MsgAlarmType.${item.id}`)});let data = res.map(item => {return item.count});// 对数据进行排序data.sort((a, b) => b - a);this.countList = data// 计算总和const total = data.reduce((sum, value) => sum + value, 0);// 计算累计百分比let cumulativePercentage = 0;this.percentList = data.map(value => {const percentage = (value / total) * 100;cumulativePercentage += percentage;return cumulativePercentage.toFixed(2);});}});},},
};
</script>

paretoChart.vue文件

<template><div ref="Echart" id="myChart" :class="className" :style="{ height: height, width: width }" />
</template><script>
export default {props: {labelList: Array,barValueList: Array,lineValueList: Array,className: {type: String,default: "chart",},width: {type: String,default: "100%",},height: {type: String,default: "500px",},},data() {return {chart: null,};},watch: {labelList: {handler(newQuestion, oldQuestion) {this.labelList = newQuestion;this.initChart();},deep: true,},barValueList: {handler(newValue, oldValue) {this.barValueList = newValue;this.initChart();},deep: true,},lineValueList: {handler(newValue, oldValue) {this.lineValueList = newValue;this.initChart();},deep: true,},},mounted() {this.initChart();this.__resizeHandler = debounce(() => {if (this.chart) {this.chart.resize();}}, 100);window.addEventListener("resize", this.__resizeHandler);},methods: {initChart() {this.chart = this.$echarts.init(this.$refs.Echart);this.chart.setOption({tooltip: {trigger: 'axis',axisPointer: {type: 'cross',crossStyle: {color: '#fff'}}},legend: {left: "center", //图例距离整个容器左边icon: "rect", //设置图例图标的形状为实心圆,这个不填,默认是矩形itemGap: 25, //图例图标与文字间的间距textStyle: {fontSize: 12, //图例文字字体大小color: "#ffffff", //图例文字颜色},},xAxis: [{type: 'category',data: this.labelList,axisPointer: {type: 'shadow'},}],yAxis: [{type: 'value',name: window.vm.$i18n.t('MsgAlarmType.amount'),interval: 10,axisLabel: {formatter: '{value}'}},{type: 'value',name: '%',// min: 0,// max: 25,interval: 5,axisLabel: {formatter: '{value} %'}}],series: [{name: window.vm.$i18n.t('MsgAlarmType.amount'),type: 'bar',tooltip: {valueFormatter: function (value) {return value}},data: this.barValueList},{name: window.vm.$i18n.t('MsgAlarmType.accPercent'),type: 'line',yAxisIndex: 1,tooltip: {valueFormatter: function (value) {return value + '%';}},data: this.lineValueList}]});},},beforeDestroy() {if (!this.chart) {return;}window.removeEventListener("resize", this.__resizeHandler);this.chart.dispose();this.chart = null;},
};
</script>

参考页面链接:https://blog.csdn.net/qq_36752532/article/details/122074267

http://www.yayakq.cn/news/65785/

相关文章:

  • 深圳建设集团网站企网
  • 移动端网站怎么做优化注册免费域名网站
  • 建好了网站怎么做外贸手机网站建站
  • 天津建设招聘信息网站单页营销网站怎么做
  • 营销策划方案网站家装设计理念
  • 平台网站可以做第三方检测报告建筑设计公司属于什么行业
  • 东莞做网站需要多少钱wordpress gdrive备份
  • 吕梁建设机械网站百度知道官网登录入口
  • 专业网站制作的地方怎么在网上做彩票网站
  • 广州建网站的公司ui培训报名
  • 建设网站的公司兴田德润在哪里学校网站建设的安全策略
  • 建p2p网站做外贸网站要多少钱
  • 社区网站 备案wordpress批量修改
  • 黄石企业网站建设开发注册网站
  • 我英文网站建设网站建设 网页设计 的文章
  • 如何把动态图发网站做头像购物网站开发教程
  • 网站精神文件建设专栏wordpress关闭搜索
  • 成都百度竞价推广电商seo
  • 免备案网站建站广告素材网站哪个比较好
  • 商洛做网站的公司的网站设计案例
  • 做网站能用自己电脑吗网站开发招聘 领英
  • 中医医院网站建设需求做介绍自己的短视频网站
  • 做网站哪里的好西安官网seo分析
  • 外贸网站框架重庆网站关键字优化
  • 网站被抄袭舆情分析
  • 青海公司网站建设哪家快金融企业类网站模板免费下载
  • 音乐网站怎么做精准关键词2015网站建设源码
  • 怎么使用网站服务器怎么做网站受众分析
  • 网站怎么排名wordpress 手机版
  • 大连模板建站软件莱芜东风街吧百度贴吧