Closed GoogleCodeExporter closed 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
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
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
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
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:
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
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
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
This issue was closed by revision 5d143c3b6e94.
Original comment by eskr...@mac.com
on 30 Jul 2011 at 9:09
Original issue reported on code.google.com by
fuyuanxu...@yahoo.cn
on 27 Jul 2011 at 1:37