Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend in CombinedChartView only shows Legend for LineData #4229

Closed
robertschmid23 opened this issue Nov 22, 2019 · 0 comments
Closed

Legend in CombinedChartView only shows Legend for LineData #4229

robertschmid23 opened this issue Nov 22, 2019 · 0 comments

Comments

@robertschmid23
Copy link

robertschmid23 commented Nov 22, 2019

I have created a CombinedChartView with lineDataSets and CandleDataSets. The CandleDataSets are used to highlight certain data points.

This has all worked fine except for the Legend. When I enable the legend it only shows legend information for the LineDataSets.

I looked into the LegendRenderer and discovered the problem arises here ->

@objc open func computeLegend(data: ChartData)
{
    guard let legend = legend else { return }
    
    if !legend.isLegendCustom
    {
        var entries: [LegendEntry] = []
        
        // loop for building up the colors and labels used in the legend
        for i in 0..<data.dataSetCount

...

The dataSetCount only counts lineDataSets and ignores the candleDataSet. So any data sets after the line data are ignored.

My setup looks like this;
`
self.chartView.data = CombinedChartData()

if let chartView = self.chartView
{
let allData = CombinedChartData()
allData.lineData = LineChartData()
for line in lineData.values
{
if line.isVisible
{
allData.lineData.addDataSet(line)
}
}
allData.candleData = CandleChartData()
for fiducialMark in buttonData.values
{
if fiducialMark.isVisible
{
allData.candleData.addDataSet(fiducialMark)
}
}
chartView.data = allData
chartView.chartDescription?.text = self.fileLabel.stringValue
chartView.needsDisplay = true
chartView.rightAxis.enabled = false
chartView.legend.enabled = true
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant