echarts学习第二讲--图表基本属性应用字典

1、仪表图

option = {
				    tooltip: {
				        formatter: '{a} <br/>{b} : {c}%'
				    },
				    series: [
				        {
				            name: '业务指标',
				            type: 'gauge',
				            radius: '90%',
				            axisLine: {     //仪表盘轴线相关配置
				                	show:true,
				                    lineStyle: {
				                        color: [  //仪表盘背景颜色渐变
						                    [1,new echarts.graphic.LinearGradient(0, 0, 1, 0, [
						                      	{
						                        	offset: 0.1,
						                        	color: "#fd2100"
						                      	},
						                      	{
						                        	offset: 0.6,
						                        	color: "#d09f00"
						                      	},
						                      	{
						                        	offset: 1,
						                        	color: "#26fd00"
						                      	}
						                    ])
						                  ]
						                ],
				                        width:10,  //仪表盘轴线宽度
				                    },
				                },
				            axisTick: {            // 坐标轴小标记
				                length:12,        // 属性length控制线长
				                lineStyle: {       // 属性lineStyle控制线条样式
				                    color: 'auto'
				                }
				            },
				            splitLine: {           // 分隔线指向中心的那些线
				                length:5,         // 属性length控制线长
				                lineStyle: {       // 属性lineStyle(详见lineStyle)控制线条样式
				                    color: 'auto'
				                }
				            },
				            pointer: {
				                width:2  //仪表指针宽度
				            },
				            axisLabel: {  // 刻度标签
				            	show:true,
				            	color: '#000',
				            	fontSize:7,   //改变仪表盘内刻度数字的大小
				            	shadowColor : '#000', //默认透明
				            },
				            title: {	//仪表盘标题。
				            	show: false,				//是否显示标题,默认 true。
				            },
				            
				            title: {	//仪表盘标题。
				            	show: false,				//是否显示标题,默认 true。
				            	offsetCenter: [0,"60%"],//相对于仪表盘中心的偏移位置,数组第一项是水平方向的偏移,第二项是垂直方向的偏移。可以是绝对的数值,也可以是相对于仪表盘半径的百分比。
				                color: '#000',
				                fontWeight: '100',
				                fontSize: '18',
				            },
				            
				            detail: {				// 仪表盘详情,用于显示数据。
				            	show: false,				// 是否显示详情,默认 true。
				            	offsetCenter: [0,"35%"],// 相对于仪表盘中心的偏移位置,数组第一项是水平方向的偏移,第二项是垂直方向的偏移。可以是绝对的数值,也可以是相对于仪表盘半径的百分比。
				                color: '#000',
				                fontWeight: '700',
				                fontSize: '20',
				            	formatter: "{value}%",	// 格式化函数或者字符串
				            },
				            data: [{ value: 92, name: '指标' }],
				        }
				    ]
				};

仪表图可以用来表示什么什么率的变化变量

2、柱状图

