Echarts基本的实用属性

news/2024/7/19 15:10:56 标签: echarts, css, js, 前端

大家也可以去Echarts官网查看相关属性:echarts官网,下面都是我在官网中提炼和平时工作中所用到的基本常见属性以及一些特殊属性。
基本结构

<html>
	<div id="container" style="width:100px;height:100px"><div>
</html>
<script>
	var chartDom = document.getElementById('container');
	var myChart = echarts.init(chartDom);
	option = {
		legend: {},//小标签,图例
		grid: {},//图表的位置
		tooltip:{},//鼠标移入显示的文本
		toolbox: {},//拓展的基本功能,复位,下载,转换等等
		xAxis: {},//x轴
		yAxis: {},//y轴
		color:[],//颜色,柱形图,折线等等
		series: {},//存放的数据,值
	}
	 option && myChart.setOption(option);//绘制图表
</script>

详细属性
1,legend,小标签,图例

 legend: {
      top:32,//图例距离页面顶部的距离
      left:'center',//图例的位置,left,center,right
      data: ['降水量', '累计降水'],//图例的名称,有几个就写几个
    },

2,grid,图表的位置

 grid: {
      left: "2%",//图表距离页面左边的距离
      top: "16%",//上
      right: "0%",//右
      bottom: "0%",//下
      containLabel:true,//是否包含坐标轴的刻度标签。
    },

3,tooltip,鼠标移入显示文本

        tooltip: {
              trigger: "axis", //触发类型
              backgroundColor: "rgba(255,255,255,1)", //背景
              textStyle: {
                color: "black", //设置文字颜色
              },
              axisPointer: {//鼠标更随
                type: 'cross',
                label: {
                  backgroundColor: '#fff',
                  color:'#000',
                  borderColor:'#aaa',
                  borderWidth:'1'
                },
              }
            },

4,toolbox,附加功能

toolbox: {	
      show: true,//是否显示
      feature: {
        dataView: {//转换为表格
        	show: true
        },
        restore: {//还原,复位,恢复第一次的样子
        	show: true
        },
        saveAsImage: {//下载,保存为图片
        	show: true
        },
        dataZoom:{//局部数据缩放
        	show:true
        },
	    magicType: {//折线图柱状图等等切换
	        type: ['line', 'bar', 'stack']
	    }
      }
    },

5,color,图例,内容的颜色

color:'#1F1FF9',//只有一个图例
color:[],//多个就用数组装着,逗号隔开

6,X轴

 xAxis: {
      type: 'time',//轴线格式
      axisLabel: {
        show: true,//标签显示 
        interval:'0' //隔一个显示一个刻度标签
      }
    },

7,Y轴
如果想要双y轴复制一个就可以了

    yAxis: [{
      name:'降水',//名称
      type: 'value',
      position: 'left',//位置
      interval:50, //刻度值每次增加几个
      min:0,//最小值
      max:200,//最大值
      axisLine:{//轴线
        show:true,
        lineStyle:{color:'#35AA36'} //轴线颜色
      },
      axisLabel:{//刻度带单位
       formatter:'{value}mm',
      }
    }]

8,series,数据

series: [{
		stack:'名字',//柱子堆叠,一根柱子显示多种数据,只要名字一样就可以
		barWidth:‘10px’//柱子宽度
		barGap: 0.1,//间隙
		name:"降水量",
		data:[],//值
		type: 'bar',//类型
		 yAxisIndex: 0,  // 通过这个判断左右轴
}, {
        name:"累计降水",
        data: [],
        type: 'line',
        yAxisIndex: 1,
        smooth: true,
        symbolSize: 7,
        areaStyle: {            // 折现下是否填充阴影
			color: {//阴影样式
	          type: 'linear',//类型
	          x: 0,//位置
	          y: 0,
	          x2: 0,
	          y2: 1,
	          colorStops: [{//颜色
	            offset: 1, 
	            color: 'rgba(86,122,210,0.6)'
	          }],
          global: false
        }
	}
}]

最后:如果此篇博文对您有帮助,还请动动小手点点关注点点赞呐~,谢谢 ~ ~


http://www.niftyadmin.cn/n/734866.html

相关文章

JavaScript 有关文件上传的总结

1.文件上传时的处理$scope.submit function(){var url $scope._datalistmodel.impexp.imp;var t_file new FormData(document.getElementById(upload_file));//id是form表单的id$http({headers : {content-type:undefined },url : url,data : t_file,method : post,t…

vue js获取当前时间,年月日时分秒

效果图: 话不多说&#xff0c;直接看代码&#xff1a; var date new Date();this.year date.getFullYear();//年this.month date.getMonth() 1;//月this.strDate date.getDate();//日if (this.month > 1 && this.month < 9) { this.month "0" t…

开学测试2018.9.1周年纪念日 BSOJ

描述 输入 输出 样例输入[复制] 5 7322141 5 11 3 72 1 42 3 63 4 52 4 35 4 2样例输出[复制] 11 55 29第一个问题显然是最小生成树&#xff0c;直接上板子就可以了第二个问题稍微要复杂一点首先他是要求一个最小值&#xff0c;我们再来看数据范围发现非常大&#xff0c;n是1e6…

vue中的select下拉框多选

效果图&#xff1a; 代码&#xff1a; <el-select v-model"xxx" multiple value-key"id" collapse-tags change"clk"><el-option v-for"(item,index) in arrs" :label"item.name" :value"item" :key&qu…

Eclipse------启动Server时出现弹窗Server at localhost was unable to start within 45 seconds.

弹窗详细信息&#xff1a; Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor. 解决方法&#xff1a; 我们找到当前工程的workplace目录&#xff0c;然后按…

element ui表格表头中某列标题用图片图标代替

效果图&#xff1a; 我这里用的是图标代替&#xff0c;图片也是一样的。 最关键的是&#xff1a;:render-header“renderHeader” &#xff0c;他是将列标题替换为其他内容。 话不多说&#xff0c;代码来了&#xff01; HTML&#xff1a; <el-table-column prop"xxx&qu…

Hazelcast更换CEO,承诺继续造福开源社区

Hazelcast是一家以开发人员为中心的基础设施组件开发商&#xff0c;其产品包括一个内存数据网格&#xff08;IMDG&#xff09;和一个流式处理引擎&#xff08;Hazelcast Jet&#xff09;。近日&#xff0c;Hazelcast经历了一场管理层人员变动。\\之前的首席执行官Greg Luck将成…

element ui表格中根据某列的值判断操作栏里面的按钮显示隐藏

效果图&#xff1a; 这里我上通过审核意见那列的值判断操作里面的审核按钮的显示隐藏。 首先审核意见那列后台给我返回的是A、B、null三种值&#xff0c;然后我再将这三种值转换为已驳回、已通过、未审核。三个中文显示在页面上。 这个是通过 &#xff1a;formatter属性改的&am…