npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reveal.js-d3js

v1.0.0

Published

Add dynamic d3.js visualizations to your reveal.js presentations

Downloads

11

Readme

Reveal.js plugin - d3js

Reveal.js plugin to embed d3.js visualizations in slides with support for transitions triggerd by normal slide navigation. d3.js visualizations are embed as iframe elements.

Check out the live demo

Installation

  1. Copy the file d3js.js into the plugin folder of your reveal.js presentation, i.e. plugin/d3js.

  2. Add the plugins to the dependencies in your presentation

Reveal.initialize({
	// ...
	dependencies: [
		// ... 
		{ src: 'https://d3js.org/d3.v4.min.js' },
		{ src: 'plugin/d3js/d3js.js' },
		// ... 
	]
});

Adding d3.js visualizations to slides

To add a d3.js visualizations to your presentation, simply create a container element with the class fig-container, the attribute data-fig-id with the figure id, and data-file with the path to the html page with the d3.js visualizations. The container can be a div, span or other element.

<section>
    <div class="fig-container"
        data-fig-id="fig-collision-detection"
        data-file="Collision-Detection.html"></div>
</section>

You can also embed the visualization in the background by adding the fig-container class to the section element like in the demo under demo/index.html.

<section class="fig-container"
        data-fig-id="fig-collision-detection"
        data-file="Collision-Detection.html"
        data-transitions="2">
    <h2>d3.js plugin for reveal.js</h2>

    Press right arrow to trigger transitions and left arrow to invert transition.
</section>

Finally, you can embed visualization in markdown slides using the special syntax to add attributes markdown elements.

<section data-markdown>
    <script type="text/template">
        <!-- .element: class="fig-container" data-fig-id="fig-collision-detection" data-file="Collision-Detection.html"-->
    </script>
</section>

Adding transitions

To add transitions, simply create two global variables in the html page with the d3.js visualizations:

  1. _transitions is an array with functions that for each transition.

  2. _inverse_transitions is an array with functions that revert each transition when user navigates back. _inverse_transitions can be set to [] if this functionality is not required.

The plugin automatically looks at the number of elements in the array _transitions and creates corresponding fragments in the container slide.

In the example, Collision-Detection.html adds two transitions:

var _transitions = [],
    _inverse_transitions = [];

_transitions.push(
  () => d3.selectAll("circle")
 			.transition().duration(1000)
 			.attr("r", function(d) { return d.radius * runif(0, 2); })
);
_inverse_transitions.push(
  () => d3.selectAll("circle")
  			.transition().duration(1000)
  			.attr("r", function(d) { return d.radius; })
);
_transitions.push(
  () => d3.selectAll("circle")
  			.transition().duration(1500)
  			.style("fill", "#33ff33")
);
_inverse_transitions.push(
  () => d3.selectAll("circle")
  			.transition().duration(1500)
  			.style("fill", function(d, i) { return color(i % 3); })
);

License

MIT licensed

Copyright (C) 2017 Joscha Legewie