ios - Only one label appearing on a BarChart created with Charts -


i want create barchart charts library. working except labels on x axis. first label "jan" appearing on line. code

override func viewwillappear(_ animated: bool) {         dobarchart()     }      func dobarchart(){           barchartview.drawbarshadowenabled = false         barchartview.drawvalueabovebarenabled = true         barchartview.chartdescription?.enabled = false          barchartview.maxvisiblecount = 60          let xaxis  = barchartview.xaxis         xaxis.axislinecolor = uicolor.black         xaxis.labelposition = .bottom         xaxis.drawaxislineenabled = true         xaxis.drawgridlinesenabled = false         xaxis.granularity = 1.0         xaxis.labelcount = 1        // xaxis.setlabelcount(7, force: true)         let months = ["jan", "feb", "mar", "apr", "may", "jun", "jul",]          xaxis.valueformatter = indexaxisvalueformatter(values:months)         //also, want add:            let leftaxis = barchartview.leftaxis;         leftaxis.enabled = false         leftaxis.drawaxislineenabled = false;         leftaxis.drawgridlinesenabled = false;         leftaxis.axisminimum = 0.0; // replaces startatzero = yes          let rightaxis = barchartview.rightaxis         rightaxis.enabled = false;          rightaxis.drawaxislineenabled = true;         rightaxis.drawgridlinesenabled = false;         rightaxis.axisminimum = 0.0; // replaces startatzero = yes          let l = barchartview.legend         l.enabled =  false          barchartview.fitbars = true;         barchartview.animate(xaxisduration: 0.2, yaxisduration: 1.0, easingoptionx: .easeinexpo, easingoptiony: .easeinexpo)          setdatacount(count: 7, range: 50)      }       func setdatacount(count: int, range: double){          let barwidth = 7.0         let spaceforbar =  10.0          var yvals = [barchartdataentry]()           yvals.append(barchartdataentry(x: double(0) * spaceforbar, y: 44.5))         yvals.append(barchartdataentry(x: double(1) * spaceforbar, y: 78.1))         yvals.append(barchartdataentry(x: double(2) * spaceforbar, y: 50.3))         yvals.append(barchartdataentry(x: double(3) * spaceforbar, y: 56.6))         yvals.append(barchartdataentry(x: double(4) * spaceforbar, y: 20.5))         yvals.append(barchartdataentry(x: double(5) * spaceforbar, y: 44.3))         yvals.append(barchartdataentry(x: double(6) * spaceforbar, y: 54.4))          var set1 : barchartdataset!           if let count = barchartview.data?.datasetcount, count > 0{             set1 = barchartview.data?.datasets[0] as! barchartdataset             set1.values = yvals             set1.colors = [uicolor.black,uicolor.orange,uicolor.red,uicolor.green,uicolor.yellow,uicolor.blue,uicolor.gray]             barchartview.data?.notifydatachanged()             barchartview.notifydatasetchanged()          }else{             set1 = barchartdataset(values: yvals, label: "dataset")             set1.colors = [uicolor.black,uicolor.orange,uicolor.red,uicolor.green,uicolor.yellow,uicolor.blue,uicolor.gray]               var datasets = [barchartdataset]()             datasets.append(set1)              let data = barchartdata(datasets: datasets)               data.barwidth =  barwidth;              barchartview.data = data          }     } 

add following delegate method of "iaxisvalueformatter"  , assign these delegate.  class xyz :  iaxisvalueformatter{  weak var axisformatdelegate: iaxisvalueformatter?  //add these line in func...  func dobarchart{   let xaxisvalue = linechartview.xaxis         xaxisvalue.valueformatter = axisformatdelegate         linechartview.xaxis.granularityenabled = true         linechartview.xaxis.granularity = 1.0 }  //add these method..   func stringforvalue(_ value: double, axis: axisbase?) -> string {         return yvlaues[int(value) % yvlaues.count]   } } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -