Code Monkey home page Code Monkey logo

nvd3's Introduction

addEvents in NVD3

This repository is extended from novus/nvd3. Before moving ahead, we highly recommend to go through README.md of novus/nvd3 for usage and learning NVD3.

It has one additional functionality addEvents for showing events by adding a vertical line, which on hover event displays a popup showing event's description on graph. You can read more about why we built this function on our blog.

Requirements

  • d3.js (NVD3 is dependent on d3.js)
  • jQuery (addEvents feature requires jQuery)

Usage

    nv.utils.addEvents(divId, eventsList, chart);

Example

var events = {
    "x1": "event details for x1",
    "x2": "event details for x2",
    "x3": "event details for x3",
    "x4": "event details for x4"
};

nv.addGraph(function() {
    var chart = nv.models.lineChart()
        .useInteractiveGuideline(true);

    chart.xAxis
        .axisLabel('Time (ms)')
        .tickFormat(d3.format(',r'));

    chart.yAxis
        .axisLabel('Voltage (v)')
        .tickFormat(d3.format('.02f'));

    d3.select('#chart svg')
        .datum(data())
        .transition().duration(500)
        .call(chart);

    nv.utils.windowResize(chart.update);

    // Add events by providing list of events
    nv.utils.addEvents('#chart', events, chart);
    return chart;
});

Checkout the examples/lineChart.html for complete code.

To Do:

  • Remove the jQuery dependency, such that the only library required is d3.js.
  • options to change look and feel of vertical line and popups

Frequently Asked Questions:

  • How to learn NVD3?

    Checkout NVD3 examples for coding your first chart.

  • Why did you not send a PR for extended feature to novus/nvd3?

    Robin Hu (Frontend Software Engineer at Novus Partners) commented on issue #1063 (titled "Extending charts?") that the officially recommended way to extend NVD3 is by forking the NVD3 repo and just adding the functionality we need into the code directly.

nvd3's People

Contributors

balmma avatar barakchamo avatar bgth avatar bobmonteverde avatar crenshinibon avatar davidsouther avatar fshao816 avatar itay avatar jakubdostal avatar jdlubrano avatar jjzazuet avatar joshjordan avatar klangfarbe avatar ksgy avatar liquidpele avatar lucaslin avatar mgalloue avatar mrijke avatar ovvn avatar portante avatar renatoutsch avatar rinand avatar rmleon avatar robinfhu avatar sghazzawi avatar snoble avatar thomasbrierley avatar turgar avatar twolfnovus avatar ywplee 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.