Search code examples
iosobjective-cgraphios-charts

iOS-charts with exponential x-axis


I have the requirement to plot a graph with y-axis range (-15 db to 15 db).

plot values are got from a float array -e.g

float plotVal[] = {
        0.707087f,
        0.715769f,
        0.724338f,......};(contains 560 points)

My x-axis value should range from 20 HZ to 20,000HZ but in logarithmic scale like shown in the imageenter image description here

I am using iOS-Charts and populating the values as

NSMutableArray *xVals = [[NSMutableArray alloc] init];
    int xCount = 560;

    for (int i = 0; i < xCount; i++)
    {
        [xVals addObject:[@(i) stringValue]];

    }

    NSMutableArray *yVals = [[NSMutableArray alloc] init];

    int yCount = 560;

    for (int i = 0; i < yCount; i++)
    {
      [yVals addObject:[[ChartDataEntry alloc] initWithValue:plotVal[i] xIndex:i]];

    }

How could I change my scale values as shown in the image,please help.


Solution

  • Atlast I used core plot, by playing with some Math functions could do a graph as in screenshot. So its possible using core plot.Thanks.Grt core plot.