Skip to content

Simplify imports (scales, curves, projections, etc) #478

@techniq

Description

@techniq

Instead of requiring imports from d3-scales, d3-shape, d3-geo, we should support simple strings for many of these use cases (but still support functions for custom implementations including pulling from other sources such as d3-geo-projection) or d3-geo-polygon).

This will

  • Simplify the packages needing to be installed by the user
  • Knowing the packages and import names (prefixes like scale*, geo*, curve*, etc)
  • Explorability of the API (ex. auto complete when <Spline curve=" is typed with available options)

Scale

Before

<script>
  import { scaleBand } from 'd3-scale';
</script>

<Chart xScale={scaleBand()} />

After

<Chart xScale="band" />

Curve

Before

<script>
  import { curveMonotoneX } from 'd3-shape';
</script>

<Spline curve={curveMonotoneX} />

After

<Spline curve="monotoneX" />

Projection

Before

<script>
  import { geoOrthographic } from 'd3-geo';
</script>

<Chart geo={{ projection: geoOrthographic }}>...</Chart>

After

<Chart geo={{ projection: 'orthographic' }}>...</Chart>

Will need to consider how this impacts the library size / tree shaking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions