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

vue-interactive-graphics

v1.2.10

Published

vue component for interactive graphics (drag and drop, visualization and two way data binding)

Downloads

30

Readme

vue-interactive-graphics (geometry?)

Vue-interactive-graphics component allows to manipulate easily geometric objects by drag and two way data-binding. Under the hood, it uses d3.js.

usage

<InteractiveGraphics
  :width="800"
  :height="400"
  :dataString="dataText"
  @update="dataUpdate"
/>
  • width, height: (numbers), dimentions in pixels of the component
  • dataString: (string), JSON object as a string representing the data
  • dataUpdate ( fun: string -> void ) update function called when vue-interactive-graphics modifies some values in the data (when the user drags some element)

data structure

data passed is a JSON object given to vue-interactive-graphics as a string and is composed by the following elements:

  • instr: List of instructions (Line, Circle, etc.). All of them are listed below.
  • layerOrder: Indicates layers to display and in which order
  • drawSize: size of the drawing area (indicated by fields w and h).
  • background: (OPTIONAL) background color, by default white.

Line Instruction

Line instructions have the following fields:

  • x1,y1,x2,y2: coordinates of the first point and second point as in the SVG spec.
  • stroke: (OPTIONAL) color of the line (by default: '#ccc')
  • stroke-width: (OPTIONAL) width of the line (by default 1)

Circle instruction

Circle instruction have the following fields:

  • cx,cy,r: center and radius of the circle
  • stroke: (OPTIONAL) color of the line (by default: '#ccc')
  • stroke-width: (OPTIONAL) width of the line (by default 1)
  • fill: (OPTIONAL) filling of the area (default: 'black')
  • text: (OPTIONAL) text at the center of the circle
  • textColor: (OPTIONAL) color of text
  • textStroke: (OPTIONAL) border color of the text
  • draggable: (OPTIONAL) allows user to drag the shape

Rectangle instruction

Rectangle instruction have the following fields:

  • x,y,width,height: coordinates and size of the rectangle
  • stroke: (OPTIONAL) color of the line (by default: '#ccc')
  • stroke-width: (OPTIONAL) width of the line (by default 1)
  • fill: (OPTIONAL) filling of the area (default: 'black')
  • text: (OPTIONAL) text at the center of the circle
  • textColor: (OPTIONAL) color of text
  • textStroke: (OPTIONAL) border color of the text
  • draggable: (OPTIONAL) allows user to drag the shape
  • resize: (OPTIONAL) allows user to resize rectangle. Possible values are:
    • constantSurface: surface stay the same as user resizes the shape.

Grid instruction

Grid instruction have the following fields:

  • dim-x, dim-y: size of the grid mesh
  • x,y,w,h: coordinates and size of the grid
  • stroke: (OPTIONAL) color of the line (by default: '#ccc')
  • stroke-width: (OPTIONAL) width of the line (by default 1)
  • fill: (OPTIONAL) filling of the lines (default: 'black')

Rounded path

  • radius: radius of turns
  • width: width of the stroke
  • instructions: list of x,y coordinates of the drawing points

array

  • dim-x: width of tile
  • dim-y: height of tile
  • array: array of array of booleans
  • x,y: position of array
  • stroke: (OPTIONAL) color of the line (by default: '#aaa')
  • stroke-width: (OPTIONAL) width of the line (by default 0)
  • fill: (OPTIONAL) filling of the area (default: 'black')

events

  • update: emited when the user changes something in the drawing and returns new drawing instructions
  • change: emited when the user changes something in the drawing and returns a json object containing:
    • id: id of the instruction (position in the instruction array)
    • changes: dict with values (k,v) where k is the key and v the new value

principles

  • layers : vue-interactive-graphics is given a list of layers. Each layer can be interpreted as a group element (g) in SVG. Each layer contains geometric elements like lines, rectangles, circles, text etc.
  • geometric element : Each geometric element is composed of display properties according to its type and coordinates.
  • scaling factor : According to component size and drawing size, dimentions are scaled.

TODO

  • mobile support
  • add click event
  • add scenarii
  • firefox multiple selection compatibility
  • bug add instruction (grid case)