nivo icon indicating copy to clipboard operation
nivo copied to clipboard

feat(swarmplot): add support for log axis and legends

Open tkonopka opened this issue 3 years ago • 1 comments

Addresses themes raised in #1939 and #1992

Adds features to the swarmplot:

  • support for log scales along the value axis
  • support for legends

Example

2022-06-03-swarmplot-legends

Implementation

Support for log scales required tweaks to the typescript definition for the valueScale prop. This was simple conceptually, but also required propagating the changes to functions that process coordinates. In practice, this is achieved by defining new types for the value-scale spec and the scale object. (Using dedicated types seemed more robust that extending the existing approach of joining primitive types using 'or'). Propoagating these changes introduces several code edits. However, the edits do not introduce any new real features. (It was already possible to use a log scale before). The advantage of the changes is that typescript users will be able to use log scales without seeing warnings.

Support for legends required addition of new props legendLabel and legends to the SwarmPlot and SwarmPlotCanvas components. These follow the nomenclature and formats from other nivo packages.

Two new stories have examples for how to use log scales and legends.

Can make further changes and improvements if needed.

tkonopka avatar Jun 03 '22 12:06 tkonopka

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 124ac73d774fe239f2e9977685649fc82d7f6bf4:

Sandbox Source
nivo Configuration

codesandbox-ci[bot] avatar Jun 03 '22 12:06 codesandbox-ci[bot]