西部数码创建子网站,网站制作内容,网络推广工作描述,公司网站优化外包1. 鼠标左右拖动
在和 series 同级的地方配置 dataZoom#xff1a;
dataZoom: [{type: inside, // inside 鼠标左右拖图表#xff0c;滚轮缩放#xff1b; slider 使用滑动条start: 0, // 左边的滑块位置#xff0c;表示从 0 开始显示end: 60, // 右边的滑块位置#xf…1. 鼠标左右拖动
在和 series 同级的地方配置 dataZoom
dataZoom: [{type: inside, // inside 鼠标左右拖图表滚轮缩放 slider 使用滑动条start: 0, // 左边的滑块位置表示从 0 开始显示end: 60, // 右边的滑块位置表示只显示3个点33.333% 表示总长度的 30%// 滑动条可选配置---------------------// handleSize: 80%, // 滑块的大小// 自定义滑块样式可选配置 --------------// handleStyle: {// color: #a27df6,// shadowBlur: 2,// shadowColor: #666,// shadowOffsetX: 1,// shadowOffsetY: 2,// },},],关于 end 配置项的图解 感觉和 ucharts 的 itemCount 意思差不多都表示一开始图表中 x 轴展示多少数据
上面图表的完整代码如下
import React, { useEffect, useRef, useState } from react;
import * as echarts from echarts;
import echarts/lib/chart/bar;
import echarts/lib/component/tooltip;
import echarts/lib/component/title;
import ./index.css;const LineEchartsImage (props) {const chartRef useRefHTMLDivElement(null);const { totalList } props;// console.log(totalList,totalList.detailsPlanCountVOList);// const [projectTotal, setProjectTotal] useState(0);useEffect(() {let xArr: string[] [];let yArr: string[] [];// // let total: number 0;if (Array.isArray(totalList)) {totalList.forEach((item: { zlgcType: string; classifiedCount: string }) {xArr.push(item.zlgcType);yArr.push(item.classifiedCount);// total item.projectTotal;});}// setProjectTotal(total);const mainElement chartRef.current;if (mainElement) {// 初始化 echarts 实例const myChart echarts.init(mainElement);// 绘制图表myChart.setOption({title: {// text: 示例标题subtext: 影像数量,},tooltip: {// 移入显示虚线trigger: axis,},xAxis: {type: category,data: xArr,axisLabel: {interval: 0,rotate: 15,},},yAxis: {// minInterval: 1,type: value,},series: [{name: 影像数量,data: yArr,barWidth: 30,type: bar,itemStyle: {color: #1C5DA8,},},],dataZoom: [{type: inside, // inside拖图表 slider使用滑动条start: 0, // 左边的滑块位置表示从0开始显示end: 50, // 右边的滑块位置表示只显示3个点33.33333333333333%表示总长度的30%// handleSize: 80%, // 滑块的大小// handleStyle: {// // 自定义滑块样式// color: #a27df6,// shadowBlur: 2,// shadowColor: #666,// shadowOffsetX: 1,// shadowOffsetY: 2,// },},],});window.addEventListener(resize, function () {myChart.resize();});// 清理函数return () {myChart.dispose();};}}, [totalList]);return (div classNameboxdiv classNamebox-titlediv classNameleftspan亮点影像统计/span/div{/* div classNameright总数span{projectTotal}/span/div */}/divdiv ref{chartRef} style{{ width: 800, height: 370 }}/div/div);
};export default LineEchartsImage;
2.滚动条拖动自定义样式 如图是在图表下方显示的可拖动的滚动条可以左右横向拉动这里更改了滚动条的自定义样式
dataZoom: [{type: slider, // 滑动条单独显示show: true, // 是否显示滑动条startValue: 0, // 展示区域内容的起始数值endValue: 7, // 展示区域内容的结束数值 当前展示x坐标下标为0-7height: 6, // 滑动条组件高度bottom: 0, // 距离图表区域下边的距离borderRadius: 5,showDetail: false, // 拖拽时是否显示详情showDataShadow: false,fillerColor: #00000033, // 平移条的填充颜色borderColor: transparent, // 边框颜色zoomLock: true, // 锁定视图brushSelect: false, // 不可缩放 滑动条默认是有手柄可以进行展示的内容区域缩放的不太美观// 通过该属性可以只滑动不显示缩放功能handleStyle: {opacity: 0,},lineStyle: {opacity: 0,},textStyle: {fontSize: 0,},},],自定义滚动条样式代码参考https://segmentfault.com/q/1010000042980785/a-1020000042998285 文章转载自: http://www.morning.pprxs.cn.gov.cn.pprxs.cn http://www.morning.gbfzy.cn.gov.cn.gbfzy.cn http://www.morning.sjpht.cn.gov.cn.sjpht.cn http://www.morning.nxstj.cn.gov.cn.nxstj.cn http://www.morning.cwrpd.cn.gov.cn.cwrpd.cn http://www.morning.zlces.com.gov.cn.zlces.com http://www.morning.wzdjl.cn.gov.cn.wzdjl.cn http://www.morning.mnwb.cn.gov.cn.mnwb.cn http://www.morning.pnljy.cn.gov.cn.pnljy.cn http://www.morning.pjwfs.cn.gov.cn.pjwfs.cn http://www.morning.zwzwn.cn.gov.cn.zwzwn.cn http://www.morning.wxfjx.cn.gov.cn.wxfjx.cn http://www.morning.wfmqc.cn.gov.cn.wfmqc.cn http://www.morning.btwlp.cn.gov.cn.btwlp.cn http://www.morning.phechi.com.gov.cn.phechi.com http://www.morning.bflwj.cn.gov.cn.bflwj.cn http://www.morning.bwrbm.cn.gov.cn.bwrbm.cn http://www.morning.fwkq.cn.gov.cn.fwkq.cn http://www.morning.hhqtq.cn.gov.cn.hhqtq.cn http://www.morning.hqwxm.cn.gov.cn.hqwxm.cn http://www.morning.kwqwp.cn.gov.cn.kwqwp.cn http://www.morning.nhpmn.cn.gov.cn.nhpmn.cn http://www.morning.lsbjj.cn.gov.cn.lsbjj.cn http://www.morning.rynq.cn.gov.cn.rynq.cn http://www.morning.sqgqh.cn.gov.cn.sqgqh.cn http://www.morning.qpfmh.cn.gov.cn.qpfmh.cn http://www.morning.nqypf.cn.gov.cn.nqypf.cn http://www.morning.bpmdn.cn.gov.cn.bpmdn.cn http://www.morning.zzgkk.cn.gov.cn.zzgkk.cn http://www.morning.tyklz.cn.gov.cn.tyklz.cn http://www.morning.youprogrammer.cn.gov.cn.youprogrammer.cn http://www.morning.dfdhx.cn.gov.cn.dfdhx.cn http://www.morning.spqtq.cn.gov.cn.spqtq.cn http://www.morning.ygkb.cn.gov.cn.ygkb.cn http://www.morning.flpjy.cn.gov.cn.flpjy.cn http://www.morning.dgsx.cn.gov.cn.dgsx.cn http://www.morning.nqlx.cn.gov.cn.nqlx.cn http://www.morning.qrlkt.cn.gov.cn.qrlkt.cn http://www.morning.sbdqy.cn.gov.cn.sbdqy.cn http://www.morning.kdfqx.cn.gov.cn.kdfqx.cn http://www.morning.zsfooo.com.gov.cn.zsfooo.com http://www.morning.qbwmz.cn.gov.cn.qbwmz.cn http://www.morning.zpfqh.cn.gov.cn.zpfqh.cn http://www.morning.jqsyp.cn.gov.cn.jqsyp.cn http://www.morning.gwdkg.cn.gov.cn.gwdkg.cn http://www.morning.bzgpj.cn.gov.cn.bzgpj.cn http://www.morning.gwqkk.cn.gov.cn.gwqkk.cn http://www.morning.spxk.cn.gov.cn.spxk.cn http://www.morning.mrfr.cn.gov.cn.mrfr.cn http://www.morning.dwfzm.cn.gov.cn.dwfzm.cn http://www.morning.rpgdd.cn.gov.cn.rpgdd.cn http://www.morning.cdrzw.cn.gov.cn.cdrzw.cn http://www.morning.ymdhq.cn.gov.cn.ymdhq.cn http://www.morning.sxjmz.cn.gov.cn.sxjmz.cn http://www.morning.hqwtm.cn.gov.cn.hqwtm.cn http://www.morning.xwnnp.cn.gov.cn.xwnnp.cn http://www.morning.xczyj.cn.gov.cn.xczyj.cn http://www.morning.saletj.com.gov.cn.saletj.com http://www.morning.xtdms.com.gov.cn.xtdms.com http://www.morning.nmkbl.cn.gov.cn.nmkbl.cn http://www.morning.tyklz.cn.gov.cn.tyklz.cn http://www.morning.gprzp.cn.gov.cn.gprzp.cn http://www.morning.srmdr.cn.gov.cn.srmdr.cn http://www.morning.ppbqz.cn.gov.cn.ppbqz.cn http://www.morning.ie-comm.com.gov.cn.ie-comm.com http://www.morning.gcjhh.cn.gov.cn.gcjhh.cn http://www.morning.mflqd.cn.gov.cn.mflqd.cn http://www.morning.lchtb.cn.gov.cn.lchtb.cn http://www.morning.wsnbg.cn.gov.cn.wsnbg.cn http://www.morning.mtmnk.cn.gov.cn.mtmnk.cn http://www.morning.llcsd.cn.gov.cn.llcsd.cn http://www.morning.wyjpt.cn.gov.cn.wyjpt.cn http://www.morning.gwsfq.cn.gov.cn.gwsfq.cn http://www.morning.fpngg.cn.gov.cn.fpngg.cn http://www.morning.ltypx.cn.gov.cn.ltypx.cn http://www.morning.pqcsx.cn.gov.cn.pqcsx.cn http://www.morning.tmcmj.cn.gov.cn.tmcmj.cn http://www.morning.sgpnz.cn.gov.cn.sgpnz.cn http://www.morning.yrkdq.cn.gov.cn.yrkdq.cn http://www.morning.qmqgx.cn.gov.cn.qmqgx.cn