Coder Social home page Coder Social logo

angular-plotly's Introduction

Angular Plotly.js

Usage

Install with bower:

bower install angular-plotly

Include angular, plotly and angular-plotly:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="bower_components/angular-plotly/src/angular-plotly.js"></script>

Add plotly dependency:

var app = angular.module('yourApp', ['plotly']);

Add a chart:

<plotly plotly-data="data" plotly-layout="layout" plotly-options="options"></plotly>

The values expected for data, layout and options can be found in plotly's documentation.

Running the example

Run a simple webserver from the root of your repository:

python -m SimpleHTTPServer 8000

Open the following url:

http://127.0.0.1:8000/example/index.html

Optional Event Subscription:

Plotly can also be initialized with plotly-events

<plotly plotly-data="data" plotly-layout="layout" plotly-options="options" plotly-events="plotlyEvents"></plotly>

Where plotlyEvents is a function that accepts the plotly.graph Object as a parameter. This function is only called once during initialization and can be used to create listeners for the various plot events such as:

  • plotly_click
  • plotly_beforehover
  • plotly_hover
  • plotly_unhover
  • plotly_relayout
  • plotly_selecting
  • plotly_deselect
  • plotly_doubleclick
  • plotly_beforeexport
  • plotly_afterexport
  • plotly_afterplot
  • plotly_redraw
  • plotly_clickannotation

An example plotlyEvents definition is:

$scope.NumberOfSelectedPoints = 0;
$scope.plotlyEvents = function (graph){
  graph.on('plotly_selecting', function(event){
    if (event) {
      $scope.NumberOfSelectedPoints = event.points.length;
      $scope.$digest();
    }
  });
};

angular-plotly's People

Contributors

alonho avatar closedloop avatar jrafael80 avatar m-kharbat avatar senften avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.