inst/htmlwidgets/lib/EventDrops/README.md

EventDrops

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

EventDrops example

Installation

You can use npm to install event-drops

npm install event-drops --save

For Bower users, even if Bower is not officially supported, you can still use GitHub URL such as:

{
    "dependencies": {
        "eventDrops": "marmelab/EventDrops#0.1.2"
    }
}

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 can be an array of named time series. For instance:

var data = [
  { name: "http requests", data: [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", data: [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", data: [new Date('2014/09/15 13:25:12'), ...] }
];

You can also generate a chart from any type of data array but this requires us to supply a function that will return a date from each data point. The complete data object will be available during the eventColor and eventClick callbacks for example. An example data set:

var data = [
  { name: "http requests", data: [{date: new Date('2014/09/15 13:24:54'), foo: 'bar1'}, {date: new Date('2014/09/15 13:25:03'), foo: 'bar2'}, {date: new Date('2014/09/15 13:25:05'), foo: 'bar1'}, ...] },
  { name: "SQL queries", data: [{date: new Date('2014/09/15 13:24:57'), foo: 'bar4'}, {date: new Date('2014/09/15 13:25:04'), foo: 'bar6'}, {date: new Date('2014/09/15 13:25:04'), foo: 'bar2'}, ...] }
];

And the corresponding "date" function that returns a date for each data point.

var eventDropsChart = d3.chart.eventDrops();
d3.select('#chart_placeholder')
  .datum(data)
  .date(function(d){
      return d.date;
  }),
  .call(eventDropsChart);

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:

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:

make install

For development purpose, you can use the following command:

make run

It serves the demo at http://localhost:8080. It also watches source files and live reloads your browser as soon as a change is detected.

When your changes are done, ensure that all tests pass with:

make test

Finally, if everything is fine, you can rebuild the library using:

make build

However, for better Pull Request reviewing, please do not commit the build files in the same PR. You can then rebuild it once merged.

License

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



timelyportfolio/eventdropR documentation built on May 31, 2019, 1:49 p.m.