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

Radar charts custom labels #1840

Closed
chipp opened this issue Nov 16, 2016 · 8 comments
Closed

Radar charts custom labels #1840

chipp opened this issue Nov 16, 2016 · 8 comments

Comments

@chipp
Copy link

chipp commented Nov 16, 2016

Custom radar chart labels are broken.
I added this code to ChartsDemo-OSX/ChartsDemo-OSX/Demos/RadarDemoViewController.swift:

data.setLabels("a", "b", "c", "d", "e", "f", "g", "h", "k")

but RadarChartView ignores these labels.
screenshot 2016-11-16 23 07 48

I think problem is in this line: XAxisRendererRadarChart.swift#L57

XAxisRendererRadarChart ignores RadarChartData.labels property.

@liuxuan30
Copy link
Member

liuxuan30 commented Nov 18, 2016

I think you should use valueFormatter to do that, as you already see where it formats.. Labels are just labels sometimes.

@chipp
Copy link
Author

chipp commented Nov 18, 2016

/// Sets labels that should be drawn around the RadarChart at the end of each web line.
    open var labels: [String]

ok...

@liuxuan30
Copy link
Member

liuxuan30 commented Nov 18, 2016

@chipp lol. But the code tells everthing :(
@danielgindi looks like labels are not used anymore?

@liuxuan30 liuxuan30 reopened this Nov 18, 2016
@tlimp
Copy link

tlimp commented May 3, 2017

any news here?

@chipp
Copy link
Author

chipp commented May 3, 2017

@tlimp this is my production solution:

chartView.xAxis.valueFormatter = RadarChartXValueFormatter(withLabels: labels)
class RadarChartXValueFormatter: NSObject, IAxisValueFormatter {

  init(withLabels labels: String...) {
    self.labels = labels
    super.init()
  }

  init(withLabels labels: [String]) {
    self.labels = labels
    super.init()
  }

  var labels: [String]

  func stringForValue(_ value: Double, axis: AxisBase?) -> String {
    let index = Int(value)
    return labels.indices ~= index ? labels[index] : ""
  }

}

@tlimp
Copy link

tlimp commented May 3, 2017

@chipp
thanks, for the help. at least it renders the labels. but it also renders a large white space left and right padding/margin, so the chart gets illegible. margin/padding are much larger than needed by the labels
in a previous version (2.2.3 I guess) it worked as expected, making the chart as large as possible so the labels where still readable.

@lingzlu
Copy link

lingzlu commented Jul 28, 2017

same issue here, have labels with roughly 10 characters and it's shrinking the chart a lot sometimes the chart is not readable at all :(

@jjatie jjatie closed this as completed Apr 1, 2018
@mamilov
Copy link

mamilov commented May 31, 2021

The issue with white spaces is still present! Does anyone know how to remove those?
image

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

6 participants