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

is there a way to create a date scale for the x axis? #736

Closed
shawn-kb opened this issue Feb 3, 2016 · 5 comments
Closed

is there a way to create a date scale for the x axis? #736

shawn-kb opened this issue Feb 3, 2016 · 5 comments

Comments

@shawn-kb
Copy link

shawn-kb commented Feb 3, 2016

i am trying to chart the pressure of a transducer over the last week. However the transducer does not report at regular time intervales and I need to chart to reflect that. is there a way to make a date scale on the XAxis that will show these points this way? I have included a version of the chart we use on our web page.
draw_quick_chart

@liuxuan30
Copy link
Member

Simple answer: you should generate full date values for xVals, and not insert data entry for those dates that don't have data.
Complicated answer: this has been asked and not having a good solution yet. #194
and you will ask for breaking lines feature, which I already did: #280. #533 is the discussion with a few workarounds.

@shawn-kb
Copy link
Author

shawn-kb commented Feb 4, 2016

ok, thanks very much

@romanbaitaliuk
Copy link

romanbaitaliuk commented Aug 8, 2017

@skrite @liuxuan30 Hi, do I need to create multiple datasets to implement this feature? (1 for the chart, 2 for the fake xAxis labels) I tried to create 2 data sets and merge them. This is my code:

//primary data set array will include both sets
var primaryDataSet: [LineChartDataSet] = []

//1 data set:
var set1DataEntry: [ChartDataEntry] = [.......]
...
let set1 = LineChartDataSet(values: set1DataEntry, label: nil)

//2 data set
var set2DataEntry: [ChartDataEntry] = [empty]
let set2 = LineChartDataSet(values: set2DataEntry, label: nil)

//merge sets
primaryDataSet.append(set1)
primaryDataSet.append(set2)

//populate chart with data
let lineChartData = LineChartData(dataSets: primaryDataSet)
lineChartView.data = lineChartData

//format labels
lineChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: [labels for set1 + fake labels])

As a result this code doesn't show fake set2, only set1. Could you please help me with that, what am I doing wrong? I also tried just create 1 set and add more xAxis labels in array, but it didn't solve the problem.

@romanbaitaliuk
Copy link

Simple answer: you should generate full date values for xVals, and not insert data entry for those dates that don't have data.

Do I need to append my dataEntries with (0,0) values for those dates that don't have data?

@romanbaitaliuk
Copy link

romanbaitaliuk commented Aug 9, 2017

I solved the issue, just created two data sets, and fill second data sets with entries started x value from the last index of 1set.

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

No branches or pull requests

3 participants