Change position of labels to be inside data set ci

2019-07-31 12:38发布

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

enter image description here

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

1条回答
Evening l夕情丶
2楼-- · 2019-07-31 13:22

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:

enter image description here

查看更多
登录 后发表回答