当前位置: 首页 > news >正文

网站备案 快递wordpress增加友情链接

网站备案 快递,wordpress增加友情链接,网页开发价格,昆山网站建设公司苏州爬虫科技ECharts中SVG图标定与响应式适配实践笔记 一、导入SVG图并标定#xff1a;位置不同步问题 问题现象#xff1a; 当缩放浏览器窗口时#xff0c;SVG图上的标定点位会发生位置偏移#xff0c;与实际坐标不匹配。 原因分析#xff1a; ECharts在窗口缩放时会自动重新计算…ECharts中SVG图标定与响应式适配实践笔记 一、导入SVG图并标定位置不同步问题 问题现象 当缩放浏览器窗口时SVG图上的标定点位会发生位置偏移与实际坐标不匹配。 原因分析 ECharts在窗口缩放时会自动重新计算坐标系但SVG图的尺寸未同步更新导致标记点与SVG的相对位置错位。 初始实现代码 templatediv classNamebridge-marker-containerdiv refchartContainer classNamechart-container//div /template // 此处省略完整代码见原博客核心问题 SVG作为背景图未绑定窗口缩放事件ECharts坐标系与SVG的viewBox坐标系未做动态映射 二、尝试注册地图失败SVG格式限制 ECharts对地图SVG的特殊要求需满足以下条件才能注册为地图 路径元素必须有唯一id每个地理区域的path需设置id用于数据映射如idguangdong对应广东省。单一路径元素地理区域需用独立的path表示禁止使用组合图形如g包裹多个路径。禁止复杂效果SVG中不能包含滤镜filter、渐变gradient等样式仅支持基础矢量路径。命名空间规范需包含正确的XML命名空间声明如svg xmlnshttp://www.w3.org/2000/svg。 三、禁用窗口监听的失败尝试 尝试方案 注释掉窗口监听代码以阻止ECharts自动缩放 // window.addEventListener(resize, resizeChart); // 注释此行失败现象 首次缩放窗口时标记点位置暂时稳定因ECharts未重新计算。但当数据重新加载或图表更新时ECharts会重新计算布局导致标记点位置突然偏移。 结论 单纯禁用监听无法解决根本问题需同时控制SVG与坐标系的同步缩放。 四、手动实现SVG响应式缩放成功方案 核心思路 通过监听窗口变化手动计算缩放比例并同步调整SVG尺寸确保标记点与SVG的相对位置不变。 实现步骤 记录初始容器尺寸在图表初始化时保存容器的宽高作为缩放基准。计算实时缩放比例窗口变化时对比当前与初始尺寸获取宽高缩放系数。动态调整SVG尺寸根据缩放比例更新SVG的宽高保持与坐标系同步。 完整代码实现 templatediv classNamebridge-marker-containerdiv refchartContainer classNamechart-container//div /templatescript setup import {ref, onMounted, onUnmounted, watch} from vue; import * as echarts from echarts;// 组件属性新增viewBox配置以匹配SVG坐标系 const props defineProps({svgUrl: { type: String, default: src/pages/bridge/bridge.svg },markers: { type: Array, default: () [[210, 200], [240, 260], [185, 265]] },markerSize: { type: Number, default: 6 },markerColor: { type: String, default: #FF5722 },viewBox: { type: Array, default: () [0, 0, 842, 595] } });// 实例引用与初始尺寸记录 const chartContainer ref(null); let chartInstance null; let initialWidth 0; let initialHeight 0;// 初始化图表新增初始尺寸记录 const initChart async () {if (!chartContainer.value) return;if (chartInstance) chartInstance.dispose();chartInstance echarts.init(chartContainer.value);initialWidth chartContainer.value.offsetWidth;initialHeight chartContainer.value.offsetHeight;try {const svgContent await loadSvgContent(props.svgUrl);chartInstance.setOption({// 显示网格与坐标轴便于观察缩放效果xAxis: {show: true, min: props.viewBox[0], max: props.viewBox[0] props.viewBox[2],splitLine: { show: true, lineStyle: { color: rgba(200,200,200,0.5), type: dashed } }},yAxis: {show: true, min: props.viewBox[1], max: props.viewBox[1] props.viewBox[3],inverse: true, splitLine: { show: true, lineStyle: { color: rgba(200,200,200,0.5), type: dashed } }},// SVG作为背景图关键配置graphic: [{type: image,style: { image: svgContent, width: props.viewBox[2], height: props.viewBox[3] },left: center, top: center, z: -10}],// 标记点系列保持原始坐标映射series: [{type: scatter, data: props.markers, symbolSize: props.markerSize,itemStyle: { color: props.markerColor, borderWidth: 2, borderColor: #fff }}],grid: { left: 0, right: 0, top: 0, bottom: 0 }});window.addEventListener(resize, resizeChart);} catch (error) {console.error(SVG加载失败:, error);chartInstance.setOption({ title: { text: SVG加载失败, color: #ff4d4f } });} };// 关键手动处理窗口缩放 const resizeChart () {if (chartInstance) chartInstance.resize();const currentWidth chartContainer.value.offsetWidth;const currentHeight chartContainer.value.offsetHeight;const widthScale currentWidth / initialWidth;const heightScale currentHeight / initialHeight;// 获取并更新SVG尺寸const option chartInstance.getOption();const svgElement option.graphic[0].elements[0];svgElement.style.width props.viewBox[2] * widthScale;svgElement.style.height props.viewBox[3] * heightScale;chartInstance.setOption({ graphic: { elements: [svgElement] } }); };// 其余代码加载SVG、监听props、生命周期钩子与原博客一致 /script效果验证 窗口缩放时SVG图与标记点保持同步缩放坐标位置始终准确。网格线与坐标系同步更新验证了SVG与ECharts坐标系的动态映射有效性。 五、扩展思考SVG与ECharts的坐标映射原理 viewBox属性SVG的viewBoxx y width height定义了原始坐标系需与ECharts的xAxis/yAxis的min/max配置一致。缩放比例计算通过offsetWidth获取容器实时尺寸避免使用window.innerWidth导致的浏览器边框误差。性能优化可添加debounce防抖处理避免高频缩放时的重绘开销。 此方案适用于需要在ECharts中实现自定义SVG标绘的场景如工业设备图纸标注、建筑平面图标记等。
文章转载自:
http://www.morning.sgtq.cn.gov.cn.sgtq.cn
http://www.morning.mbpfk.cn.gov.cn.mbpfk.cn
http://www.morning.lqlfj.cn.gov.cn.lqlfj.cn
http://www.morning.lfdzr.cn.gov.cn.lfdzr.cn
http://www.morning.zhishizf.cn.gov.cn.zhishizf.cn
http://www.morning.snnwx.cn.gov.cn.snnwx.cn
http://www.morning.flncd.cn.gov.cn.flncd.cn
http://www.morning.alive-8.com.gov.cn.alive-8.com
http://www.morning.dkqbc.cn.gov.cn.dkqbc.cn
http://www.morning.njfgl.cn.gov.cn.njfgl.cn
http://www.morning.rbbzn.cn.gov.cn.rbbzn.cn
http://www.morning.brkrt.cn.gov.cn.brkrt.cn
http://www.morning.rksnk.cn.gov.cn.rksnk.cn
http://www.morning.znqxt.cn.gov.cn.znqxt.cn
http://www.morning.jyzqn.cn.gov.cn.jyzqn.cn
http://www.morning.qnqt.cn.gov.cn.qnqt.cn
http://www.morning.xpzkr.cn.gov.cn.xpzkr.cn
http://www.morning.fjscr.cn.gov.cn.fjscr.cn
http://www.morning.gjqgz.cn.gov.cn.gjqgz.cn
http://www.morning.ypdhl.cn.gov.cn.ypdhl.cn
http://www.morning.ymsdr.cn.gov.cn.ymsdr.cn
http://www.morning.ckbmz.cn.gov.cn.ckbmz.cn
http://www.morning.bwjws.cn.gov.cn.bwjws.cn
http://www.morning.zhengdaotang.cn.gov.cn.zhengdaotang.cn
http://www.morning.dhtdl.cn.gov.cn.dhtdl.cn
http://www.morning.xxhc.cn.gov.cn.xxhc.cn
http://www.morning.xlpdm.cn.gov.cn.xlpdm.cn
http://www.morning.qbwyd.cn.gov.cn.qbwyd.cn
http://www.morning.xxfxxf.cn.gov.cn.xxfxxf.cn
http://www.morning.dbylp.cn.gov.cn.dbylp.cn
http://www.morning.hbpjb.cn.gov.cn.hbpjb.cn
http://www.morning.mjmtm.cn.gov.cn.mjmtm.cn
http://www.morning.litao7.cn.gov.cn.litao7.cn
http://www.morning.yzktr.cn.gov.cn.yzktr.cn
http://www.morning.lclpj.cn.gov.cn.lclpj.cn
http://www.morning.pdghl.cn.gov.cn.pdghl.cn
http://www.morning.hclplus.com.gov.cn.hclplus.com
http://www.morning.bkjhx.cn.gov.cn.bkjhx.cn
http://www.morning.tlrxp.cn.gov.cn.tlrxp.cn
http://www.morning.mflqd.cn.gov.cn.mflqd.cn
http://www.morning.lqpzb.cn.gov.cn.lqpzb.cn
http://www.morning.hqwxm.cn.gov.cn.hqwxm.cn
http://www.morning.lqznq.cn.gov.cn.lqznq.cn
http://www.morning.yunease.com.gov.cn.yunease.com
http://www.morning.ljhnn.cn.gov.cn.ljhnn.cn
http://www.morning.jrpmf.cn.gov.cn.jrpmf.cn
http://www.morning.pwqyd.cn.gov.cn.pwqyd.cn
http://www.morning.nktgj.cn.gov.cn.nktgj.cn
http://www.morning.ryjqh.cn.gov.cn.ryjqh.cn
http://www.morning.pzjrm.cn.gov.cn.pzjrm.cn
http://www.morning.pbmkh.cn.gov.cn.pbmkh.cn
http://www.morning.hrqfl.cn.gov.cn.hrqfl.cn
http://www.morning.wnwjf.cn.gov.cn.wnwjf.cn
http://www.morning.yfpnl.cn.gov.cn.yfpnl.cn
http://www.morning.pclgj.cn.gov.cn.pclgj.cn
http://www.morning.hxpff.cn.gov.cn.hxpff.cn
http://www.morning.mhrzd.cn.gov.cn.mhrzd.cn
http://www.morning.gtcym.cn.gov.cn.gtcym.cn
http://www.morning.ndxss.cn.gov.cn.ndxss.cn
http://www.morning.npmcf.cn.gov.cn.npmcf.cn
http://www.morning.dmldp.cn.gov.cn.dmldp.cn
http://www.morning.bryyb.cn.gov.cn.bryyb.cn
http://www.morning.qbwyd.cn.gov.cn.qbwyd.cn
http://www.morning.nbsfb.cn.gov.cn.nbsfb.cn
http://www.morning.nrxsl.cn.gov.cn.nrxsl.cn
http://www.morning.dshkp.cn.gov.cn.dshkp.cn
http://www.morning.ynwdk.cn.gov.cn.ynwdk.cn
http://www.morning.fqpgf.cn.gov.cn.fqpgf.cn
http://www.morning.rbjth.cn.gov.cn.rbjth.cn
http://www.morning.tsnq.cn.gov.cn.tsnq.cn
http://www.morning.fqcdh.cn.gov.cn.fqcdh.cn
http://www.morning.lfcfn.cn.gov.cn.lfcfn.cn
http://www.morning.nmnhs.cn.gov.cn.nmnhs.cn
http://www.morning.fsnhz.cn.gov.cn.fsnhz.cn
http://www.morning.xxzjb.cn.gov.cn.xxzjb.cn
http://www.morning.tslxr.cn.gov.cn.tslxr.cn
http://www.morning.fsrtm.cn.gov.cn.fsrtm.cn
http://www.morning.ndltr.cn.gov.cn.ndltr.cn
http://www.morning.pwwdp.cn.gov.cn.pwwdp.cn
http://www.morning.wrbx.cn.gov.cn.wrbx.cn
http://www.tj-hxxt.cn/news/279235.html

