piaoyongren / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

Adding label on plot in core plot #170

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
I want to add label on plot in my bar graph .But unable to do .
Please help if any one knows it.
Please take a look on attached image ,these plot contain black rect.on top ,i 
want to replace these black rect. with label.I added these rect in order to 
clarify my problem to you guys.

Original issue reported on code.google.com by monikadh...@gmail.com on 8 Jul 2010 at 7:18

Attachments:

GoogleCodeExporter commented 8 years ago
Please see this recent question on the discussion board: 
http://groups.google.com/group/coreplot-discuss/browse_thread/thread/691f8091ecf
58ed1#

Original comment by eskr...@mac.com on 9 Jul 2010 at 2:17

GoogleCodeExporter commented 8 years ago
Hi,
will you plz send me an example ,because i already set the barLabelTextStyle 
but its not giving any bar.
My code is:
CPBarPlot *barPlot1 = [CPBarPlot tubularBarPlotWithColor:[CPColor redColor]  
horizontalBars:NO ];
    barPlot1.baseValue = CPDecimalFromString(@"0");
    barPlot1.barWidth=11;
    barPlot1.dataSource = self; 
    barPlot1.barLabelTextStyle=whiteText;
    barPlot1.barLabelOffset=2.0;
    barPlot1.barOffset = 2.0; 
    barPlot1.borderWidth=0.0;
    barPlot1.masksToBorder=NO;
    //barPlot1.borderColor=[UIColor whiteColor];
    barPlot1.identifier = SERIES1;
    [self.graph addPlot:barPlot1 toPlotSpace:plotSpace];

How we write method for bar label,plz tell that thing also.I urgently need this.

Thanks,
Monika

Original comment by monikadh...@gmail.com on 9 Jul 2010 at 5:19

GoogleCodeExporter commented 8 years ago
Hi Thanks its done .But i also want too add label on my pie chart.is there is 
any method for pie chart also.

Original comment by monikadh...@gmail.com on 9 Jul 2010 at 6:01

GoogleCodeExporter commented 8 years ago
Unfortunately pie charts can not yet have labels. It is on our TODO list. For 
now, you would have to add labels yourself. Sorry.

Original comment by drewmcco...@mac.com on 9 Jul 2010 at 7:27

GoogleCodeExporter commented 8 years ago
if there is any way by which i am able to findout the area or  start position 
and end position of a slice or angel of a slice in pie.and how we add 
animations in our core plot bar or pie chart.we also able to add labels on line 
chart using same bar chart method.

Original comment by monikadh...@gmail.com on 9 Jul 2010 at 7:42

GoogleCodeExporter commented 8 years ago
I think your best bet at this point is just to look in the source code at 
CPPiePlot.

Original comment by drewmcco...@mac.com on 10 Jul 2010 at 9:06

GoogleCodeExporter commented 8 years ago
Hi ,
I added the label in pie chart,with the help of cptextlayer.but what i want to 
do is i  have an array of data labela i want to show these in place of 
labels.But when i am adding logic and calling cptextlayer again and again its 
not working.
Please see my code below:
int k=-135;
    int j=50;

    for (int i=0; i<[final_resultant_data count];i++) 
    {
        k=i+50;
        k=j+50;
        CPTextLayer *layerdarkgrayotfinalfi=nil;
        if (!layerdarkgrayotfinalfi) 
        {
            NSString *test=[NSString stringWithFormat:@"%@",[final_resultant_data objectAtIndex:i]];
            layerdarkgrayotfinalfi= [[[CPTextLayer alloc] initWithText:test]autorelease];
            layerdarkgrayotfinalfi.bounds = CGRectMake(k,j, 20,layerred.preferredFrameSize.height);
            layerdarkgrayotfinalfi.position = CGPointMake(0, 0);

            layerdarkgrayotfinalfi.textStyle=whiteText1;
            [hostingView.hostedLayer addSublayer:layerdarkgrayotfinalfi];

        }

    }
This is my code i am calling CPTEXTLAYER again and again for different points 
but its not working.Please help me.

Original comment by monikadh...@gmail.com on 12 Jul 2010 at 9:28

GoogleCodeExporter commented 8 years ago
I think you should be changing the position for each label, rather than the 
bounds. Set the bounds to be at 0,0, and then change the position to be k,j

            layerdarkgrayotfinalfi.bounds = CGRectMake(0,0, 20,layerred.preferredFrameSize.height);
            layerdarkgrayotfinalfi.position = CGPointMake(k,j);

