gujjula / core-plot

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

CPTLegend can't display at the right place #310

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.create a graph
2.call my service, then create scatter plots.
3.create CPTLegend and set the display place

What is the expected output? What do you see instead?
Expected output:
show it at the place I set.
instead:
some times, show the legend at the right place, some times, at the wrong place 
or not show it.

What version of the product are you using? On what operating system?
Version: 0.4
MAC: 10.6.6
XCODE: 4.0
SDK: 4.3

Please provide any additional information below.
1. I create the CPTXYGraph at the ViewDidLoad method.
2. I add the plots when my web service is done.
3. I create the legend after  the plots added.
4. After this steps, I use the reloadData method.

Original issue reported on code.google.com by fuyuanxu...@yahoo.cn on 27 Jul 2011 at 1:37

GoogleCodeExporter commented 9 years ago
How are you adding the legend to the graph? Using the CPTGraph legend 
properties or some other way? The examples in the Plot Gallery app show a 
couple of different ways to do it.

Original comment by eskr...@mac.com on 27 Jul 2011 at 2:14

GoogleCodeExporter commented 9 years ago
I using the CPTGraph legend properties.Under is my code create legend:

    CPTLegend *theLegend = [CPTLegend legendWithGraph: _graph];
    theLegend.fill = [CPTFill fillWithColor:[CPTColor colorWithComponentRed:0.0 green:0.0 blue:0.0 alpha: 0.5]];
    theLegend.numberOfColumns = 4;
    theLegend.swatchSize = CGSizeMake(24.0, 8.0);
    theLegend.cornerRadius = 5.0;
    theLegend.textStyle = legendTextStyle;
    [theLegend setLayoutChanged];

    if (_graph.legend != nil) {
        _graph.legend = nil;
    }
    _graph.legend = theLegend;
    _graph.legendAnchor = CPTRectAnchorTop;
    _graph.legendDisplacement = CGPointMake(0.0, -22.0);

Then I use [_graph reloadData] to load it.
Can you tell me what's wrong?

Original comment by fuyuanxu...@yahoo.cn on 27 Jul 2011 at 8:05

GoogleCodeExporter commented 9 years ago
For more Information:
sometimes, show the warning below:

2011-07-27 19:01:14.049 assiapoc[6999:207] -[<<<CPTLegend: 0x836dc90> bounds: 
{{0, 0}, {2.81831e+20, 31}}> for plots (
    "<<CPTScatterPlot: 0x836d160> bounds: {{0, 0}, {280, 267}}>",
    "<<CPTScatterPlot: 0x836d3c0> bounds: {{0, 0}, {280, 267}}>",
    "<<CPTScatterPlot: 0x836d4d0> bounds: {{0, 0}, {280, 267}}>",
    "<<CPTScatterPlot: 0x836d700> bounds: {{0, 0}, {280, 267}}>",
    "<<CPTScatterPlot: 0x836d8a0> bounds: {{0, 0}, {280, 267}}>",
    "<<CPTScatterPlot: 0x836dae0> bounds: {{0, 0}, {280, 267}}>"
)> display]: Ignoring bogus layer size (281830849042148491264.000000, 31.000000)

Original comment by fuyuanxu...@yahoo.cn on 27 Jul 2011 at 11:01

GoogleCodeExporter commented 9 years ago
The warning shown in comment #3 should be fixed in the latest code (after 0.4 
was released). Use Mercurial to pull the update.

The call to -setLayoutChanged is unnecessary. Core Plot will call it 
automatically as needed. You also don't need to set the legend to nil right 
before you set the new legend.

I'm not seeing a positioning problem, but I did notice problems with the legend 
layout and drawing caused by having a swatch size that's shorter than the title 
text. I'll work on fixing that.

Original comment by eskr...@mac.com on 29 Jul 2011 at 2:23

GoogleCodeExporter commented 9 years ago
That's Good!
 The attachment is my problem that I'm facing.
I just add the plots when my service done,
and then create the legend, set it to the graph legend property,
at last, I use the method [graph reloadData] to update graph.

Then I see the legend position problem.

PS: the attachment is the problem shortcut.

Original comment by fuyuanxu...@yahoo.cn on 29 Jul 2011 at 7:02

Attachments:

GoogleCodeExporter commented 9 years ago
That I have another hope is that,
 CPTLegend can give the columnWidth property let us 
set the CPTLegend width easily.
The columnWidths  is hard to use.

Original comment by fuyuanxu...@yahoo.cn on 29 Jul 2011 at 7:11

GoogleCodeExporter commented 9 years ago
Sorry, I have not really understand the API.

I find i can't set the CPTLegend width,
because my title width is one dynamic string,
it will not  fit the frame that i have set, 
sometimes,the CPTLegend width is big than the frame i have set.

Original comment by fuyuanxu...@yahoo.cn on 29 Jul 2011 at 9:11

GoogleCodeExporter commented 9 years ago
You should leave the rowHeights and columnWidths arrays nil unless you really 
need fine control over the sizes. The legend will auto size around the titles 
and swatches.

Original comment by eskr...@mac.com on 30 Jul 2011 at 9:09

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 5d143c3b6e94.

Original comment by eskr...@mac.com on 30 Jul 2011 at 9:09