Change position of labels to be inside data set circles

允我心安 提交于 2020-01-05 03:37:09

问题


I am using the iOS-Charts framework and have the following chart:

I would like to change the position of the numbers (labels) to appear within the circle. Is it possible to achieve this?


回答1:


Inside LineChartRenderer.swift, increased the value of y when text is being drawn, I increase it by 30 in this example:

 if dataSet.isDrawValuesEnabled {
                    ChartUtils.drawText(
                        context: context,
                        text: formatter.stringForValue(
                            e.y,
                            entry: e,
                            dataSetIndex: i,
                            viewPortHandler: viewPortHandler),
                        point: CGPoint(
                            x: pt.x,
                            y: pt.y - CGFloat(valOffset) - valueFont.lineHeight  + 30),
                        align: .center,
                        attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)])
 }

Result:



来源:https://stackoverflow.com/questions/44910889/change-position-of-labels-to-be-inside-data-set-circles

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!