Coreplot: Changing the zPosition of an individual element in a CPTBarPlot

35 Views Asked by At

I have graph with 2 CPTBarPlots, much like the Vertical BarChart example in Coreplot Plot Gallery project. I need to bring an element with a smaller base width to the front if its height is less than the associated one from the other CPTBarPlot. At the datasource function: func barFill(for barPlot: CPTBarPlot, record idx: UInt) -> CPTFill? one is able to increase the zPosition for the barPlot as a whole, yet I am unable to do this on an individual element basis. I observed that at the methods call time barPlot does not have any CALayer sublayers, where I kind of assumed the elements might be. Where might I possibly achieve access to an element's zPosition of a CPTBarPlot?

1

There are 1 best solutions below

1
Eric Skroch On

As noted, each plot is drawn in its own layer stacked back to front in the order the plots are added to the graph. You can achieve this effect by using three bar plots. Give the middle one its data as normal. For the other plots, decide whether to display the bar at each index in the front or back plot based on the data value relative to the other plot. Return nil from the datasource to hide the bar at that index for the other plot.