AAChartModel / AAChartKit-Swift

📈📊📱💻🖥️An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的现代化声明式数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
https://cocoapods.org/pods/AAInfographics
MIT License
2.42k stars 257 forks source link

折线图左右显示不完整 #501

Open auqarius opened 2 hours ago

auqarius commented 2 hours ago

我在使用的时候发现 chartView 宽度设定值很小的时候,折线图会被截取,表现如下:

正常情况,宽度 400,左右就是有圆角的 IMG_7622

出错情况,宽度 200,左右就被截取了 IMG_7623

代码如下

aaChartView!.frame = CGRect(x: 0,y: 60,width: 200,height: 130)  // height 设定的大小不影响是否截取,但是 width 设定过小就会被截取,如果是 400 就不会被截取
        view.addSubview(aaChartView!)
        aaChartView!.isScrollEnabled = false//Disable chart content scrolling
        aaChartView!.isClearBackgroundColor = true
        aaChartView!.delegate = self as AAChartViewDelegate

        aaChartModel = AAChartModel()
            .chartType(.line)
            .xAxisTickInterval(20)   /// 尝试用这个值去解决问题也没法解决
            .animationType(.easeInOutCubic)
            .dataLabelsEnabled(false)
            .markerRadius(0)
            .colorsTheme([])
            .tooltipEnabled(false)
            .legendEnabled(false)
            .xAxisVisible(false)
            .yAxisVisible(false)
            .yAxisMin(-1)
            .series([
                AASeriesElement()
                    .name("Name")
                    .data([0,0,0,1,5,10,3])
                    .lineWidth(6)
                    .color("#ffffff")
            ])
        aaChartView!.aa_drawChartWithChartModel(aaChartModel!)

有没有什么方法解决呢?

auqarius commented 2 hours ago

经过再次测试,发现与 lineWidth 有关系,lineWidth 设定为 10,那即使把 chatView.width 设定为 400,也会被截取。

截屏 2024-10-17 23 19 09