
I set "noDataText", but it does not work, it always be "no chart data available." when the chart is empty even i change the value of "noDataText" in ChartViewBase.swift
How do you change it. It should be working:
/// text that is displayed when the chart is empty
open var noDataText = "No chart data available."
@liuxuan30 I set a value for "noDataText", it does not work, and i try to change source code like this:
/// text that is displayed when the chart is empty
open var noDataText = "Other Value"
it does not work too, the empty chart always display "No chart data available"
I just tried and it works just fine. I believe you should made some simple mistakes. Check from:
open override func draw(_ rect: CGRect)
{
let optionalContext = NSUIGraphicsGetCurrentContext()
guard let context = optionalContext else { return }
let frame = self.bounds
if _data === nil && noDataText.characters.count > 0
{
context.saveGState()
defer { context.restoreGState() }
ChartUtils.drawMultilineText(
context: context,
text: noDataText,
point: CGPoint(x: frame.width / 2.0, y: frame.height / 2.0),
attributes:
[NSFontAttributeName: noDataFont,
NSForegroundColorAttributeName: noDataTextColor],
constrainedToSize: self.bounds.size,
anchor: CGPoint(x: 0.5, y: 0.5),
angleRadians: 0.0)
return
}
debug into here to see how noDataText is fed.
Got the same issue. Setting noDataText or noDataTextColor doesn't change anything.
All the other attributes work as expected.
// Works
cell.chartView.backgroundColor = UIColor.clear
cell.chartView.chartDescription!.enabled = false
cell.chartView.drawGridBackgroundEnabled = false
cell.chartView.dragEnabled = false
cell.chartView.pinchZoomEnabled = false
cell.chartView.setScaleEnabled(false)
cell.chartView.xAxis.enabled = false
cell.chartView.rightAxis.enabled = false
cell.chartView.leftAxis.enabled = false
cell.chartView.legend.enabled = false
// Doesn't work
cell.chartView.noDataText = "Foo"
cell.chartView.noDataTextColor = UIColor.white
Nevermind, got it working by placing it before draw().
Nevermind, got it working by placing it before draw().
How ? do we directly calling draw method ? where did you placed the noDataText ?
I have same this problem . I called chart.nodatatext = "text" at ViewdidLoad . It work for me. Hope it useful . Thanks
I have same this problem . I called chart.nodatatext = "text" at ViewdidLoad . It work for me. Hope it useful . Thanks
worked for me, Thanks man
Most helpful comment
I have same this problem . I called chart.nodatatext = "text" at ViewdidLoad . It work for me. Hope it useful . Thanks