Skip to main content
100%

Superscript Format

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Sep 28, 2013

A log-scale axis displays powers of ten from 10⁰ to 10⁹, with tick labels formatted using superscript characters (⁰¹²³⁴⁵⁶⁷⁸⁹) via a custom `formatPower` function that maps each digit to its Unicode superscript equivalent. The example uses d3.v3's `d3.scale.log` and `d3.svg.axis`, with tick formatting defined by a custom function passed to `.ticks(10, ...)`. The SVG rendering places the axis with generous top and bottom margins, and the code notes the vertical alignment issue between superscripts and normal digits.

AI-generated description

Perhaps not the best approach due to the inconsistent vertical positioning of ¹²³ vs. the other numbers… Alternatively, you could use axis post-selection to achieve the same effect.

gpl-3.0 Licensed

Similar vizzes