topmobile1201 / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add a CPPlotSymbol class #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
A CPPlotSymbol class should be created that knows how to draw symbols (crosses, 
squares, 
circles etc) on a scatter plot. Symbols can be string based, vector based 
drawings, or even an 
image (CGImageRef).

CPPlotSymbol probably should be an abstract class, with subclasses for each 
mode of symbol (eg 
text, image, etc).

One question is whether it would be worth making each symbol a separate layer. 
This could be 
used to create some cool animation effects, but for large datasets, may be a 
performance 
problem. One option would be to have two different modes, and only use separate 
layers for 
each symbol if requested by the user. Perhaps the first pass should just use a 
layer per symbol. 
(We don't want to preoptimize).

Plot symbol classes should have class methods to easily create standard 
symbols, but offer 
constructors to generate custom symbols. Eg.

+(id)crossPlotSymbol;
+(id)circlePlotSymbol;

Symbols would also have a size property (CGSize), and comply with NSCopying. 
The reason for 
the latter is that the user will probably create a symbol object, and pass this 
as a prototype to 
the plot. The plot will copy the symbol, like an NSCell, to create the various 
points on the plot.

Original issue reported on code.google.com by drewmcco...@mac.com on 11 Feb 2009 at 2:15

GoogleCodeExporter commented 8 years ago
Doesn't having a separate layer per symbol incur a huge memory cost for large 
data sets?

Original comment by barryw...@gmail.com on 11 Feb 2009 at 7:12

GoogleCodeExporter commented 8 years ago
From my experience you will face huge costs for large datasets +/- regardless 
of the used drawing method (I 
have sound files to draw, hi samplerate resulting in 2.000.000+ dots or lines). 

In my app - still using Quartz2D paths - I tuned performance by only drawing 
necessary parts, that means 
visible not only by the defined rect, but also atop of all other elements on 
the +/- same coordinate. I am not 
sure how to do this in a useful manner with Layers, since then adding/removing 
of layers would be necessary.

To add something more constructive: It might be worth to have a option to 
create all symbols of the same 
kind (squares, circles, ...) in one layer, then the user can quickly fade 
in/out partial datasets.

Original comment by volker.r...@gmail.com on 15 Feb 2009 at 8:14

GoogleCodeExporter commented 8 years ago
Instead having separate classes of symbol, what about combining these functions 
into one.  That way you could 
have your standard vector symbols filled with a color, gradient, or image.  
Strings could be rendered on top of 
the filled shape.  Backgrounds would be clipped to whatever shape was selected.

If you want just the image, specify nil for the line style and text.  If you 
want an open shape, specify nil for the 
fill.  If you just want the text, specify nil for the line style and fill.  Etc.

Original comment by eskr...@mac.com on 9 Apr 2009 at 2:20

GoogleCodeExporter commented 8 years ago
Yes, a single class would also be fine. I also think now that having a separate 
layer for each symbol is a no go 
performance wise. In fact, this is probably a case where the 'flyweight' 
pattern would work best. The symbol 
class probably would be used in much the same way as an NSCell: it would have a 
size, but no position; a CPPlot 
object would simply use the symbol object like a stamp, moving it to the 
desired location, setting its properties, 
and drawing it, then moving to a new location, etc. 

Drew

Original comment by drewmcco...@mac.com on 9 Apr 2009 at 7:38

GoogleCodeExporter commented 8 years ago
I'll tackle this one.

Original comment by eskr...@mac.com on 9 Apr 2009 at 11:27

GoogleCodeExporter commented 8 years ago

Original comment by drewmcco...@mac.com on 12 May 2009 at 7:07

GoogleCodeExporter commented 8 years ago
Even though this issue was closed I added a few methods in order to create 
custom plot symbols from a 
provided GGPathRef. Hope that was ok!

/ Leo

Original comment by leo.berg...@gmail.com on 25 May 2009 at 7:29

GoogleCodeExporter commented 8 years ago
I like it!

Original comment by eskr...@mac.com on 26 May 2009 at 2:48