var option = {
            //--------------    标题 title  ----------------   
            title: {                                
                text: '主标题',                
                textStyle:{                 //---主标题内容样式    
                    color:'#fff'
                },
 
                subtext:'副标题',          //---副标题内容样式
                subtextStyle:{
                    color:'#bbb'                
                },
 
                padding:[0,0,100,100]               //---标题位置,因为图形是是放在一个dom中,因此用padding属性来定位
 
            },
 
            //----------------   图例 legend  -----------------
            legend: {
                type:'plain',               //----图例类型,默认为'plain',当图例很多时可使用'scroll'
                top:'1%',                   //----图例相对容器位置,top\bottom\left\right            
                selected:{
                    '销量':true,          //----图例选择,图形加载出来会显示选择的图例,默认为true
                },
                textStyle:{                 //----图例内容样式
                    color:'#fff',               //---所有图例的字体颜色
                    //backgroundColor:'black',  //---所有图例的字体背景色
                },              
                tooltip:{                   //图例提示框,默认不显示
                    show:true,
                    color:'red',
                },
                data:[                      //----图例内容
                    {
                        name:'销量',
                        icon:'circle',          //----图例的外框样式
                        textStyle:{
                            color:'#fff',       //----单独设置某一个图例的颜色
                            //backgroundColor:'black',//---单独设置某一个图例的字体背景色
                        }
                    }
                ],                      
            },
 
            //--------------   提示框 -----------------
            tooltip: {
                show:true,                  //---是否显示提示框,默认为true
                trigger:'item',             //---数据项图形触发
                axisPointer:{               //---指示样式
                    type:'shadow',      
                    axis:'auto',    
 
                },
                padding:5,
                textStyle:{                 //---提示框内容样式
                    color:"#fff",           
                },
            },
 
            //-------------  grid区域  ----------------
            grid:{
                show:false,                 //---是否显示直角坐标系网格
                top:80,                     //---相对位置,top\bottom\left\right  
                containLabel:false,         //---grid 区域是否包含坐标轴的刻度标签
                tooltip:{                   //---鼠标焦点放在图形上,产生的提示框
                    show:true,  
                    trigger:'item',         //---触发类型
                    textStyle:{
                        color:'#666',
                    },
                }
            },
 
            //-------------   x轴   -------------------
            xAxis: {
                show:true,                  //---是否显示
                position:'bottom',          //---x轴位置
                offset:0,                   //---x轴相对于默认位置的偏移
                type:'category',            //---轴类型,默认'category'
                name:'月份',              //---轴名称
                nameLocation:'end',         //---轴名称相对位置
                nameTextStyle:{             //---坐标轴名称样式
                    color:"#fff",
                    padding:[5,0,0,-5], //---坐标轴名称相对位置
                },
                nameGap:15,                 //---坐标轴名称与轴线之间的距离
                //nameRotate:270,           //---坐标轴名字旋转
 
                axisLine:{                  //---坐标轴 轴线
                    show:true,                  //---是否显示
 
                    //------------------- 箭头 -------------------------
                    symbol:['none', 'arrow'],   //---是否显示轴线箭头
                    symbolSize:[8, 8] ,         //---箭头大小
                    symbolOffset:[0,7],         //---箭头位置
 
                    //------------------- 线 -------------------------
                    lineStyle:{
                        color:'#fff',
                        width:1,
                        type:'solid',
                    },
                },
                axisTick:{                  //---坐标轴 刻度
                    show:true,                  //---是否显示
                    inside:true,                //---是否朝内
                    lengt:3,                    //---长度
                    lineStyle:{
                        //color:'red',          //---默认取轴线的颜色
                        width:1,
                        type:'solid',
                    },
                },
                axisLabel:{                 //---坐标轴 标签
                    show:true,                  //---是否显示
                    inside:false,               //---是否朝内
                    rotate:0,                   //---旋转角度   
                    margin: 5,                  //---刻度标签与轴线之间的距离
                    //color:'red',              //---默认取轴线的颜色
                },
                splitLine:{                 //---grid 区域中的分隔线
                    show:false,                 //---是否显示,'category'类目轴不显示,此时我的X轴为类目轴,splitLine属性是无意义的
                    lineStyle:{
                        //color:'red',
                        //width:1,
                        //type:'solid',
                    },
                },
                splitArea:{                 //--网格区域
                    show:false,                 //---是否显示,默认false
                },              
                data: ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],//内容
            },
 
            //----------------------  y轴  ------------------------
            yAxis: {
                show:true,                  //---是否显示
                position:'left',            //---y轴位置
                offset:0,                   //---y轴相对于默认位置的偏移
                type:'value',           //---轴类型,默认'category'
                name:'销量',              //---轴名称
                nameLocation:'end',         //---轴名称相对位置value
                nameTextStyle:{             //---坐标轴名称样式
                    color:"#fff",
                    padding:[5,0,0,5],  //---坐标轴名称相对位置
                },
                nameGap:15,                 //---坐标轴名称与轴线之间的距离
                //nameRotate:270,           //---坐标轴名字旋转
 
                axisLine:{                  //---坐标轴 轴线
                    show:true,                  //---是否显示
 
                    //------------------- 箭头 -------------------------
                    symbol:['none', 'arrow'],   //---是否显示轴线箭头
                    symbolSize:[8, 8] ,         //---箭头大小
                    symbolOffset:[0,7],         //---箭头位置
 
                    //------------------- 线 -------------------------
                    lineStyle:{
                        color:'#fff',
                        width:1,
                        type:'solid',
                    },
                },
                axisTick:{                  //---坐标轴 刻度
                    show:true,                  //---是否显示
                    inside:true,                //---是否朝内
                    lengt:3,                    //---长度
                    lineStyle:{
                        //color:'red',          //---默认取轴线的颜色
                        width:1,
                        type:'solid',
                    },
                },
                axisLabel:{                 //---坐标轴 标签
                    show:true,                  //---是否显示
                    inside:false,               //---是否朝内
                    rotate:0,                   //---旋转角度   
                    margin: 8,                  //---刻度标签与轴线之间的距离
                    //color:'red',              //---默认取轴线的颜色
                },
                splitLine:{                 //---grid 区域中的分隔线
                    show:true,                  //---是否显示,'category'类目轴不显示,此时我的y轴为类目轴,splitLine属性是有意义的
                    lineStyle:{
                        color:'#666',
                        width:1,
                        type:'dashed',          //---类型
                    },
                },
                splitArea:{                 //--网格区域
                    show:false,                 //---是否显示,默认false
                }                        
            },
 
            //------------ 内容数据  -----------------
            series: [
                {
                    name: '销量',             //---系列名称
                    type: 'bar',                //---类型
                    legendHoverLink:true,       //---是否启用图例 hover 时的联动高亮
                    label:{                     //---图形上的文本标签
                        show:false,
                        position:'insideTop',   //---相对位置
                        rotate:0,               //---旋转角度
                        color:'#eee',
                    },
                    itemStyle:{                 //---图形形状
                        color:'blue',
                        barBorderRadius:[18,18,0,0],
                    },
                    barWidth:'20',              //---柱形宽度
                    barCategoryGap:'20%',       //---柱形间距
                    data: [3020, 4800, 3600, 6050, 4320, 6200,5050,7200,4521,6700,8000,5020]
                }
            ]
        };

3、条形图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值