echarts 百度图表 缩放

3 篇文章 0 订阅

项目中用到的,vue的 直接看吧

dataZoom 就是缩放内容
在这里插入图片描述

	 <template>
		  <div>
		    <!-- 图表 -->
		    <div class="pl_20">
		      <div id="myChart" ref="myChart"></div>
		    </div>
		  </div>
		</template>
		<style scoped lang='less' rel='stylesheet/less'>
		#myChart {
		  width: 100%;
		  height: 6.8rem;
		}
		</style>
		<script>
		// 引入完整的echarts
		import echarts from "echarts";
		export default {
		  data() {
		    return {
		      timeData: ["00:00", "06:00", "12:00", "18:00", "24:00"],
		      NumberDara: [15, 81, 201, 10, 90],
		    };
		  },
		  mounted() {
		    // 调用绘制图表的方法
		 	this.draw()
		  },
		  methods: {
		    draw() {
		      // 实例化echarts对象
		      var myChart = echarts.init(this.$refs.myChart);
		      var fontColor = "#F65D31";
		      // 绘制条形图
		      myChart.setOption({
		        backgroundColor: "#fff",
		        grid: {
		          left: "0%",
		          right: "9%",
		          top: "8%",
		          bottom: "20%",
		          containLabel: true
		        },
		        xAxis: [
		          {
		            axisLabel: {
		              show: true,
		              textStyle: {
		                color: "#333"
		              }
		            },
		            type: "category",
		            boundaryGap: false,
		            axisLine: {
		              show: true,
		              lineStyle: {
		                color: "#c8c8c8"
		              }
		            },
		            splitLine: {
		              show: false
		            },
		            data: this.timeData
		          }
		        ],
		        yAxis: [
		          {
		            axisLabel: {
		              show: true,
		              textStyle: {
		                color: "#333"
		              }
		            },
		            axisLine: {
		              lineStyle: {
		                color: "#c8c8c8"
		              }
		            },
		            splitLine: {
		              show: false
		            }
		          }
		        ],
		        dataZoom: [
		          {
		            show: true,
		            height: 40,
		            xAxisIndex: [0],
		            bottom: "8px",
		            start: 10,
		            end: 90,
		            handleIcon:
		              "path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z",
		            handleSize: "110%",
		            handleStyle: {
		              color: "#ff7b06"
		            },
		            textStyle: {
		              color: "#90979c"
		            },
		            borderColor: "#90979c"
		          },
		          {
		            type: "inside",
		            show: true,
		            height: 15,
		            start: 1,
		            end: 35
		          }
		        ],
		        series: [
		          {
		            name: "浏览量",
		            type: "line",
		            stack: "总量",
		            symbol: "circle",
		            symbolSize: 10,
		            itemStyle: {
		              normal: {
		                color: "#F65D31",
		                lineStyle: {
		                  color: "#F65D31",
		                  width: 1
		                },
		                barBorderRadius: 0,
		                label: {
		                  show: true,
		                  position: "top",
		                  formatter: function(p) {
		                    return p.value > 0 ? p.value : "";
		                  }
		                },
		                areaStyle: {
		                  color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
		                    {
		                      offset: 0,
		                      color: "rgba(7,44,90,0)"
		                    },
		                    {
		                      offset: 1,
		                      color: "rgba(114,144,89,0)"
		                    }
		                  ])
		                }
		              }
		            },
		            data: this.NumberDara
		          }
		        ]
		      });
		    },
		  }
		};
		</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值