当前位置: 首页> 汽车> 新车 > 沧州做网站费用_网页设计实训总结心得体会_网站构建的基本流程_网站seo哪里做的好

沧州做网站费用_网页设计实训总结心得体会_网站构建的基本流程_网站seo哪里做的好

时间:2025/8/26 12:41:43来源:https://blog.csdn.net/aZHANGJIANZHENa/article/details/142878003 浏览次数: 0次
沧州做网站费用_网页设计实训总结心得体会_网站构建的基本流程_网站seo哪里做的好

写在前面,博主是个在北京打拼的码农,工作多年做过各类项目,最近心血来潮在这儿写点东西,欢迎大家多多指教。

数据排名列表——图表开发,动态柱状图表,排名图

UI

3debe8ac928c47f5b666fe9afae805ed.png

直接搜到类似在线代码(数据列表--bar - category-work,grid直角坐标,legend,series-bar柱状图,toolbox工具栏,tooltip提示框 - makeapie echarts社区图表可视化案例),准备在此基础上向UI靠拢

全部代码:

 enableChart() {let that = this;// 启用表格----重组数据格式this.tableData = JSON.parse(JSON.stringify(this.chartData));if (this.tableData && this.tableData.length) {// this.tableData.push(this.allNumObj);this.tableData = [...this.tableData, this.benjiObj, this.allNumObj];}this.$nextTick(function() {const elPart = document.querySelectorAll("tr");elPart.forEach(a => {a.children[2].style.color = "#fd5702";});});this.$forceUpdate();//       if (["舆情办结率"].includes(this.typeName)) {// return;// // 舆情办结率没图表所以不刷新//             }//  if (["舆情办结率", "转办时效"].includes(this.typeName)) {//         this.titleStr = "均值";//       }else{//         this.titleStr = "合计";//       }// color: #fd5702;var myChart = echarts.init(document.getElementById("chartPart1"));var colorList = ["#FC0033", "#FD5702", "#FEB507", "#BBBBBB"];var datas = this.chartData.map(a => {return { value: a.nowInfoNum, name: a.addressName };});let junZhi = (this.chartData[0].nowInfoAllNum /(this.addressOption.length - 2)).toFixed(2);if (this.loginUl.orgParentId != 0) {junZhi = (this.chartData[0].nowInfoAllNum /(this.addressOption.length - 1)).toFixed(2);}if (this.loginUl.orgParentId != 7) {junZhi = (this.chartData[0].nowInfoAllNum / this.addressOption.length).toFixed(2);}let maxArr = new Array(datas.length).fill(this.chartData[0] ? this.chartData[0].nowInfoAllNum : "暂无");//合计值字段;let option = {tooltip: {trigger: "axis",axisPointer: {type: "none"},formatter: function(params, index) {return (params[0].name +",位列第" +(params[0].dataIndex + 1) +"," +params[0].seriesName +params[0].value +"<br>均值:" +junZhi);}},legend: {show: false},grid: {top: 30, //图表距离容器下面多少距离containLabel: true},xAxis: {show: false,type: "value"},yAxis: [{type: "category",inverse: true,axisLine: {show: false},axisTick: {show: false},axisPointer: {label: {show: false,margin: 20}},// itemGap: 10,data: datas.map(item => item.name),axisLabel: {// width:2000,    //网格宽度// height:'auto',   //网格高度margin: 140,fontSize: 16,align: "left",color: "#333",// offset: 100,  // 调整标签与刻度值的距离rich: {a1: {color: "#fff",backgroundColor: colorList[0],width: 30,height: 30,align: "center",borderRadius: 2},a2: {color: "#fff",backgroundColor: colorList[1],width: 30,height: 30,align: "center",borderRadius: 2},a3: {color: "#fff",backgroundColor: colorList[2],width: 30,height: 30,align: "center",borderRadius: 2},b: {color: "#fff",backgroundColor: colorList[3],width: 30,height: 30,align: "center",borderRadius: 2}},formatter: function(params) {var index = datas.map(item => item.name).indexOf(params);index = index + 1;let disposeText = params.length > 6 ? params + "..." : params;if (index - 1 < 3) {return ["{a" + index + "|" + index + "}" + "  " + disposeText].join("\n");} else {return ["{b|" + index + "}" + "  " + disposeText].join("\n");}}}},{type: "category",inverse: true,axisTick: "none",axisLine: "none",show: true,data: datas.map(item => item.value),axisLabel: {show: false, //右侧百分比fontSize: 14,color: "#333",formatter: "{value}%"}}],series: [{//   left: 100,// right: 0,// top:0,// bottom:0,z: 2,name: this.typeName,type: "bar",barWidth: 20,zlevel: 1,data: datas.map((item, i) => {let colorStr = "";if (that.checkName === item.name) {colorStr = "#009b63";} else {if (i > 3) {colorStr = colorList[3];} else {colorStr = colorList[i];}}let itemStyle = {color: colorStr,barBorderRadius: 30};//设置选中的柱子颜色return {value: item.value,itemStyle: itemStyle};}),label: {show: false,position: "right",color: "#333333",fontSize: 14,offset: [10, 0]}},{name: "合计",type: "bar",barWidth: 20,barGap: "-100%",itemStyle: {normal: {color: "#EEEEEE",barBorderRadius: 30},emphasis: {// 高亮状态下的样式color: "#EEEEEE"}},data: maxArr}]};var worldMapContainer = document.getElementById("chartPart1");//用于使chart自适应高度和宽度,通过外部元素高宽计算容器高宽 - 50worldMapContainer.style.width =document.getElementsByClassName("left")[0].clientWidth + 100 + "px";let H = 400;if (60 * this.chartData.length > 400) {H = 60 * this.chartData.length;}document.getElementsByClassName("left")[0].style.height = H + "px";worldMapContainer.style.height = H + "px";//设置容器高宽myChart.setOption(option);myChart.resize();this.$forceUpdate();},

调整echarts图的缩放大小

echarts如何改变图形的大小

echarts 放大与缩放的功能

echarts图表的大小调整的解决方案

echarts如何改变图形的大小

echarts的图表撑满整个容器 echarts图大小设置

那么怎么真真正正的解决上述几个问题呢

当我们直接拿别人二次开发过的echarts图,发现有点无从下手,搜索后也没发现有啥好属性,某处边距就是很宽看着难受

我的解决方法是

父元素相对定位,子元素绝对定位,直接调整子元素Echarts图的宽高来缩放图表,通过定位,让框与框的间距消失

改动前:

75b3e77ae884469c971bdfe2021d4d85.png

 

改动后:

fc726a470a6148f79c17097c180ac248.png

.left {position: relative;
.chartPartEl {position: absolute !important;top: 0;left: -90px;
}}<div class="left" v-show="isUnfold"><templatev-if="chartData && chartData.length && chartData[0].nowInfoAllNum"><p><button class="green" @click="handleOk()">下载图片</button></p><divclass="chartPartEl"id="chartPart1"ref="chartPart1"style="width: 500px;height: 500px;"></div></template><p v-else class="notData">暂无数据</p></div>

 

最终效果:

b84c5fd631b841ad9dd539b3b0e2b4cd.png

5ee6cdc4241441d981e5559a7866abf5.png

 

 

 

 

 

本次开发中碰到的有意思的文章:

 

1.ECharts 高度宽度自适应(转载) - hao_1234_1234 - 博客园

  var worldMapContainer = document.getElementById("chartPart1");//用于使chart自适应高度和宽度,通过外部元素高宽计算容器高宽var resizeWorldMapContainer = function() {worldMapContainer.style.width =document.getElementsByClassName("left")[0].clientWidth - 100 + "px";worldMapContainer.style.height =document.getElementsByClassName("content")[0].clientWidth + "px";}; //设置容器高宽resizeWorldMapContainer();myChart.setOption(option);myChart.resize();

 

2.4361476db20642b9a701a8bbdfb6549e.png

3.javaScript实用方法第三篇(.fill .filter .find)_js .fill-CSDN博客 

4.Error in callback for watcher “options“: “TypeError:Cannot read properties of null (reading ‘level‘)_error in callback for watcher "options": "typeerro-CSDN博客 

5.4727e943c56b42489b7575efa74cd7e3.png 解决前代码:根据父元素可视高度实现

//用于使chart自适应高度和宽度,通过外部元素高宽计算容器高宽var resizeWorldMapContainer = function() {worldMapContainer.style.width =document.getElementsByClassName("left")[0].clientWidth - 100 + "px";worldMapContainer.style.height =document.getElementsByClassName("content")[0].clientWidth + "px";}; //设置容器高宽resizeWorldMapContainer();

解决后代码:根据数据数量多少决定

  var worldMapContainer = document.getElementById("chartPart1");//用于使chart自适应高度和宽度,通过外部元素高宽计算容器高宽// var resizeWorldMapContainer = function() {worldMapContainer.style.width =document.getElementsByClassName("left")[0].clientWidth - 100 + "px";let H=400;if(60*this.chartData.length>400){
H=60*this.chartData.length;}worldMapContainer.style.height =H+'px';// document.getElementsByClassName("left")[0].clientHeight + "px";// }; //设置容器高宽// resizeWorldMapContainer();

6.b4c48ba754d04681a383bfe26c079dce.png

 

关键字:沧州做网站费用_网页设计实训总结心得体会_网站构建的基本流程_网站seo哪里做的好

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: