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 8117551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:12:39+00:00 2026-06-06T04:12:39+00:00

So my problem is simple. I am trying to switch my chart from a

  • 0

So my problem is simple. I am trying to switch my chart from a bar graph to a line graph but my line chart does not show/plot. I use similar code for my CPTBarPlot ‘Bar Chart’ and this plots/shows correctly.

My Bar Plot Code which plots correctly is:

CPTBarPlot *barPlot             = nil;    
barPlot                         = [CPTBarPlot tubularBarPlotWithColor:[CPTColor colorWithComponentRed:0.9294f green:0.3960f blue:0.5921f alpha:1.0f] horizontalBars:NO];
barPlot.fill                    = [CPTFill fillWithColor:[CPTColor colorWithComponentRed:0.9294f green:0.3960f blue:0.5921f alpha:1.0f]];
barPlot.opacity                 = 0.8f;
barPlot.dataSource              = self;
barPlot.delegate                = self;
barPlot.baseValue               = CPTDecimalFromString(@"0");
barPlot.barOffset               = CPTDecimalFromFloat(0.50f);

switch (graphType) {
    case kWeightThreeMonth:
    {
        barPlot.identifier  = [GraphsViewController threeMonthBarPlotIdentifier];
    }
        break;

    case kWeightSixMonth:
    {
        barPlot.identifier  = [GraphsViewController sixMonthBarPlotIdentifier];
    }
        break;

    case kWeightNineMonth:
    {
        barPlot.identifier  = [GraphsViewController nineMonthBarPlotIdentifier];
    }
        break;  
    default:
        break;
} 
barPlot.barCornerRadius         = 2.0f;
barPlot.lineStyle               = nil;
[lineGraph addPlot:barPlot toPlotSpace:plotSpace];

My Line Plot Code which does not show is:

// Create a blue plot area
CPTScatterPlot *boundLinePlot   = [[[CPTScatterPlot alloc] init] autorelease];
CPTMutableLineStyle *lineStyle  = [CPTMutableLineStyle lineStyle];
lineStyle.miterLimit            = 1.0f;
lineStyle.lineWidth             = 3.0f;
lineStyle.lineColor             = [CPTColor redColor];
boundLinePlot.dataLineStyle     = lineStyle;
switch (graphType) {
    case kWeightThreeMonth:
    {
        boundLinePlot.identifier  = [GraphsViewController threeMonthBarPlotIdentifier];
    }
        break;

    case kWeightSixMonth:
    {
        boundLinePlot.identifier  = [GraphsViewController sixMonthBarPlotIdentifier];
    }
        break;

    case kWeightNineMonth:
    {
        boundLinePlot.identifier  = [GraphsViewController nineMonthBarPlotIdentifier];
    }
        break;  
    default:
        break;
} 

boundLinePlot.dataSource    = self;
boundLinePlot.delegate      = self;
[lineGraph addPlot:boundLinePlot toPlotSpace:plotSpace];

// Do a blue gradient
CPTColor *areaColor1        = [CPTColor colorWithComponentRed:0.3 green:0.3 blue:1.0 alpha:0.8];
CPTGradient *areaGradient1  = [CPTGradient gradientWithBeginningColor:areaColor1 endingColor:[CPTColor clearColor]];
areaGradient1.angle         = -90.0f;
CPTFill *areaGradientFill   = [CPTFill fillWithGradient:areaGradient1];
boundLinePlot.areaFill      = areaGradientFill;
boundLinePlot.areaBaseValue = [[NSDecimalNumber zero] decimalValue];

// Add plot symbols
CPTMutableLineStyle *symbolLineStyle = [CPTMutableLineStyle lineStyle];
symbolLineStyle.lineColor   = [CPTColor blackColor];
CPTPlotSymbol *plotSymbol   = [CPTPlotSymbol ellipsePlotSymbol];
plotSymbol.fill             = [CPTFill fillWithColor:[CPTColor blueColor]];
plotSymbol.lineStyle        = symbolLineStyle;
plotSymbol.size             = CGSizeMake(10.0, 10.0);
boundLinePlot.plotSymbol    = plotSymbol;

Am I missing something here? I would of thought that the datasource etc would all work the same way considering the Bar Plot works correctly. I am simply just trying to switch from a bar chart, to a line chart.

Any help would be much appreciated.

Kind regards,
Dan

  • 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-06T04:12:40+00:00Added an answer on June 6, 2026 at 4:12 am

    This was actually my own fault.

    In the dataSource methods;

    -(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
    -(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
    

    I was doing an If statement of;

    if ( [plot isKindOfClass:[CPTBarPlot class]] ){
    

    Ofcourse I was using a CPTScatterPlot so my code was not being called. Doh.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to make simple minesweeper game in python, but have one problem. I have
I'm trying to switch back from my UIViewController to my UITableViewController but apperendly it's
I'm trying to make a simple css framework which allows me to switch from
I am trying to show a simple text RSS feed from a CodePlex project
This simple problem is kiling me. I posted something earlier about trying to clean
I have what is likely a simple problem, whereby I am trying to get
I am beginner trying to complete a simple JSON problem on SingPath which asks
I'm trying to find a simple solution to a specific problem, which is a
Problem Solved - See bottom for solution notes I'm trying to build a simple
Here's my problem: I'm trying to set up a simple mobile contact form with

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.