Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xrange类型的图表支持隐藏Y轴段无数据的那行吗? #6

Open
Maxcucurbit opened this issue Apr 2, 2024 · 2 comments
Open

Comments

@Maxcucurbit
Copy link

Maxcucurbit commented Apr 2, 2024

红框内的是没数据的,有什么办法隐藏它吗?
1712027011965

@AAChartModel
Copy link
Owner

   public class var xrangeData: [Any] {
        func getSingleGroupCategoryDataElementArrayWithY(_ y: Int) -> [Any] {
            var dataArr = [Any]()
            
            var x = 0
            var x2 = x + Int(arc4random()) % 10
            for _ in 0 ..< 50 {
                var dataElementDic = [String:Any]()
                dataElementDic["x"] = x
                dataElementDic["x2"] = x2
                dataElementDic["y"] = y
                dataArr.append(dataElementDic)
                x = x2 + Int(arc4random()) % 1000
                x2 = x + Int(arc4random()) % 2000
            }
            return dataArr
        }
        
        var dataArr = [Any]()
        for y in 0 ..< 20 {
            let data = getSingleGroupCategoryDataElementArrayWithY(y)
            for dataElement in data {
                dataArr.append(dataElement)
            }
        }
        return dataArr
    }

参考 demo 中生成 xrange 图表测试数据的示例代码, 应该是需要你自己过滤数据数据源:

  • data 数组中 xx2 的值相等的元素 dataElementDic过滤掉

@Maxcucurbit
Copy link
Author

   public class var xrangeData: [Any] {
        func getSingleGroupCategoryDataElementArrayWithY(_ y: Int) -> [Any] {
            var dataArr = [Any]()
            
            var x = 0
            var x2 = x + Int(arc4random()) % 10
            for _ in 0 ..< 50 {
                var dataElementDic = [String:Any]()
                dataElementDic["x"] = x
                dataElementDic["x2"] = x2
                dataElementDic["y"] = y
                dataArr.append(dataElementDic)
                x = x2 + Int(arc4random()) % 1000
                x2 = x + Int(arc4random()) % 2000
            }
            return dataArr
        }
        
        var dataArr = [Any]()
        for y in 0 ..< 20 {
            let data = getSingleGroupCategoryDataElementArrayWithY(y)
            for dataElement in data {
                dataArr.append(dataElement)
            }
        }
        return dataArr
    }

参考 demo 中生成 xrange 图表测试数据的示例代码, 应该是需要你自己过滤数据数据源:

  • data 数组中 xx2 的值相等的元素 dataElementDic过滤掉

试过了,没有用,出现Y轴空档的情况是这样产生的,假设Y为1和3的时候都是有数据的,Y2没有数据就会一直空在那,并不会被隐藏掉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants