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

values from array for x axis on barchart #1331

Closed
seal62 opened this issue Aug 17, 2016 · 5 comments
Closed

values from array for x axis on barchart #1331

seal62 opened this issue Aug 17, 2016 · 5 comments

Comments

@seal62
Copy link

seal62 commented Aug 17, 2016

I am using the new version of Charts and can figure out how to take a string value from an array and use it as the x-axis value. Using the examples provided I have the below, which generates a bar chart with these y values but x is just 0, 1, 2, 3 etc.. how do I change that to use the days array values? looking at the BarChartEntry class it only accepts Doubles?

let values: [Double] = [8, 104, 81, 93, 52, 44, 97]
let days: [String] = ["mon", "tues", "weds", "thurs", "fri", "sat", "sun"]

var entries: [ChartDataEntry] = Array()

for (i, value) in values.enumerate()
        {
            entries.append(BarChartDataEntry(x: Double(i), y: value))
        }

@jj-12
Copy link

jj-12 commented Aug 17, 2016

@seal62 , You mean the labels for the x axis? You don't set the x-axis label on the BarChartEntryData, you set it on the BarChartData object. See the tutorial at the end of this comment as well as the demo classes in this repo for examples.

e.g., let data: BarChartData = BarChartData(xVals: days)

Hope this helps,

https://www.codebeaulieu.com/96/How-to-create-a-Combined-Bar-and-Line-chart-using-ios-charts

@seal62
Copy link
Author

seal62 commented Aug 18, 2016

@jj-12 thank you for the response but I think you are talking about Charts 2.2.5 which allowed you to init the BarChartData with xVals. Charts 3.0 only allows init with dataSet but does not include arguements for xVals

let data = BarChartData(dataSet: [IChartDataSet?])

Unfortunately all the tutorials I can find online use the old version of Charts, there doesnt seem to be anything on 3.0 which uses a new method of generating the charts

@sammetaphani
Copy link

Same issue.

@seal62
Copy link
Author

seal62 commented Aug 26, 2016

this was answered here - #1340

@seal62 seal62 closed this as completed Aug 26, 2016
@shivang2902
Copy link

@seal62 Can you please look into my issue [Directly refer the last 2 comments]
#2262

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

4 participants