亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Vue前端柱狀圖實例(疊狀條形圖)

 更新時間:2023年03月27日 16:45:57   作者:半度納  
這篇文章主要介紹了Vue前端柱狀圖實例(疊狀條形圖),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

vue前端柱狀圖(疊狀條形圖)

通過echarts來實現(xiàn)柱狀圖的效果,echarts是針對數(shù)據報表等展現(xiàn)的一個產品,具體了解看官方網站:Echarts官網,在這個官網中有詳細教程以及API,很容易入手Echarts,從個人剛學習Echarts圖表來看,它的難度在于它有自己的一套屬性,這和我們平時用的css是不同的,因而我們需要什么效果就得去遵守它的屬性,去識別圖表的各個部分的專業(yè)名稱,才能從它API中獲取相應屬性去實現(xiàn)你想要效果。

效果圖

代碼:

<template>
	<div>
		<!-- 柱狀圖 -->
		<el-row :gutter="80">
			<!-- 柱狀圖兩側間距 最大24 -->
			<el-col :span="24">
				<div class="border-card ">
					<el-row>
						<div class="chart-wrapper">
							<bar-chart ref="chartOne" v-if="chartOneShow" style="width:100%;height:400px"
								:option="chartOptionOne" />
						</div>
					</el-row>
				</div>
			</el-col>
		</el-row>
	</div>
</template>
 
<script>
    //保存的柱狀圖組件路徑
	import BarChart from "../../dashboard/chart.vue";
    export default {
      //使用的柱狀圖組件
	  components: {
	  	BarChart,
	  },
	  data(){
	  	return{
			//表圖選項
			chartOptionOne: {},
			//表圖顯示
			chartOneShow: true,
            //前端接收到的數(shù)據
			tableData: [],
        }
      },
      created() {
	    this.getList();
	  },
      methods: {
	    getList() {
	      this.loading = true;
		  let data=[];
		  let data1=[];
		  let data2=[];
		  let data3=[];
	      taskStatisticsRwpf(this.queryParams).then(response => {
	        this.tableData = response.data;
			for (var i = 0; i < this.tableData.length; i++) {
				data.push(this.tableData[i].字段名)//此data為x坐標展示的文字
				data1.push(this.tableData[i].字段名)
				data2.push(this.tableData[i].字段名)
				data3.push(this.tableData[i].字段名)
			}
			this.getChartsData(data,data1,data2,data3);
	        this.loading = false;
	      });
	    },
		getChartsData(data,data1,data2,data3) {
			this.chartOneShow = false
			this.chartTwoShow = false
			let that = this;
			taskStatisticsRwpf({
				queryType: "chart"
			}).then(response => {
			that.chartOptionOne = {
				title: {
				    text: "柱狀圖標題名",
					x:'center',
					y:'top',
					textAlign:'left',   //位置
					textStyle:{
					    //文字顏色
					    color:'#000000',
					    //字體風格,'normal','italic','oblique'
					    fontStyle:'normal',
					    //字體粗細 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
					    fontWeight:'400',
					    //字體系列
					    // fontFamily:'sans-serif',
					    //字體大小
					    fontSize:20,
					}
				},
				grid: {
				  left: '1%',
				  right: '1%',
				  containLabel: true
				},
				legend: {
				    data: data1,data2,data3
				},
                //鼠標懸停顯示數(shù)據
				tooltip: {
				    trigger: 'axis',
				    axisPointer: {
				      type: 'shadow'
				    }
				},
                //x坐標
				xAxis: {
					type: 'category',
                    //x坐標顯示的文字
					data: data,
					axisLabel: {
					//x軸文字間距
					interval:0,
					//x軸文字傾斜度
					rotate:0
					}
				},
                //y坐標
				yAxis: {
					type: 'value'
				},
				series: [{
					      name: '文字名',
					      type: 'bar',
					      stack: 'total',
					      label: {
					        show: true
					      },
					      emphasis: {
					        focus: 'series'
					      },
					      data: data1
					    },
					    {
					      name: '文字名',
					      type: 'bar',
					      stack: 'total',
					      label: {
					        show: true
					      },
					      emphasis: {
					        focus: 'series'
					      },
					      data: data2
					    },
					    {
					      name: '文字名',
					      type: 'bar',
					      stack: 'total',
					      label: {
					        show: true
					      },
					      emphasis: {
					        focus: 'series'
					      },
					      data: data3
					    },
					    {
					      stack: 'total',
					type: 'bar',
					//設置柱狀圖大小
					barWidth: 30,
					label: {
					      // 柱圖頭部顯示值
					      show: true,
					      position: "right",
					      color: "#333",
					      fontSize: "12px",
					      formatter: (params) => {
					        return params.value[params.encode.x[0]];
					      },
					}
				}]
			};
                //表圖顯示
				this.chartOneShow = true
			})
		},
	  }
    }    