Original comment by drewmcco...@mac.com on 12 Jul 2010 at 11:30

GoogleCodeExporter commented 8 years ago
I am getting value but all values are om a single (0,0) position.
Plz check attachment and below is my code also.

int k=-135;
    int j=50;

    for (int i=0; i<[final_resultant_data count];i++) 
    {
        k=k+50;
        k=j+50;
        CPTextLayer *layerdarkgrayotfinalfi=nil;
        if (!layerdarkgrayotfinalfi) 
        {
            NSString *test=[NSString stringWithFormat:@"%@",[final_resultant_data objectAtIndex:i]];
            layerdarkgrayotfinalfi= [[[CPTextLayer alloc] initWithText:test]autorelease];
            layerdarkgrayotfinalfi.bounds = CGRectMake(0,0, 20,10);
            layerdarkgrayotfinalfi.position = CGPointMake(k, j);

            layerdarkgrayotfinalfi.textStyle=whiteText1;
            [hostingView.hostedLayer addSublayer:layerdarkgrayotfinalfi];

        }

    }

Original comment by monikadh...@gmail.com on 12 Jul 2010 at 12:23

Attachments:

GoogleCodeExporter commented 8 years ago
Hi i done with that its ok now not required thanks.k,j will remain in .bounds 
and position remain 0,0 .
i need one more help i want to move my whole pie little bit upwards but when i 
am setting coordinates its not working will u please tell me where i will set 
cordinate in order to move pie upwards.

Original comment by monikadh...@gmail.com on 12 Jul 2010 at 12:29

GoogleCodeExporter commented 8 years ago
I just added a property called centerAnchor to the pie chart. You can use that 
to move the center point anywhere within the plot area.

Original comment by eskr...@mac.com on 13 Jul 2010 at 2:27

GoogleCodeExporter commented 8 years ago
pieChart = [[CPPieChart alloc] init];
        pieChart.dataSource = self;
        pieChart.pieRadius = 100;
        pieChart.identifier = @ ""PieChart1"";;
        pieChart.startAngle =0;
        pieChart.sliceDirection = CPPieDirectionCounterClockwise;
        pieChart.anchorPoint=CGPointMake(10,10);
        //pieChart.sliceLabelOffset=150.0;
        NSLog(@"Graphtitle=%@",GraphTitle );
        self.pieData=final_resultant_data;  

        [graph addPlot:pieChart];

This is what i done but its not working and there is no property "CenterAnchor" 
in pie.

Original comment by monikadh...@gmail.com on 13 Jul 2010 at 5:10

GoogleCodeExporter commented 8 years ago
How we set the color of different pie slice .

Original comment by monikadh...@gmail.com on 13 Jul 2010 at 11:00

GoogleCodeExporter commented 8 years ago
Did you get the latest source?

BTW, this is the issue tracker. You should move this Q&A over to the discussion 
board. See the link in my first comment above.

Original comment by eskr...@mac.com on 13 Jul 2010 at 11:40

GoogleCodeExporter commented 8 years ago
ooo ok got it.I need one more help i am trying to add image with the help of 
cpimage but unable to do that plz help.

Original comment by monikadh...@gmail.com on 13 Jul 2010 at 1:27

GoogleCodeExporter commented 8 years ago
hi still not able to add image in my app with the help of cpimage.

Original comment by monikadh...@gmail.com on 14 Jul 2010 at 5:34

GoogleCodeExporter commented 8 years ago
@monikadhingra

Hi I am also trying to add labels to pie chart. I saw your image. Can you tell 
me how do you set the values to appear at the center of every slice of the 
pie-chart?? 

I see that the code you have written is for the labels at the bottom right? I 
want to know about the values at each slice. Can you please help. Right now I 
am doing something like this. (See image below)

Original comment by sidchau...@gmail.com on 18 Jul 2010 at 3:10

Attachments:

GoogleCodeExporter commented 8 years ago
i done this thing mathematically .Is there is any way to move circle upwards i 
used centerAnchor property but its not supporting.

Original comment by monikadh...@gmail.com on 19 Jul 2010 at 1:03

GoogleCodeExporter commented 8 years ago
This issue is closed. Please take this thread over to the discussion board.

http://groups.google.com/group/coreplot-discuss

Original comment by eskr...@mac.com on 19 Jul 2010 at 3:46