echarts图表

<html>
  <head>
    <meta charset="utf-8" />
    <title>ECharts</title>
    <!-- 引入刚刚下载的 ECharts 文件 -->
    <script src="echarts-5.2.1/dist/echarts.min.js"></script>
  </head>
  <body>
    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
      // 基于准备好的dom,初始化echarts实例
      data_y = [5, 20, 36, 10, 10, 20];
      data_x = ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'];
      var myChart = echarts.init(document.getElementById('main'));

      // 指定图表的配置项和数据
      var option = {
        title: {
          text: 'ECharts 入门示例'
        },
        
        grid:{   //显示网格
          show:true
        },
        tooltip: {
          show:true  //提示框组件
        },
        legend: {
          data: ['销量']     //显示图例
        },
        xAxis: {
            type:'value',
          //   axisLine: {
          //     symbol:'arrow',
          //     lineStyle: {
          //     type: 'dashed'
          //   }
          // }
          axisLine: {
            show:true,    //设置x轴是否可见
            symbol: ['none', 'triangle'], //只在末端显示箭头
            symbolOffset: 8, // 偏移距离
            symbolSize: [10, 15], // 箭头宽高
            lineStyle: {
              color: '#054E8C', // 坐标轴颜色
            },

        }
          
        },
        yAxis: {
          type:'category',
          show:true,
          data: data_x,
          axisLine: {
            symbol: ['none', 'triangle'], //只在末端显示箭头
            symbolOffset: 8, // 偏移距离
            symbolSize: [10, 15], // 箭头宽高
            lineStyle: {
            color: '#054E8C', // 坐标轴颜色
            },

        }
        },
        series: [
          {
            name: '销量',
            type: 'bar',
            stack: 'samestack',
            data:data_y,
            markLine:{      //设置标线
            
            tooltip: {
            show:false  //提示框组件
              },
              symbol:['none','none'],  //清除标线两端的样式,可以这样显示末端的箭头或者清除末端的箭头
              data:[{
                type:"average",
                name:'平均值',
                lineStyle:{
                cap:'butt',   //设置标线末端的样式,但是这样清除不了末端默认的箭头
                type:'solid'
                }
              }],
              label:{
                //这里是设置标线的标签显示,包括标线的文本内容,文本的样式等
                // padding:[-13,-20,15,-40],
                show:true ,
                formatter:'{a}{b}的值是{c}'
              },
              itemStyle:{
                // color: '#F43368'
               
              }
            },
            label:{
                show:true,
                // data:data_y,
                formatter:'{b}的值是{c}',   //设置柱状图的标签显示文字
                // rotate:90,
                fontStyle:"oblique"
            },
            // labelLine:{     
            //     show:true,
            //     lineStyle:{
            //         color:"#b",
            //         width:1,
            //         type:'solid'
            //     }
            // },
            itemStyle:{
              // color: '#F43368',
		          barBorderRadius: [0, 20, 20, 0], // (顺时针左上,右上,右下,左下)

            }
          },
          {
				//name: 'Video Ad',
				type: 'bar',
				stack: 'samestack',     //柱状图的堆叠样式
				// barWidth: 5, //柱图宽度
				data: ['20','20','20','20','20','20'],
				itemStyle: {
          
					normal: {
            color:"#ff3333",   //给柱状图添加颜色
						label: {
							show: true,
							// formatter: item => {
							// 	// return left_value+'%'
							// 	return item.data + '%'
							// }
						}
					}
				},
			},
        ]
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    </script>
  </body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值