When the chart you need does not exist
How I built custom Data Studio visualisations to finally get the dashboard of my dreams.
· shipped
- data-viz
- looker-studio
- javascript

Data Studio, which Google has since renamed Looker Studio, is the reporting tool that comes free with the Google stack. That is how most companies end up in it. It connects to BigQuery in two clicks, anyone can edit a report, and you can set up your dashboards in less than a day.
Then you try to make a better report. Put the growth percentage next to the revenue it belongs to instead of at the far end of the table. Colour this cell based on a metric the viewer is not supposed to see. Show last week's sales with the five weeks before it as a trend behind the number. Every one of those is a reasonable thing to ask for, and every one of them was a nightmare of workarounds and tricks that were piling up and hard to maintain.
It clicked when I was tasked with redoing the store dashboards. We had very specific KPIs to show while keeping the design slick and coherent. I spent a few days trying to find solutions to each of my new problems, and that is when I finally decided that the easiest way to tackle it would be to build the chart myself instead.
What the native charts will not do
None of these are bugs. They come from how the product is built, which is why being clever about them does not get you very far.
Dimensions and metrics are two separate lists, and that order is the order you get. A native table puts all the dimensions first and then all the metrics. If you want Store, Revenue, Region, Growth in that order, you cannot have it. The usual workaround is to cast a dimension as a metric or the other way round, which breaks the aggregation, and that is how you end up with a table that is only correct at one level of grouping.
Conditional formatting only looks at the cell's own value. You can colour revenue by revenue. You cannot colour revenue by margin. The accepted trick is a calculated field that smuggles the other column's value into the one you are displaying, so the number on screen stops being the number.
A chart only sees the rows that survive the filters. This one is less a limitation than a fact about how the thing works, but it is the one that hurt the most. "Last week's number with the last five weeks behind it" is two different windows over the same query, and a chart gets one query.
The escape hatch
Community visualisations are the supported way out, and the whole thing is simple
enough that believing it took me longer than building it. You write a JavaScript
file exporting a drawViz(data) function, a JSON schema describing the data slots
and style controls you want in the property panel, and a manifest. You put all of
that in a public Google Cloud Storage bucket, paste the bucket path into the
report, and your chart appears in the picker next to the native ones.
Looker hands your function the rows it has already filtered and aggregated, inside a sandboxed iframe, and what you draw in there is yours.
The toolchain for each of mine is two shell scripts. build.sh glues Google's
dscc helper library onto my code, because Looker will only load one JS resource.
deploy.sh uploads the result with the right content types.
The table
The first one is a table that renders its columns in whatever order you type. It also lets you choose which columns to show, the colours, the formats, and all those things that were blocking me.
Column order is a text field: dimensions.0,metrics.0,dimensions.1,metrics.1.
Leave it empty and you get everything, dimensions first, exactly like the native
table. Fill it in and you only get what you listed. This is the more useful part,
because a column bound in the Data tab but left out of the order is hidden from
the table and still readable by everything else. So to colour revenue by margin
you add margin to the chart, leave it out of the column order, and still get to
use it for your rule.
The colouring is a small rule language, one line per column:
metrics.0: >10000=#1E555C; 5000..10000=#88BDB6; else=#FFE8E8
metrics.1: scale(0=#F4FFF4, 50=#88BDB6, 100=#1E555C)
dimensions.0: ="EMEA"=#E8F4F4; ="APAC"=#FFF1E0
Thresholds, ranges, string matches, a fallback, and gradients with either automatic or explicit stops. Rules are read left to right and the first match wins.
The part I like most is the using clause, which runs the rule against an
arithmetic expression over the same row instead of the cell's own value:
metrics.0 using (metrics.0 - metrics.2) / metrics.0: scale(0=#FFE8E8, 1=#1E555C)
That colours revenue by its margin, where the margin is computed from two columns and one of them is not on screen.
The scorecard
Then, once you have a table, you need scorecards to give an easy read to people who don't want to deep dive into the rows. The idea is that native Data Studio scorecards are only blocks with a single value. Here, I wanted to show gaps, differences and trendlines all on the same card.
It draws in two layouts. A compact card with a category tag, the value, a small badge showing the gap to target and an up or down arrow against last year, and a larger block for the headline number, with a percent of target, a gap note and a like-for-like comparison, which is the same period last year measured on the same basis. You drop one instance per KPI. The dashboard at the top of this page is one large block and ten cards with the figures stripped out, and the filter chips, the title bar and the section labels around them are all native Looker elements. APT on those tiles is our shorthand for average sales per ticket.
Most of the work went into the calculations rather than the design.
Ratios get their components bound, not their result. Instead of binding the average sales per ticket, you bind sales to a numerator slot and tickets to a denominator slot, and the headline becomes the sum of the numerator divided by the sum of the denominator. That stays correct whatever level you aggregate at. The same pair exists for the prior year value, so the comparison runs a correctly rebuilt current ratio against a correctly rebuilt prior one instead of two separately wrong averages.
The comparison value can be a different metric from the displayed one. Show sales, compute percent of target from sales minus mobile sales, compute the year on year comparison from a standardised series. This lets you show numbers that are all correctly calculated on a single scorecard.
The headline derivation is a setting, and its default does nothing. Once you
bind a date field and the data splits into periods, there is no longer an obvious
answer to "what is the big number". The default uses Looker's own SUMMARY aggregate when
the report provides one, so the tile shows exactly what a native scorecard
filtered to the same window would show, with a line behind it and no arithmetic
of mine involved. Latest period, sum, average and first are there for when you do
want them.
Currency comes from the data. Bind a field holding EUR or USD and the symbol and its position are derived from the code, euro after the number and dollar before it, so one tile renders correctly whatever market the row belongs to.
Finally, you get to choose with a single checkbox whether you want to see percentages or raw values. The idea is to let everyone use the dashboard as they prefer, something that is not always the case when you are bound by Data Studio's base functions.
But can it run Doom?
By this point I knew roughly what the iframe would and would not allow, and I had some time to spare.

It is a real community visualisation and not a joke. It declares data slots like any other viz, every row becomes an enemy, the dimension names it, the metric sets its hit points and which of three species it is, and clearing the level clears the table. Tab opens a scoreboard, which is just the table again.
The sandbox makes it more awkward than writing the same game on a normal page. Pointer lock is blocked, so there is no mouse look and you steer by moving the cursor towards the edge of the tile. Nothing can be fetched either, not even from the bucket the viz itself was served from, so every wall texture, sprite and sound is generated in code at load time and the whole game ends up being the single JS file Looker already loads. And Looker quietly removes a viz that has not reported being healthy for about 45 seconds, which a normal chart never notices because it finishes rendering immediately, so the game has to keep telling the report that it is still alive.
Nobody asked for it and it has no business being in a report, but it was a fun way to find out where the walls of the sandbox actually are.
Was it worth it
Three visualisations, about 4,700 lines of JavaScript between them, nothing outside Google's own helper library.
The table and the scorecard let me easily create the dashboard as I wanted it to look, and remove the liability of the methods circumventing Data Studio's limitations. All in all, everyone is happy : we get an easier dashboard to maintain, and the people using it get a better design and easier UI. So it is definitely worth it, and a reminder that when you're hitting too many walls, the solution is often to find (or make) another path.