• 前端大屏可视化项目


    这篇文章记录了我开发中遇到的问题和解决方法。

    1、确定需要适配屏幕的大小,虽然我们前端默认大屏的1920*1080起步的,但是防止有人不懂开发前需要新搞清楚适配范围;

    2、和UI说清楚字体大小尽量在12px以上,一是12px以下写起来麻烦;二是12px以下在大屏中展示效果不好;

    3、不同大小屏幕的适配方法 我使用的是zoom,其中1920是设计稿的宽度

    const s = window.innerWidth / 1920
    document.body.style.zoom = s + ''
    
    • 1
    • 2

    当然transform scale 和rem等方式也行;

    4、大屏中有很多样式很难实现,可能会使用很多图片代替,图片太多可以使用雪碧图来优化;

    5、DataV组件库中的轮播表config数据更新后视图不发生变化的解决方法:

    this.config.data = ['foo', 'foo']是无效的
    
    this.config = { data: ['foo', 'foo'] }才是有效的
    
    • 1
    • 2
    • 3

    6、3d柱形图的实现:模仿了
    https://gallery.echartsjs.com/editor.html?c=xH0E6KFMcG

    7、 实现下图的进度条效果在这里插入图片描述

    使用背景图片
    在这里插入图片描述

    background-position: ${100 - item.‘百分比’}%;
    
    • 1

    8、 折线图渐变背景色:模仿https://echarts.apache.org/examples/zh/editor.html?c=line-tooltip-touch

    9、点击屏幕左边在屏幕右边弹窗,点击屏幕右边在屏幕左边弹窗功能的实现(配合3中的zoom可适配不同屏幕),
    使用下面代码可以获取点击的位置;

    function getElementPos (elementId) {
        var ua = navigator.userAgent.toLowerCase()
        var el = document.getElementById(elementId)
        if (el.parentNode === null || el.style.display === 'none') {
            return false
        }
        var parent = null
        var pos = []
        var box
        if (el.getBoundingClientRect) { // IE
            box = el.getBoundingClientRect()
            var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop)
            var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft)
            return { x: box.left + scrollLeft, y: box.top + scrollTop }
        } else if (document.getBoxObjectFor) { // gecko
            box = document.getBoxObjectFor(el)
            var borderLeft = (el.style.borderLeftWidth) ? parseInt(el.style.borderLeftWidth) : 0
            var borderTop = (el.style.borderTopWidth) ? parseInt(el.style.borderTopWidth) : 0
            pos = [box.x - borderLeft, box.y - borderTop]
        } else { // safari & opera
            pos = [el.offsetLeft, el.offsetTop]
            parent = el.offsetParent
            if (parent !== el) {
                while (parent) {
                    pos[0] += parent.offsetLeft
                    pos[1] += parent.offsetTop
                    parent = parent.offsetParent
                }
            }
            if (ua.indexOf('opera') !== -1 || (ua.indexOf('safari') !== -1 && el.style.position === 'absolute')) {
                pos[0] -= document.body.offsetLeft
                pos[1] -= document.body.offsetTop
            }
        }
        if (el.parentNode) {
            parent = el.parentNode
        } else {
            parent = null
        }
        while (parent && parent.tagName !== 'BODY' && parent.tagName !== 'HTML') { // account for any scrolled ancestors
            pos[0] -= parent.scrollLeft
            pos[1] -= parent.scrollTop
            if (parent.parentNode) {
                parent = parent.parentNode
            } else {
                parent = null
            }
        }
        return { x: pos[0], y: pos[1] } // 返回点击位置的坐标
    }
    
    this.isLeft = getElementPos(idName).x > 960
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
  • 相关阅读:
    发第一篇SCI有哪些技巧?
    Mysql高级——Mysql8一主一从,多主多从搭建
    LeetCode 热题 C++ 53. 最大子数组和 55. 跳跃游戏
    09-MySQL主从复制
    Apache Doris系列之:深入认识实时分析型数据库Apache Doris
    Good idea of English learning
    Purple Pi OH鸿蒙开发板7天入门OpenHarmony开源鸿蒙教程【五】
    【函数式编程】Java函数式编程学习
    Rust的高效易用日志库—tklog
    3.Tornado注意事项
  • 原文地址:https://blog.csdn.net/efew212efe/article/details/125492631