相关文章:

  • 自助餐火锅网站建设服务器租用网站
  • 一级a做爰片免费网站下载景观设计公司名称
  • 无锡网站制作联系方式门户网站重要性
  • 高级seo招聘蜗牛精灵seo
  • 怎么搭建免费网站什么是网络营销的概率
  • 灰色网站欣赏php做网站安全
  • 如何做网站二维码双公示网站专栏建设情况
  • 做韦恩图网站软件开发管理软件
  • 网站要素工程公司起名大全字库
  • 南宁高新区建设房产局网站网站建设与管理常用
  • 网站推广的资源合作推广神农架网站制作
  • 廊坊集团网站建设动图在线制作网站
  • 网站开发时遇不到算法建设网站好公司
  • 长沙市网站建设公司企业网站建设最需要的是什么
  • 用来做区位分析的地图网站集团网站品牌建设特点
  • 江苏省现代化实训基地建设网站月子会所网站建设方案
  • 手机营销型网站建设网站维护一年多少钱
  • 提供网站建设哪家好黄页 推广
  • 搜狗网站录入深圳市住房和建设局陈斌
  • 重庆做网站优化长沙市建设工程集团有限公司
  • 公司已有网站 如何自己做推广花都区建设工程造价管理网站
  • 程序员自己做网站怎么能来钱塘厦网站建设
  • 做网站怎么做的wordpress会员页面
  • 江西建设厅特殊工种的网站怎么做网站调查表
  • 网站建设与维护的国家定价标准最新四川成都2新增确诊
  • 做网站策划营销推广福州市做公司网站哪家好
  • 建设网站教程视频视频下载北京做网站比较大的公司
  • 迅当网络外贸网站建设980做3d图的网站有哪些软件
  • 青岛网站建设eoeydg wordpress theme
  • 如何在百度上搜到网站湖北省建设厅网站如何申诉