Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:07:43+00:00 2026-06-07T15:07:43+00:00

Hi All Can someone help me with this problem I have encountered Can I

  • 0

Hi All
Can someone help me with this problem I have encountered

Can I plot a bargraph in coreplote with unequal bar width meaning Say my X-axis interval is 1 unit and I have set the bar graph width as same 1 unit. But there are certain points where x-axis value changes at 0.5units and i want the bar width to be equal to the width where change has occurred. And the data is dynamically changing. Is there any other solution that I can use and still looks like a bar graph. The only reason for using bar is I need to fill the plot space.

CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)barChart.defaultPlotSpace;
        plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromInt(0) 
                                                       length:CPDecimalFromInt(rangeY)];
        plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-0.5f) 
                                                       length:CPDecimalFromFloat(rangeX)];

        CPXYAxisSet *axisSet = (CPXYAxisSet *)barChart.axisSet;
        CPXYAxis *x = axisSet.xAxis;
        x.axisLineStyle = nil;
        x.majorTickLineStyle = nil;
        x.minorTickLineStyle = nil;
        x.majorIntervalLength = CPDecimalFromString(@"1");
        x.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");

        x.title = [[[tempCol colName] componentsSeparatedByString:@"*@"] objectAtIndex:0];
        x.titleLocation = CPDecimalFromFloat((rangeX-1)/2);
        x.titleOffset = 25.0f;

        // Define some custom labels for the data elements
        x.labelRotation = 0;
        x.labelingPolicy = CPAxisLabelingPolicyNone;
        NSMutableArray *customTickLocations = [[NSMutableArray alloc] init];
        NSMutableArray *xAxisLabels = [[NSMutableArray alloc] init];
        for (int i = 0; i < [tempGraph.d2pArray count]; i++) {
            tempD2P = [tempGraph.d2pArray objectAtIndex:i];
            [customTickLocations addObject:[NSNumber numberWithInt:i]];
            [xAxisLabels addObject:[tempD2P d2pName]];
        }
        NSUInteger labelLocation = 0;
        NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]];
        for (NSNumber *tickLocation in customTickLocations) {
            CPAxisLabel *newLabel = [[CPAxisLabel alloc] 
                                     initWithText:[xAxisLabels objectAtIndex:labelLocation++] 
                                     textStyle:x.labelTextStyle];
            newLabel.tickLocation = [tickLocation decimalValue];
            newLabel.offset = 0;
            newLabel.rotation = 0;
            newLabel.alignment = CPAlignmentCenter;     
            [customLabels addObject:newLabel];
            [newLabel release];
            newLabel = nil;
        }
        [xAxisLabels release];
        xAxisLabels = nil;
        [customTickLocations release];
        customTickLocations = nil;
        x.axisLabels =  [NSSet setWithArray:customLabels];

        CPXYAxis *y = axisSet.yAxis;
        CPLineStyle *majorGridLineStyle = [CPLineStyle lineStyle];
        majorGridLineStyle.lineWidth = 0.75;
        majorGridLineStyle.lineColor = [CPColor colorWithCGColor:[[UIColor grayColor] CGColor]];
        y.axisLineStyle = nil;
        y.majorTickLineStyle = nil;
        y.majorGridLineStyle = majorGridLineStyle;
        y.minorTickLineStyle = nil;
        y.majorIntervalLength = CPDecimalFromInt(rangeY/8);
        y.orthogonalCoordinateDecimal = CPDecimalFromString(@"-0.5");
        y.title = [[[tempCol colName] componentsSeparatedByString:@"*@"] objectAtIndex:1];
        y.titleOffset = 30 + 5*log10(mult);
        y.titleLocation = CPDecimalFromInt(rangeY/2);
        NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
        [formatter setMaximumFractionDigits:0];
        y.labelFormatter = formatter;
        [formatter release];
        formatter = nil;
        char firstChar = 'F';
        CPBarPlot *barPlot;
        // First bar plot
        for (int i = 0; i < noOfBarCharts; i++) {
            static CPTextStyle *whiteText = nil;
            if ( !whiteText ) {
                whiteText = [[CPTextStyle alloc] init];
                whiteText.color = [CPColor whiteColor];
                whiteText.fontSize = 14;
            }
            barPlot = [CPBarPlot tubularBarPlotWithColor:[CPColor colorWithComponentRed:[[[rgbArray objectAtIndex:0] objectAtIndex:i] floatValue]/255.0 
                                                                                  green:[[[rgbArray objectAtIndex:1] objectAtIndex:i] floatValue]/255.0 
                                                                                   blue:[[[rgbArray objectAtIndex:2] objectAtIndex:i] floatValue]/255.0 
                                                                                  alpha:1.0] 
                                          horizontalBars:NO];
            barPlot.baseValue = CPDecimalFromString(@"0");
            barPlot.dataSource = self;
            barPlot.barOffset = ([tempGraph.graType rangeOfString:@"GROUPED"].location != NSNotFound)?(i+0.5)-(noOfBarCharts/2):0;
            barPlot.labelOffset = 0;
            barPlot.barWidth = 20;
            barPlot.identifier = [NSString stringWithFormat:@"%d%c", [tempGraph.graID intValue], (firstChar - noOfBarCharts +1 + i)];
            barPlot.delegate = self;




            [barChart addPlot:barPlot 
                  toPlotSpace:plotSpace];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:07:45+00:00Added an answer on June 7, 2026 at 3:07 pm

    I figured it out myself instead of using a bar chart i used a scatter plot with step graph That did the trick :

    Plot.interpolation = CPTScatterPlotInterpolationStepped;
    

    and filled the plot with:

    Plot.areaFill = [CPTFill fillWithColor:[CPTColor blueColor]];
    Plot.areaBaseValue = CPTDecimalFromInteger(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hopefully someone can help me with this odd problem. I have a database which
Can someone help me with this: This is a program to find all the
Hopefully someone can help me debug this problem as EXC_BAD_ACCESS is the only error
I'm hoping someone can help me out. I've been researching this problem for hours
Can someone help me get started with a button timeout feature. All I want
Can someone tell me why this processes all the files and then does it
I have encountered this problem: Depending on numbers from I want to create a
Can someone help out with an animation issue I can't figure out. I have
I know that there is a lot of posts about this problem.But can someone
I have this weird problem.. I'm building an in-house app that should register all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.