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

venny

v0.1.0

Published

Declarative Venn diagrams

Downloads

27

Readme

Venny

Venny is a set of custom elements used to show Venn/Euler Diagrams on a web page. These Web Components are framework indepenedent and can easily be used with any framework or in markdown.

Venny is based on venn.js which provides the algorithms to layout area proportional Venn and Euler diagrams.

Venny is good for area proportional diagrams with as many sets but not very good when the intersections are of more than three sets.

Usage

In your HTML you can import the library and just use the venn- elements in your HTML

For example:

<script type="module" src="https://unpkg.com/venny?module"></script>

<venn-diagram>
  <venn-set name="A" label="Apples"></venn-set>
  <venn-set name="B" label="Oranges"></venn-set>
  <venn-n sets="A B" label="Fruit"></venn-n>
</venn-diagram>

will create:

Venn diagram example

You can also import Venny in your JavaScript project from NPM

npm install venny -s

Styling & Interactivity

Venny components expose CSS properties to let you control the styling of the section. See more in the Styling section.

Since these components are just DOM Nodes, you can add click and other handlers to them as you would add to any other node.

Usage Examples

More usage and examples on this website: Venny Website

Documentation

Venny is a set of three components: venn-diagram is the container. venn-set represents a set or, visually a circle. venn-n describes intersection of sets.

venn-diagram

This is the outer-most element for any diagram. It sets the size of the diagram. The default size is 600px x 350px. These values can be set as properties or via atttributes to the node. These properties/attributes are reactive. When set, the diagram will recalculate the sizes of the shapes.

<venn-diagram width="400" height="200">
  <venn-set name="A"></venn-set>
</venn-diagram>
const vd = document.querySelector('venn-diagram');
vd.width = 400;
vd.height = 200;

venn-set

This element represents a single Set. It must have a name property. You can also set a label property which gets displayed in the diagram.

Circles corresponding to each set are sized based on the size property which has a numeric value. If no size is set, it is assumed that the set's size is 10.

<venn-diagram>
  <venn-set name="A" label="Apples" size="20"></venn-set>
  <venn-set name="B" label="Bananas" size="10"></venn-set>
</venn-diagram>

Venn Diagram with differrnt sized sets

venn-n

This element represents the intersection of two or more sets. The intersecting sets are specified in the sets property, which is a list of space separated set namnes. Like a set, the intersection can alsoe have a label and a size. The size property indicates how much the sets are intersecting. e.g. two sets each of size 10, can have 5 elements in the intersection or just 1.

<venn-diagram>
  <venn-set name="A"></venn-set>
  <venn-set name="B"></venn-set>
  <venn-n sets="A B" size="5" label="Five"></venn-n>
</venn-diagram>

<venn-diagram>
  <venn-set name="A"></venn-set>
  <venn-set name="B"></venn-set>
  <venn-n sets="A B" size="1" label="One"></venn-n>
</venn-diagram>

Screen Shot 2021-11-17 at 10 58 04 PM Screen Shot 2021-11-17 at 10 57 52 PM

Normally when more than two sets are intersecting, you should declare all possible intersections but it is not necessary. e.g. If three sets are intersecting, you can just provide one intersection for sets A, B, C. Venny will automatically assume values for intersections of A, B B, C and A, C.

<venn-diagram>
  <venn-set name="A"></venn-set>
  <venn-set name="B"></venn-set>
  <venn-set name="C"></venn-set>
  <venn-n sets="A B C"></venn-n>
</venn-diagram>

Screen Shot 2021-11-17 at 11 01 17 PM

Or you can be specific

<venn-diagram>
  <venn-set name="A"></venn-set>
  <venn-set name="B"></venn-set>
  <venn-set name="C"></venn-set>
  <venn-n sets="A B C" size="1"></venn-n>
  <venn-n sets="A B" size="5"></venn-n>
  <venn-n sets="A C" size="3"></venn-n>
</venn-diagram>

Screen Shot 2021-11-17 at 11 02 07 PM

Nested Sets

When you need to show that a Set is a subset of another one, you can create an intersection expressing that, or you can define the Subset as a child of the parent Set. Venny will automatically generate the intersection of the two.

<venn-diagram>
  <venn-set name="A" label="Apples"></venn-set>
  <venn-set name="B" label="Oranges">
    <venn-set name="C" label="Lemons">
      <venn-set name="D" label="Limes"></venn-set>
    </venn-set>
  </venn-set>
  <venn-n sets="A B" size="1" label="A+O"></venn-n>
</venn-diagram>

Screen Shot 2021-11-17 at 11 11 15 PM

Styling

Venny exposes custom CSS properties to style the diagrams. Color, opacity of the set fill, stroke colors can be specified for the normal and the hover states.

Styling Circles

Fill Color: A dynamic color is assigned to each circle. But this can be overriden by setting the css property --venn-circle-[name]-fill where name is the name of the set in lower-case. e.g. --venn-circle-apples-fill: red;

A corersponding property --venn-hover-[name]-fill can be set to change the color of the set when the user hovers over the set.

Fill Opacity: By default all circles are filled with an opacity of 0.25. Having a translucent fill easily shows the intersections between the sets. However the default value of this can be set by setting the --venn-circle-fill-opacity property. To change the fill opacity only of a specific set you can set the --venn-circle-[name]-fill-opacity property by substituting [name] with the name of the set in lower-case.

Corresponding hover properties are --venn-hover-circle-fill-opacity and --venn-hover-circle-[name]-fill-opacity to change the opacity on hover.

Stroke: Circles are not drawn without any stroke (outline). But circle stroke color, size can be set using following properties:

--venn-circle-stroke to set the color of the stroke of all circles. --venn-circle-[name]-stroke to set the stroke color of a specific set.

--venn-circle-stroke-width to set the width of the stroke of all circles. --venn-circle-[name]-stroke-width to set the stroke width of a specific set.

Replace --venn- with --venn-hover- in these styles to set these when hovered.

Styling Intersections

Intersection strokes can be set using --venn-intersection-stroke and --venn-intersection-stroke-width prroperties.

To set stroke on a specific intersection specify the intersecting set names in lower case, separated by a - e.g. --venn-intersection-a-b-stroke sets the stroke color only of the intersection of Sets A and B.

Replace --venn- with --venn-hover- in these styles to set these when hovered.

Styling Labels

By default labels use the same color as their corresponding sets but with full opacity. Intersection labels are black by default.

--venn-label-color can be set to set the color of all labels.

--venn-label-[name]-color to set the label color of a specific set or intersection. e.g --venn-label-a-b-color sets the label color of the intersection of sets A, B

Following properties cannot be set on a set specifc levl at the moment:

--venn-label-size sets the font size of the label.

--venn-label-font-family sets which Font you'd like to use for the labels.

--venn-label-font-weight sets the font weight which defaults to normal / 400.

Sponsor

If you like my whimsical open source projects like this one, you can show some love by sponsoring me https://github.com/sponsors/pshihn Or just Tweet at me to show your love, that's equally appreciated :)