Charts data formate


#1

Hi,

  I am using highcharts in web and we are checking the feasibility of using shinobi charts in native app. our web service are common and the chart data received is in the format [[1354517595000,2.1500000953674],[1354530227000,1.8125],[1354542859000,2.2000000476837],[1354555490000,1.0500000715256],[1354568122000,0.57499998807907],[1354580754000,3.7000000476837],[1354593385000,0.63749998807907],[1354606017000,4.2000002861023],[1354618649000,5.5750002861023]] which is timestamp and value. Can i you pass this value directly to sinobi or needs to br processed as x in one array and y and in another array.

I am trying to impliment in iOS currently.

Thanks,

Senthil


#2

Hi senthil.at,

ShinobiCharts must have it’s data supplied to it by objects conforming to the SChartData protocol (it’s easiest to use the SChartDatapoint class we provide for you though) - it’s up to you to parse your data into this format.

Assuming you’ve got your date on the X axis and your value on the Y axis, you’d need to assign an NSDate to the datapoint’s xValue and an NSNumber to the datapoint’s yValue. It’s easy to convert the timestamps to NSDate objects. In the following example I’m assuming that your epoch is 1/1/1970 00:00:00 GMT:

// Create a datapoint object.
SChartDatapoint *datapoint = [SChartDatapoint new];

// Create an NSDate referring to 1/1/1970 00:00:00 GMT + 1354517595000 seconds.
datapoint.xValue = [NSDate dateWithTimeIntervalSince1970:1354517595000];

It’s also simple to create NSNumbers:

datapoint.yValue = @(2.1500000953674);

Thanks,

Jan


#3

Thanks Jan i am able to do it.