Exploring Data-Driven SVG Part 1 (Colour-fill and Size)

Published Categorized as Creative, Experimentation, HTML Content Visual, Infographic, Power BI, SVG

In earlier years of using Power BI I came across an article by David Eldersveld on utilising SVG and colour fill. I was wrapped with the idea and immediately set about using it for my own reports. One of the first uses was KPI indicators, before the general availability of custom conditional icons. That’s about where my experimentation ended, as the visual options to display SVG were limited.

Fast forward a year or so and a new HTML visual appeared on the scene with added measure support. Ooh. Never mind that it won’t print to pdf, what can I now do with it?!
I’d used colour fill plenty before, however, I was constrained using size. So why not change the length of an SVG element with a measure, like a Pinocchio nose? I searched “lies dataset” and the top result was this rich source by the Washington Post. (At the time, the count was 5229, this has since grown and a CSV made available for download).

With the help of Adobe Illustrator I imaged traced a silhouette, and overlayed a rectangle element on the nose. After exporting the image as SVG, I copied the code and pasted into a measure.

Measure = 
VAR Size =  86 + Max('Lies'[Index])
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5000 1500'>"
  & [Image] & "
  <rect x='818' y='814.56' width="& IF(HASONEVALUE('Lies'[Date]),Size,86) &" height='35' rx='17.5' ry='17.5'/>

For the width I thought that 1 coordinate point per lie would be sufficient enough to see the nose grow over time. I added the lies in a separate Text Enhancer visual, pulled the date into the Play Axis visual and eagerly hit play.

Wow. The nose went over the page!

I next added the finishing touches with the background. I’m no graphic designer, and I have quite a distaste for backgrounds on business reports and dashboards, but felt as this was not intended to be a business report, I would embellish a little.

The result? An Infographic of a different kind.