当前位置: 首页 > 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.khdw.cn/news/37923.html

相关文章:

  • 网站建设及管理工作岗位要求优书网
  • 保健品网站建设流程微帮推广平台怎么加入
  • 武汉招聘网站制作品牌营销策划方案怎么做才好
  • 南京网站官网建设长沙seo就选智优营家
  • 饶阳网站建设如何做网页制作
  • 工厂 电商网站建设网络快速排名优化方法
  • 企业管理咨询机构信息流优化师培训
  • 东城网站制作公司seo优化的搜索排名影响因素主要有
  • 做毕业设计免费网站建设网络推广和seo
  • 恒锐奇 做网站广州网站制作公司
  • 做网站前途免费网站提交入口
  • 免费申请一个不花钱网站南京网络推广优化哪家好
  • 低价高端网站设计seo流量的提升的软件
  • 网站备案需要拍照seo广州工作好吗
  • 武汉网站设计师培训学校阳江seo
  • 南昌网站建设行业现状火蝠电商代运营公司
  • 昆明网站快照优化公司灰色词快速排名接单
  • 怎么做直播网站刷弹幕百度售后服务电话
  • 做网站需要找什么客户网站权重怎么看
  • 重庆网站建设开发云南疫情最新数据消息中高风险地区
  • wordpress默认界面做网站seo推广公司
  • 南通网站的优化seo竞价排名
  • 互联网门户网站建设管理 总结中国有几个搜索引擎
  • 网站的建设与预算建网站平台
  • 做网站的如何增加电话量怎么给公司做网站推广
  • 专门做app的原型网站济南seo优化
  • 资源优化网站排名郑州网站优化seo
  • 做一家公司网站要注意哪些品牌推广与传播方案
  • 做图片格式跟尺度用哪个网站好怎么制作自己公司网站
  • 网站手机页面做多大咖啡seo是什么意思