Coder Social home page Coder Social logo

travisperson / eventdrops Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marmelab/eventdrops

1.0 1.0 0.0 197 KB

A time based / event series interactive visualization using d3.js

License: MIT License

CSS 1.11% HTML 17.74% JavaScript 81.14%

eventdrops's Introduction

EventDrops

A time based / event series interactive visualization using d3.js. Use drag and zoom to navigate in time.

EventDrops example

Installation

You can use npm to install event-drops

npm install event-drops --save

Additionally you can also use bower

bower install event-drops --save

Usage

Include the src/eventDrops.js script in your page after d3:

<script src="path/to/d3.js"></script>
<script src="src/eventDrops.js"></script>

Tip: You can also use RequireJs, see example/amd for an implementation.

In the HTML source, create a new EventDrops chart, bind data to a DOM element, then call the chart on the element.

var eventDropsChart = d3.chart.eventDrops();
d3.select('#chart_placeholder')
  .datum(data)
  .call(eventDropsChart);

The data must be an array of named time series. For instance:

var data = [
  { name: "http requests", dates: [new Date('2014/09/15 13:24:54'), new Date('2014/09/15 13:25:03'), new Date('2014/09/15 13:25:05'), ...] },
  { name: "SQL queries", dates: [new Date('2014/09/15 13:24:57'), new Date('2014/09/15 13:25:04'), new Date('2014/09/15 13:25:04'), ...] },
  { name: "cache invalidations", dates: [new Date('2014/09/15 13:25:12'), ...] }
];

Configuration

EventDrops follows the d3.js reusable charts pattern to let you customize the chart at will:

var eventDropsChart = d3.chart.eventDrops()
  .width(1200)
  .hasTopAxis(false);

Configurable values:

  • start: start date of the scale. Defaults to new Date(0).
  • end: end date of the scale. Defaults to new Date()
  • width: width of the chart in pixels. Default to 1000px.
  • margin: margins of the graph in pixels. Defaults to { top: 60, left: 200, bottom: 40, right: 50 }
  • locale: locale used for the X axis labels. See d3.locale for the expected format. Defaults to null (i.e. d3 default locale).
  • axisFormat: function receiving the d3 axis object, to customize tick number and size.
  • tickFormat: tickFormat for the X axis. See d3.timeFormat.multi() for expected format.
  • eventHover: function to be called when hovering an event in the chart. Receives the DOM element hovered (uses event delegation).
  • eventZoom: function to be called when done zooming on the chart. Receives the d3 scale at the end of the zoom.
  • hasDelimiter: whether to draw time boundaries on top of the chart. Defaults to true.
  • hasTopAxis: whether the chart has a top X axis. Accepts both a boolean or a function receiving the data of the graph that returns a boolean.
  • hasBottomAxis: same as topAxis but for the bottom X axis
  • eventLineColor: The color of the event line. Accepts a color (color name or #ffffff notation), or a function receiving the eventData and returning a color. Defaults to 'black'.
  • eventColor: The color of the event. Accepts a color (color name or #ffffff notation), or a function receiving the eventData and returning a color. Defaults to null. EventLineColor will be ignored if this is used.
  • minScale: The minimum scaling (zoom out), default to 0.
  • maxScale: The maximum scaling (zoom in), default to Infinity.

Styling

You can style all elements of the chart in CSS. Check the source to see the available selectors.

Extending / Hacking

First, install the dependencies:

$ npm install

Source files are located under the lib/ folder, and use browserify for dependency management. Once your changes are finished, regenerate the combined and minified source under src/ by calling the following command:

$ gulp browserify

To update your change dynamically and have sourcemap that allow the console to map to the original file type:

$ gulp watch

To run the test :

$ gulp test // all test
$ gulp karma-test
$ gulp mocha-test

You can test the result by launching a server at the project root, and navigating to the examples/ directory.

License

EventDrops is released under the MIT License, courtesy of marmelab and Canal Plus.

eventdrops's People

Contributors

chulkilee avatar fzaninotto avatar jbschlosser-zz avatar manuquentin avatar robinbressan avatar

Stargazers

 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.