-
Notifications
You must be signed in to change notification settings - Fork 603
Description
I'm interested in being able to color line segments based on the values within a third array. That is to say, if X and Y are the graph positions that represent a line, then the color of the line along the path is represented by some array Z along that path.
In its simplest form, I want to achieve what's in the screenshot below. The X/Y values are components of a wind speed vector (X being the U or zonal component, and Y being the V or meridional component) and the lines are colored based on the altitude of those wind measurements. Wind speeds below 3 km altitude are colored red, 3-6km colored green, 6-9km colored cyan, and so on. However - I also envision the ability to color each segment of an array (rather than all just one color) based on the Z array. This would be analogous to the gradient or fill options, but not being dependent on the XY representation of a gradient.
Right now, the only way I can to do this in CorePlot is to have individual arrays for 0-3km, 3-6km, 6-9km, etc and creating new instances of CPTScatterPlot for each line segment, and then changing the line style for each instance of ScatterPlot. I'm worried about this approach's possible performance hit by having to create multiple CPTScatterPlots to achieve this functionality, especially as more segments require more instances of the object. I think it would be ideal to be able to style a path without having to create new CPTScatterPlot instances.
I see that the line positions appear to be handled by CPTScatterPlot::newDataLinePathForViewPoints, and that line color is set by CPTLineStyle::setLineStyleInContext. From doing some research into drawing with CoreGraphics, it looks like the stroke would have to be updated along each segment of the line as it is being added. Creating an array that holds the colors of each line segment would be trivial, the question becomes how does one integrate this into the current drawing system well? If you have any pointers for how integrating this functionality might be possible, I would be happy to work on it myself.