</script>

vue echarts柱狀圖自定義formatter

echarts雙柱狀圖自定義tooltip

<template>
  <div id="echartsId" style="width:100%;height:200px;"></div>
</template>
zhuDouble() {
      var myChart = echarts.init(document.getElementById('echartsId'))
      window.addEventListener('resize', function () {
        myChart.resize()
      })
      myChart.setOption({
        legend: {
          left: 'center',
          bottom:'3%',
          icon: 'circle',
          data: ['Forest', 'Steppe'],
          textStyle: {
            fontSize: 12,
            color: '#8C8C8C'
          }
        },
        xAxis: {
          type: 'category',
          axisTick: {
            show: false // 去掉x軸 小細條
          },
          data: ['2018', '2019', '2020', '2021', '2022'],
          axisLabel: {
            width: 30,
            overflow: "breakAll",
            fontSize: 11,
          },
        },
        grid: {
          left: '5%',
          right: '8%',
          bottom: '12%',
          top: '8%',
          containLabel: true,
        },
        color: ['#3372FF', '#21C9E6'],
        yAxis: {
          type: 'value'
        },
        tooltip: {
          trigger: 'item', 
          formatter:function(params){
            let tip = '';
            tip += '<div>總數(shù)' + 23 + '</div><div>'+ params.seriesName + '數(shù)量' + params.value +'所</p></div>'
            return tip
          },
          borderColor: "rgba(255, 255, 255, 1)"
        },
        series: [
        {
	      name: 'Forest',
	      type: 'bar',
	      data: [320, 332, 301, 334, 390]
	    },
	    {
	      name: 'Steppe',
	      type: 'bar',
	      data: [220, 182, 191, 234, 290]
	    },
      })
    }

總結

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • 詳解vue-cli構建項目反向代理配置

    詳解vue-cli構建項目反向代理配置

    本篇文章主要介紹了詳解vue-cli構建項目反向代理配置,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09
  • Vue+Canvas繪圖使用的講解

    Vue+Canvas繪圖使用的講解

    這篇文章主要介紹了Vue+Canvas繪圖的使用方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • vue 國際化 vue-i18n 雙語言 語言包

    vue 國際化 vue-i18n 雙語言 語言包

    這篇文章主要介紹了vue 國際化 vue-i18n 雙語言 語言包的相關知識,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-06-06
  • vue input標簽通用指令校驗的實現(xiàn)

    vue input標簽通用指令校驗的實現(xiàn)

    這篇文章主要介紹了vue input標簽通用指令校驗的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-11-11
  • vue使用Highcharts實現(xiàn)3D餅圖

    vue使用Highcharts實現(xiàn)3D餅圖

    這篇文章主要為大家詳細介紹了vue使用Highcharts實現(xiàn)3D餅圖,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • antd+vue實現(xiàn)動態(tài)驗證循環(huán)屬性表單的思路

    antd+vue實現(xiàn)動態(tài)驗證循環(huán)屬性表單的思路

    今天通過本文給大家分享antd+vue實現(xiàn)動態(tài)驗證循環(huán)屬性表單的思路,代碼簡單易懂,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2021-09-09
  • el-form-item中表單項label和表單項內容換行實現(xiàn)方法

    el-form-item中表單項label和表單項內容換行實現(xiàn)方法

    這篇文章主要給大家介紹了el-form-item中表單項label和表單項內容換行實現(xiàn)的相關資料,每個表單el-form由多個表單域el-form-item組成,需要的朋友可以參考下
    2023-09-09
  • Vuex入門之Module使用詳解

    Vuex入門之Module使用詳解

    這篇文章主要介紹了Vuex入門之Module使用詳解,由于使用單一狀態(tài)樹,應用的所有狀態(tài)會集中到一個比較大的對象,當應用變得非常復雜時,store?對象就有可能變得相當臃腫,需要的朋友可以參考下
    2023-11-11
  • 淺談Vue下使用百度地圖的簡易方法

    淺談Vue下使用百度地圖的簡易方法

    本篇文章主要介紹了淺談Vue下使用百度地圖的簡易方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • vue2左側菜單欄收縮展開功能實現(xiàn)

    vue2左側菜單欄收縮展開功能實現(xiàn)

    vue2左側菜單欄收縮展開目前是非常常見的,我們在日常開發(fā)過程中經常會碰到,這篇文章給大家介紹vue2左側菜單欄收縮展開功能,感興趣的朋友跟隨小編一起看看吧
    2024-04-04

最新評論