[iOS] axis range not getting set properly


#1

Hello,

I am new to using the ShinobiCharts framework. I am trying to set a custom range for the x-axis, which is of type “SChartAxisTypeDateTime”.

I tried setting the default range, but that did not work. So then (upon advice on a previous forum), I created an axis with the desired range when I created the graph with this code:        

SChartDateRange *XRange = [[SChartDateRangealloc] initWithDateMinimum:_theModel.myProcedure.procedureStartTimeandDateMaximum:[NSDatedate]];

        SChartDateTimeAxis *xAxisSponge = [[SChartDateTimeAxisalloc] initWithRange:XRange];

        spongeChart.xAxis = xAxisSponge;

However, that still does not work. Instead of giving the desired range (which should be several hours) I get an axis with a range of about a minute.

Has anyone else run into this problem?

Thanks!


#2

Hi,

I just wanted to add the image of the graph to give a little more context

  image of graph with axes


#3

After downloading some ShinobiControls projects on GitHub, I found that setting “defaultRange” was the best solution, but I had to convert  the dates into NSTimeIntervals, and then create NSNumber’s with the time intervals like this:

NSTimeInterval startRangeXAxis, endRangeXAxis;       

startRangeXAxis = [_theModel.myProcedure.procedureStartTimetimeIntervalSince1970];

endRangeXAxis = [[NSDate date] timeIntervalSince1970];

    SChartRange *XRange = [[SChartRangealloc] initWithMinimum:@(startRangeXAxis)andMaximum:@(endRangeXAxis)];

    [spongeChart.xAxissetDefaultRange:XRange];


#4

Hi - the workaround with the defaultRange is the current way to do this, as it’s a known issue with charts that’s fixed in our upcoming release, provisionally scheduled for later this month / September. We’ll let you know when it’s out!