19

I am trying to remove Description Label in ios-chart library. You can see it on the image below:

enter image description here

And I know that, on Android (MPAndroidChart library which is the predecessor of ios-chart), I can do the following:

barchart.setDescription(" ");

but I am trying to do the same on Swift:

barchart.description = ""

and I am getting the following error:

Cannot assign to property: 'description' is immutable

I have looked on the Internet and here in StackOverflow but could not see anything to remove it.

Is it possible to remove that Description Label on ios-chart library?

Thanks in advance!

Francisco Romero
  • 12,787
  • 22
  • 92
  • 167

4 Answers4

50

It's descriptionText, not description, description is NSObject variable

On Swift 3.0 and Chart 3.0:

barchart.chartDescription?.text = ""
Tj3n
  • 9,837
  • 2
  • 24
  • 35
  • Thank you very much! In `Swift 3.0` I could see that it is deprecated so you should use `barchart.chartDescription?.text = ""`. I will accept the answer as fast I could. +1 by the moment :D – Francisco Romero Sep 21 '16 at 09:49
  • 1
    thanks for the edit :D i was still using swift 2 version so it's that one – Tj3n Sep 21 '16 at 09:56
14

It could work better in Swift 3.0 by disabling as

   barChart.chartDescription?.enabled = false
Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
Ade
  • 363
  • 3
  • 13
0

In new version description is not a String its ChartDescription class.

ChartDescription *desc = [[ChartDescription alloc]init];
desc.text = @"";
chart.chartDescription = desc;
Atan
  • 168
  • 2
  • 4
0

For swift 4

barChart.chartDescription?.text = ""

Jigar Thakkar
  • 6,834
  • 2
  • 17
  • 15