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

委托广告公司做的网站违法了整站seo排名要多少钱

委托广告公司做的网站违法了,整站seo排名要多少钱,注册公司北京,个人网站方案建设书引言 大数据量渲染性能优化,在地图上渲染2000个ECharts饼图,直接渲染会导致页面卡顿甚至崩溃 解决方案: 实现视口检测机制,只渲染当前可见区域内的数据点使用分块渲染策略,每次只处理15ms的计算任务,避免…

引言

大数据量渲染性能优化,在地图上渲染2000个ECharts饼图,直接渲染会导致页面卡顿甚至崩溃

解决方案:

  • 实现视口检测机制,只渲染当前可见区域内的数据点
  • 使用分块渲染策略,每次只处理15ms的计算任务,避免阻塞主线程
  • 采用防抖技术优化地图移动/缩放事件的触发频率

在这里插入图片描述

示例代码—不是伪代码可以直接复制到项目跑通

<template><div class="map-container" ref="mapContainer"></div>
</template><script>
import L from 'leaflet'
import 'leaflet/dist/leaflet.css'
import * as echarts from 'echarts'export default {name: 'MapComponent',data() {return {map: null,points: [], // 存储所有点数据renderedCharts: new Map(), // 已渲染的图表chartInstances: new Map(), // Echarts实例debounceTimer: null,pointsMap: new Map(),}},mounted() {this.initMap()this.generatePoints(2000) // 生成2000个点数据this.renderVisiblePoints()// 监听地图移动和缩放事件this.map.on('moveend zoomend', this.debounce(this.renderVisiblePoints, 300))},beforeDestroy() {// 清理资源if (this.map) {this.map.off('moveend zoomend', this.renderVisiblePoints)this.map.remove()}// 销毁所有Echarts实例this.chartInstances.forEach((chart) => {if (chart) chart.dispose()})this.renderedCharts.clear()this.chartInstances.clear()},methods: {initMap() {// 初始化Leaflet地图this.map = L.map(this.$refs.mapContainer).setView([39.90923, 116.397428],12)// 添加地图图层L.tileLayer('http://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',}).addTo(this.map)},// 生成随机点数据generatePoints(count) {const points = []for (let i = 0; i < count; i++) {// 在北京区域内生成随机点const lat = 39.5 + Math.random() * 1.0const lng = 115.5 + Math.random() * 1.5points.push({id: i,lat,lng,data: [{ value: Math.random() * 100, name: '类别1' },{ value: Math.random() * 100, name: '类别2' },{ value: Math.random() * 100, name: '类别3' },{ value: Math.random() * 100, name: '类别4' },],})}this.points = pointsthis.pointsMap = new Map(this.points.map((point) => [point.id, point]))},// 判断点是否在可见区域内isPointInBounds(point) {const bounds = this.map.getBounds()return bounds.contains([point.lat, point.lng])},// 渲染可见区域内的点renderVisiblePoints(n = 0) {const bounds = this.map.getBounds()const zoom = this.map.getZoom()// 清除不在可见区域内的图表this.renderedCharts.forEach((marker, id) => {const point = this.pointsMap.get(id)if (!point || !this.isPointInBounds(point)) {marker.remove()this.renderedCharts.delete(id)// 销毁Echarts实例if (this.chartInstances.has(id)) {this.chartInstances.get(id).dispose()this.chartInstances.delete(id)}}})// 1. 优化后:渲染可见区域内的点,每次只计算15ms,之后就立马把剩余没做的方法settimeout的宏任务里let startTime = Date.now()for (; n < this.points.length; n++) {let endTime = Date.now()const point = this.points[n]if (this.isPointInBounds(point) && !this.renderedCharts.has(point.id)) {this.createChartMarker(point)}if (endTime - startTime > 15) {setTimeout(() => {this.renderVisiblePoints(n)}, 0)break}}// 2. 优化前:一次性渲染所有点// this.points.forEach((point) => {//   if (this.isPointInBounds(point) && !this.renderedCharts.has(point.id)) {//     this.createChartMarker(point)//   }// })},// 创建带有Echarts饼图的地图标记createChartMarker(point) {// 创建一个div用于渲染Echartsconst chartDiv = document.createElement('div')chartDiv.style.width = '100px'chartDiv.style.height = '100px'chartDiv.id = `chart-${point.id}`// 创建自定义HTML标记const customMarker = L.divIcon({html: chartDiv.outerHTML,className: 'custom-chart-marker',iconSize: [100, 100],iconAnchor: [50, 50],})// 添加标记到地图const marker = L.marker([point.lat, point.lng], {icon: customMarker,}).addTo(this.map)this.renderedCharts.set(point.id, marker)// 确保div已添加到DOM后再初始化Echartsthis.$nextTick(() => {const chartDom = document.getElementById(`chart-${point.id}`)if (!chartDom) returnconst chart = echarts.init(chartDom)// 设置Echarts配置const option = {series: [{type: 'pie',radius: '50%',data: point.data,label: {show: false,},emphasis: {label: {show: true,formatter: '{b}: {c}',},},},],}chart.setOption(option)this.chartInstances.set(point.id, chart)// 监听地图缩放事件,调整图表大小this.map.on('zoomend', () => {if (!chart._disposed) {// console.log(chart)chart.resize()} else {this.chartInstances.delete(point.id)}})})},// 防抖函数debounce(func, delay) {return () => {clearTimeout(this.debounceTimer)this.debounceTimer = setTimeout(() => {func.apply(this)}, delay)}},},
}
</script><style scoped>
.map-container {width: 100vw;height: 100vh;
}.custom-chart-marker {background: none !important;border: none !important;
}
</style>
http://www.dtcms.com/wzjs/433654.html

相关文章:

  • 网站建设属于哪个税收服务编码站长工具域名查询社区
  • 北京建设信源咨询有限公司网站域名服务器ip查询网站
  • wordpress关键字替换石家庄seo网站管理
  • 策划方案免费的网站seo引擎优化外包公司
  • 新网站应该怎么做seo网站优化关键词公司
  • 深圳建设工程交易服务网龙岗分中心北京网络排名优化
  • 在网站文字上做笔记百度24小时人工客服电话
  • 免备案网站建站私域流量运营管理
  • 美工是做什么的绍兴seo计费管理
  • win 2008 iis建立网站指数运算法则
  • 桥西区网站建设东莞网络推广招聘
  • 工信部信息备案网站首页万能引流软件
  • 如何规划企业网络推广方案需要优化的网站有哪些?
  • 无锡微信网站开发seo怎么发布外链
  • 做网站时的兼容问题上海百度推广
  • 宁夏政府采购网东莞网络优化公司
  • 期货交易网站开发域名网站查询
  • 网站建设分金手指排名四广州seo网站推广公司
  • c 网站开发 书百度推广平台登录网址
  • 自适应手机网站 css优化网站平台
  • 门头沟新乡网站建设seo文章优化方法
  • asp.net 做网站实例如何推广引流
  • 用自己电脑做服务器 网站seo广告优化多少钱
  • 设计师服务平台卡密号网站seo推广员招聘
  • 如何做单页网站网推怎么做
  • 盐城市城乡建设局网站建站宝盒
  • 盐山县招聘网站建设代运营公司
  • 网站改版 打造企业文化郑州网站seo优化公司
  • 代做网页设计作业价格厦门seo外包公司
  • 企业网站备案好不好百度商务合作联系