Skip to main content
100%

Spinner with d3-component

✓ Published0🌍 Public
CCurran Kelleher
Last edited Jul 13, 2019
Created on Feb 28, 2017

This example demonstrates how to display a spinner while data is loading and replace it with a bar chart after a simulated fetch. It uses d3-component’s conditional rendering to switch between components, with a local timer driving the spinner’s rotation based on elapsed time. The visualization is rendered as SVG, using D3 transitions with a bounce ease to animate bar heights.

AI-generated description

This example demonstrates usage of d3-component to create a spinner component, and render it conditionally while something is loading. After loading finishes, the spinner goes away and is replaced by another component.

How often have you seen a data visualization show nothing but a blank screen while the data is loading? Showing a spinner with D3 and hiding it after data is loaded is not as easy as it seems. Here's a solution for doing this, feel free to use it in your projects!

This demonstrates the following patterns supported by d3-component:

  • Use of local state and lifecycle hooks (spinner timer).
  • Composition of components with conditional rendering (app component).

Built with blockbuilder.org

forked from <a href='http://bl.ocks.org/curran/'>curran</a>'s block: <a href='http://bl.ocks.org/curran/fc8f6989901628e2e79d6374849453ed'>Posts with D3 Component</a>

forked from <a href='http://bl.ocks.org/curran/'>curran</a>'s block: <a href='http://bl.ocks.org/curran/20e0f0bfb3e1c20c6535'>Spinny Loading Icon</a>

<!-- Start of SimpleHitCounter Code --> <div align="center"><img src="http://simplehitcounter.com/hit.php?uid=2240082&f=16777215&b=0" border="0" height="18" width="83"></a></div> <!-- End of SimpleHitCounter Code -->
mit Licensed

Similar vizzes