This 3 part series demonstrates how to add a custom D2 widget that displays pie charts, bar charts, and column charts:
Part 1: Starting with Google charts
Part 2: Clicking part of the chart calls a query form that tells D2 to list the documents
Part 3: Code on GitHub