问题
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