Skip to content

Specify type g decimal to exponential break point #137

@janosh

Description

@janosh

Is there a to specify at how many decimal places type g switches from decimal to exponential?

I'd like to format everything with more than 3 decimal places as exponential:

expect(d3.format('.3~g')(0.1)).toBe('0.1')
expect(d3.format('.3~g')(0.01)).toBe('0.01')
expect(d3.format('.3~g')(-0.001)).toBe('-0.001')
expect(d3.format('.3~g')(-0.0001)).toBe('−1e-4') // actual: −0.0001
expect(d3.format('.3~g')(-0.00001)).toBe('−1e-5') // actual: −0.00001

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions