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

ng-vega

v1.4.0

Published

Angular directive for rendering vega specs

Downloads

8

Readme

ng-vega

Angular directive for rendering Vega specs. This project was forked and modified from angular-vega which was written for Vega 1 and became inactive. The current version of ng-vega supports Vega 2.

Demo

  • Simple demo -- Select dataset/renderer to see the chart changes and see the code to see how it was implemented.
  • Vega editor demo -- Implement Vega editor using ng-vega.

For more information about Vega, please refer to official documentation.

Usage

angular.module('exampleApp', ['ngVega'])
<div vega spec="spec" vega-data="testData" vega-renderer="'svg'" vega-on-parse="myCallback(view)"></div>
  • spec is $scope.spec in your controller.

  • vega-data (optional) can be used to pass dynamic data. In the example above, it is bound to $scope.testData. Data can be a function to modify the values (Vega 2 syntax) or raw values (and ng-vega will convert it to a function to make it work for you).

$scope.testData = {
  // function to modify dataset name "table"
  table: function(data){
    data.remove(function(d){return true;})
      insert([{a: 3}, {a: 4}])
  }
}

$scope.testData = {
  // raw values for dataset name "table"
  table: [{a: 1},{a: 2}] 
}
  • vega-renderer (optional) can be used to set renderer ('canvas' or 'svg'). Don't forget the quote.

  • vega-on-parse (optional) can be used to get notified when spec is parsed and to receive a handle to the View Component that Vega has built for the corresponding chart. In the example above, this parameter is bound to $scope.myCallback.

$scope.myCallback = function(view) {
  // perform any work you need to do once the spec is parsed
  console.log('Vega spec has been parsed.');
  // make use of the View Component API as you wish
  view.on('click', function(event, item) {
    console.log('clicked on ' + JSON.stringify(item));
  });
};

Installation

bower install ng-vega --save

or

npm install ng-vega --save

Import into your project

Angular module ngVega will be available once you do one of the following:

Choice 1. Global

Adding this library via <script> tag is the simplest way.

<script src="path/to/angular.js"></script>
<script src="path/to/vega.js"></script>
<script src="path/to/ng-vega.min.js"></script>
Choice 2: AMD

If you use requirejs, this library support AMD out of the box.

require.config({
  paths: {
    angular:   'path/to/angular',
    vega:      'path/to/vega',
    'ng-vega': 'path/to/ng-vega'
  }
});
require(['ng-vega'], function() {
  // do something
});
Choice 3: node.js / browserify
require('ng-vega');

Author

Krist Wongsuphasawat / @kristw

Copyright (c) 2016 Krist Wongsuphasawat. MIT License