How to draw time based graphs using ios-charts

I am trying to draw a temperature graph using iso-diagrams where the x-axis data will be given from the server timestamp, but the labels will be readable.

For example, the x-axis label of the graph will start on Monday at 00:00 and end on Tuesday at 12 pm, but the LineChartDataSet will be a set of temperature (y axis) and timestamps for x

To display the timestamp, I have my own parameter valueFormatter, as shown below (which works fine) lineChartView.xAxis.valueFormatter = timestampXAxisFormatter () // converts the timestamp to a date string

My question: It seems that the LineChartDataSet index is indexed, which causes some problems: if I have 4 data points like (9am, 10), (9:15, 11), (12pm, 15), (1pm, 16) 4 points are set on the chart at regular intervals (I expected 2 points to be on the left side of the chart, and then the last 2 points on the right side). Is there a way to set a dataset that is based on x instead of index?

I saw that ChartData has an init, which takes an array of NSObjects, but then converts it to Strings ... Thanks in advance for any suggestions you might have.

+4
source share
1 answer

There is no good way to solve this problem, since you found out that the x axis is based on the index.

You have two options:

  • x x, 9:00 9:15, 9:01, 9:02,..., 9:14, , . ios-charts , . , . ~ 1000 , .

  • , y, x y, 0 . ios-chart. , PR.

+3

Source: https://habr.com/ru/post/1622458/


All Articles