RAWGraphs core provides a set of utility functions that can be used in the
render function of a chart implementation.
This library includes utilities to generate legends like the ones seen in charts of the RAWGraphs app.
These utilities may be used in svg charts rendered using the d3 library, as are based on d3 scales to automatically draw legends for color and size scales.
Here's an example of the legend displayed in a bubblechart from the RAWGraphs app:
Here you can see an example of using these functions in the bubble chart from the rawgraphs-charts repository.
One recurring problem when implementing visualisations is the collision of labels.
If the chart rendering is based on d3 and your using the
data method of a
selection to generate the viz,
labelsOcclusion utility helps you solve this problem.
The function takes a d3 selection and the function for getting the priority for each datum. Here's an usage example:
You can see the utility in action in the beeswarm chart in the RAWGraphs app, when setting to
true the Auto hide labels visual option:
Here you can see an example of using the function in the beeswarm from the rawgraphs-charts repository.