X-axis going beyond the app screen


#1

Graph_Weekly

Please find link to the attached image in case you arent able to view it - https://www.dropbox.com/s/4d2f5o1m48al2k4/weekly_graph_issue.png?dl=0

As shown in the pic, the requirement from this Shinobi graph is to plot 7 days of the week on the x-axis and corresponding y values based on when the data was populated . The 7 days of the week is calculated as 7 days behind starting from today . 

In the attached graph , the week is taken from Jan 22 - Jan 28. 

My application had Y axis data available for Jan 26th and Jan 28th.The datapoints for Jan 26th are plotted correctly however the datapoint for Jan 28th has gone out of the app screen (The x-axis seems to be beyond the app screen)

The corresponding code used :

//Properties of the Y-axis

SChartNumberRange *rangeY=[[SChartNumberRangealloc]initWithMinimum:minY.intValue<=19 ? @(0) : [NSNumbernumberWithInt:minY.intValue-20] andMaximum:[NSNumbernumberWithInt:maxY.intValue+20]];

    SChartNumberAxis *YAxis = [[SChartNumberAxisalloc] initWithRange:rangeY];

    YAxis.rangePaddingLow = @(0.1);

    YAxis.rangePaddingHigh = @(0.1);

    YAxis.style.majorGridLineStyle.showMajorGridLines = NO; //Sim added for Cesar

    YAxis.style.gridStripeStyle.showGridStripes = NO;

    _shinobiChart.yAxis = YAxis;

    _shinobiChart.yAxis.style.majorTickStyle.showTicks=YES;

  

//Properties of the X-axis (This should have days of the week)    

 SChartDateRange *range = [[SChartDateRangealloc] initWithDateMinimum:week.weekStartDateandDateMaximum:week.weekEndDate];

     SChartDateTimeAxis *xAxis = [[SChartDateTimeAxisalloc] initWithRange:range];

    NSDateFormatter *dayFormatter = [[NSDateFormatteralloc] init];

    [dayFormatter setDateFormat:@“E”];

    SChartTickLabelFormatter *formatter = [SChartTickLabelFormatterdateFormatter];

    [formatter setFormatter:dayFormatter];

    xAxis.labelFormatter = formatter;

    xAxis.rangePaddingLow = [SChartDateFrequencydateFrequencyWithDay:1];

    xAxis.rangePaddingHigh = [SChartDateFrequencydateFrequencyWithDay:1];

   xAxis.style.majorGridLineStyle.showMajorGridLines = NO;

    xAxis.style.gridStripeStyle.showGridStripes = NO;

    xAxis.style.titleStyle.position = SChartTitlePositionTopOrRight;

    xAxis.minorTickFrequency = [SChartDateFrequencydateFrequencyWithDay:1];

    xAxis.majorTickFrequency = [SChartDateFrequencydateFrequencyWithDay:1];

    xAxis.style.majorTickStyle.showTicks=YES;

    _shinobiChart.xAxis = xAxis;


#2

Hi sim777,

It’s difficult to know exactly what’s going wrong here as I can’t tell what the minimum and maximum values are of the x-axis range. However, your image does not appear to have enough space for 7 days and is only showing 6. I am guessing that something is going wrong with the maximum range value that is being set. Would it be possible to debug your code and let us know exactly what values are used for minimum and maximum on the x-axis - this will hopefully give us a better idea of what’s going wrong.

Thanks! :-) 


#3

Thank you for your response.I debugged this further and based on your response adjusted the width of the scrollView. This resolved the issue of the point going beyond the screen .

However the issue at hand now is that the first point of the X-axis is plotted on the Y-Axis(Basically the paddijng does not work ). Can you tell me how to set the PaddingLow and PaddingHight for the SChartDateTimeAxis


#4

Regarding your padding issue please see my response here. I think that should solve your issue

Sam