Extended BKSimpleScatterGraph to Rescale for Z-Axis Selections

BKit.jpg

Today a fellow developer came to me to ask how difficult it would be to make the scatter graph rescale the axes when the z-axis selection changed. This is the BKit graph that has the optional z-axis grouping selection list so that a third column can be used to group the data points defined by the x and y axes for easier viewing.

The problem is that VantagePoint (while a great package) is not universal in it's feature set. For example, the Bar and Combo charts allow for the ability to set the specific Observables - basically, the points in a data set (or Variable). If I could have applied this to the scatter graph, then I'd be set - simply make the Observable visible, or not, based on the state of the z-axis selections and the value corresponding to that data point. But the class hierarchy of the scatter graph did not include this functionality. I'm sure there's a reason, but I with they had included this in all graph types.

So I had to come up with another scheme. The problem is, the obvious one is to have a copy of all the data, and then when any of the selections change, we remove the old data and copy in just the data set necessary to plot the complete two-columns on the graph. The problem there is that's a lot of data moving of which a ton will be unnecessary. So I didn't want to do that unless I absolutely had to.

ScatterGraph Rescaled

What I decided to do was nearly as compute intensive, but it turned out to be reasonable in the context of the GUI event. That was to look at the data values of the 'visible' points and then set the limits on the data in the graph to these, and let the graph refresh accordingly. The upside of this is that there's no data moving. The downside is that we're getting limits over and over again when they aren't necessarily changing. There's also the possibility that we might mess up the nice axes selections that VantagePoint does automatically.

Luckly, that last part had already been solved in the base graph class, so when I tried this approach, I was very pleasantly surprised to see that everything worked as it should. Not half bad, in fact. Thankfully, this is only active when the user specifies a z-axis column for the graph, otherwise this would impact the performance of the applet at all times. Not really great. Good enough.