Tuesday, March 20, 2018

#TweakThursday 39: On Viz Design with Bézier Curve

The other day, Rajeev Pandey asked me a question regarding the calculation in his dashboard privately. I didn't have time to look into it. Fortunately the gracious Simon Runc found that the issue was in data densification.

Rajeev is trying to replicate a viz by Zen Master Rody Zachovich, which seems to be inspired by a viz of Cody Crouch.

I spent some time looking into both the vizzies. I found a few computational solutions which may be interesting to share.

1.Data set reduced to 2 rows
Only two initial rows per curve are needed in Bézier curve calculation, even when the curve is a concatenation of multiple piece-wise Bézier curves.

In Rody Zachovick's NFL viz, we found that only Path={0,2} are necessary per curve instead of 4 rows. Rody used two pieces of Bézier curve and hid part of it.
In Cody Crouch's Golf viz, we found that only Path={0,3} are necessary per curve instead of 4 rows. It consists of 3 pieces of Bézier curve, although the last piece is actually a straight line.
All the rest of data marks can be generated by data densification from the two rows.

2.One Bézier curve instead of two
Rody made use of two pieces of Bézier curve in his viz. I found that, given it's a single concave curve, we need only one Bézier curve to approximate it. So, I made changes to the formula and the resulting viz looks like the same. The total number of data marks is cut by half. The curve still looks very smooth. The formula is a bit simpler too.

By the same token, Cody's viz can be designed with one Bézier curve plus a straight line. I will leave it to whoever wants to give it a try.

3.Simplify calculation
Bézier gave his famous quadratic equations as follows:
This is the general form. In special cases, these function can be simplified.

For example, when Y0=Y2=0, we have Y's calculation simplified as follows:
Then we replaced part of the calculation in X by Y. Note that 0.6 is a control coefficient on the horizontal position of the highest point.
That's the tweak of the day. The purpose here is to simplify the application of Bézier curve.

Have fun with Tableau! Feel free to view and download the modified viz.

No comments:

Post a Comment