ChartsOrg / ChartsOrg/Charts

No Data text not shown when CandleChartDataEntry is empty

Open
#4,530 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

## What did you do?
I make wrapper on CandleStickChartView and customize some properties. Everything's works good but empty text not shown when CandleChartDataEntry is empty.
My Code:

```swift
class DefaultCandleStickChartView: CandleStickChartView {

private var chartDataSet: ChartDataSet = .init()

var canShowCompleteDate: Bool = false

private var labels: [String] = []

override init(frame: CGRect) {
super.init(frame: frame)
setupConfiguration()

}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupConfiguration()
}

private func setupConfiguration() {
noDataText = "No data available"
noDataFont = UIFont.MB.title
noDataTextColor = UIColor.black
noDataTextAlignment = .center
isUserInteractionEnabled = false
legend.enabled = false
drawGridBackgroundEnabled = false
xAxis.labelPosition = .bottom
xAxis.drawGridLinesEnabled = false
xAxis.labelFont = UIFont.MB.subTitle
xAxis.labelTextColor = UIColor.lightGray
xAxis.axisLineWidth = 0
leftAxis.drawGridLinesEnabled = false
leftAxis.labelFont = UIFont.MB.subTitle
leftAxis.removeAllLimitLines()
leftAxis.drawZeroLineEnabled = false
leftAxis.drawLimitLinesBehindDataEnabled = false
leftAxis.labelTextColor = UIColor.lightGray
leftAxis.axisLineWidth = 0
rightAxis.enabled = false
xAxis.valueFormatter = self
leftAxis.valueFormatter = self
xAxis.labelRotationAngle = -45

}

func setupChart(chartDataEntryArray: [CandleChartDataEntry], labels: [String]) {
self.labels = labels
let candleChartDataSet = CandleChartDataSet(entries: chartDataEntryArray, label: "Candle chart")
let candleChartData = CandleChartData()
candleChartData.addDataSet(candleChartDataSet)
candleChartDataSet.increasingColor = UIColor.MB.positive
candleChartDataSet.decreasingColor = UIColor.MB.negative

candleChartDataSet.axisDependency = .left
candleChartDataSet.shadowColor = UIColor.darkGray
candleChartDataSet.shadowWidth = 0.7
candleChartDataSet.increasingFilled = true
candleChartDataSet.decreasingFilled = true
candleChartDataSet.decreasingFilled = true
candleChartDataSet.drawValuesEnabled = false
data = candleChartData

}


}

```
## Charts Environment

**Charts version/Branch/Commit Number:**
**Xcode version:**
11
**Swift version:**
5
**Platform(s) running Charts:**
iOS

Contributor guide

Open the contributing guide

Research direction

The report centers on setupChart(chartDataEntryArray:labels:) and the noDataText configuration on CandleStickChartView; start by tracing how empty CandleChartData is rendered. No source file or test is named, so verify the behavior with the supplied empty-entry setup on iOS/Xcode 11 and confirm that the configured “No data available” text appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.