Code Monkey home page Code Monkey logo

eventdrops's Introduction

EventDrops

EventDrops is a time based / event series interactive visualization tool powered by D3.js.

EventDrops example

If you want to pan and zoom on previous data on your own, here is the demo.

Installation

EventDrops is provided as an npm package. Grab it using the tool of your choice:

yarn add event-drops
npm install --save event-drops

Note you don't need this step if you don't use any module bundler.

Since version 1.0, event-drops follows semantic versionning. Hence, we recommend checking your package.json file and ensure that event-drops version is preceded by a carret:

{
    "event-drops": "^1.0.0"
}

This way, you'll get all bug fixes and non breaking new features.

Usage

Without a Module Bundler

If you don't use any module bundler such as Webpack, we recommend using EventDrop script available on unpkg.com. Grabbing last versions of the library is as simple as:

<link href="https://unpkg.com/event-drops/dist/style.css" rel="stylesheet" />

<script src="https://unpkg.com/d3"></script>
<script src="https://unpkg.com/event-drops"></script>

Then, the code is similar to the one with module bundler (see next paragraph), except you are not forced to specify D3 configuration parameter.

With a Module Bundler

If you use a module bundler, you can import EventDrops the following way:

import * as d3 from 'd3/build/d3';

import eventDrops from 'event-drops';

const chart = eventDrops({ d3 });

const repositoriesData = [
    {
        name: 'admin-on-rest',
        data: [{ date: new Date('2014/09/15 14:21:31') } /* ... */],
    },
    {
        name: 'event-drops',
        data: [{ date: new Date('2014/09/15 13:24:57') } /* ... */],
    },
    {
        name: 'sedy',
        data: [{ date: new Date('2014/09/15 13:25:12') } /* ... */],
    },
];

d3
    .select('#eventdrops-demo')
    .data([repositoriesData])
    .call(chart);

You can either use D3 as a specific import (specifying it in first argument of eventDrops call), or use the global one. By default, it fallbacks to a global defined d3.

Interface

eventDrops function takes as a single argument a configuration object, detailed in the:

Configuration Reference

In addition to this configuration object, it also exposes some public members allowing you to customize your application based on filtered data:

  • scale() provides the horizontal scale, allowing you to retrieve bounding dates thanks to .scale().domain(),
  • filteredData() returns an object with both data and fullData keys containing respectively bounds filtered data and full dataset.
  • draw(config, scale) redraws chart using given configuration and d3.scaleTime scale
  • destroy() execute this function before to removing the chart from DOM. It prevents some memory leaks due to event listeners.
  • currentBreakpointLabel returns current breakpoint (for instance small) among a list of breakpoints.

Hence, if you want to display number of displayed data and time bounds as in the demo, you can use the following code:

const updateCommitsInformation = chart => {
    const filteredData = chart
        .filteredData()
        .reduce((total, repo) => total.concat(repo.data), []);

    numberCommitsContainer.textContent = filteredData.length;
    zoomStart.textContent = humanizeDate(chart.scale().domain()[0]);
    zoomEnd.textContent = humanizeDate(chart.scale().domain()[1]);
};

Contributing

If you want to contribute to EventDrops, first, thank you!

To launch the project locally, grab this repository, install its dependencies, and launch the demo:

git clone [email protected]:marmelab/EventDrops.git
cd EventDrops
make install
make run

Demo will then be available on http://localhost:8080. Source files are watched automatically. Changing one file would automagically reload your browser.

When you are satisfied with your changes, ensure you didn't break anything launching tests:

make test

Finally, if everything is fine, you can then create a pull request.

Feel free to ask some help on GitHub issue tracker. The core team would be glad to help you to contribute.

License

EventDrops is released under the MIT License, courtesy of marmelab and Canal Plus. It means you can use this tool without any restrictions.

eventdrops's People

Contributors

asiby avatar benmoufm avatar busteren avatar chad-ramos avatar chulkilee avatar czukowski avatar deevus avatar djhi avatar fzaninotto avatar gassc avatar jbschlosser-zz avatar jdemangeon avatar joanyin avatar jpetitcolas avatar julianoengineer avatar kmaschta avatar kwesterfeld2 avatar manuquentin avatar marmelab-bot avatar messense avatar nathanathan avatar osadan avatar robinbressan avatar sedy-bot avatar slai avatar twisty-n avatar zyhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eventdrops's Issues

zoomRect appears black

Hello,
I am creating a medical events timeline, and have trouble with the zoomRect SVG appearing black - see image.
Adding .style("opacity", 0) to its declaration seems to do the trick.
Any ideas why it appears black in the first place?
Thanks!

zoomrect

Error while installing event-drops using npm

I wanted to have a non-minified version of eventDrops.js file for my project. I tried to install event-drops using npm. I installed python and VS2015 as I got errors. after that, the installation did not throw previous errors. But, I'm getting a new error like this:

[email protected] install D:\temp_eventDropsInstall\node_modules\contextify
node-gyp rebuild
D:\temp_eventDropsInstall\node_modules\contextify>if not defined npm_config_node_gyp (node "C:\Users...\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
contextify.cc
win_delay_load_hook.c
C:\Users...\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers [D:\temp_eventDropsInstall\node_modules\contextify\build\contextify.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declaration of '__pfnDliNotifyHook2'

Can you please help getting the non minified version of eventDrops.js file?

Meteorjs

How do I use this with Meteorjs? I'm new to js, d3js, and even Meteorjs..

Add data to event

Is it possible to add data to each event? If not, are you planning a similar feature?

I'm doing a chat analyzer and I would like to add the content of the message to the event to display it on hover.

Regards

Uncaught TypeError: t.map is not a function eventDrops.js:15

Hello Again,

I am having issues when pulling in my data from a local server. I am trying to figure out if the issues is from the way I am structuring the array or whether it is an issue within the eventDrop.js file (which is where the error is showing). As I am new to D3 I am guessing the former. I am bringing the data from python and thus have to convert from UNIX to javascript Date object.

myData = {
    "sensor1": [
        1458068401000,
        1458068401000,
        1458068403000,
        1458068404000,
        1458068405000,
        1458068406000,
        1458068411000,
        1458068413000,
        1458068415000,
        1458068416000
    ]
}

my Code

// function that converts UNIX to Date object
function mapDates(value){
    output = new Date(value);
    return output;
}
var testdata = [];
var newdates = [];
d3.json("./datatest.json", function(data)
{   

    var count = Object.keys(data)
    for (i in count)
    {
        testdata.push(data[count[i]].map(mapDates))
        newdates.push({count:testdata})
        console.log(newdates)

    }
    var eventDropsChart = d3.chart.eventDrops()
    var canvas = d3.select("body").selectAll("p")
    d3.select('body')
    .datum(newdates)
    .call(eventDropsChart);


})`   

the error: Uncaught TypeError: t.map is not a function eventDrops.js:15

Please help! Thanks

Update documentation (or example) for eventColor

I see you have this as the description for eventColor:

eventColor: 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'.

Yet you have this example with 2 parameters:

https://github.com/marmelab/EventDrops/blob/master/example/custom/index.html#L72

I can't tell from your variable names what the parameters are supposed to represent.

Can you update the documentation for eventColor if the function has 2 params instead of 1?

Some data are outside the SVG viewport

For instance, currently:

image

If we put another CSS rule on the SVG element (overflow: visible;), we have the correct view:

image

SVG has a red background on the second screenshot.

We need to draw data visible in the viewport, and only them.

No Method to Configure Y-Axis... Words are Cut-Off

I am unable to configure the margins for the Y-axis Labels on the Left.

Essentially I have some long worded labels and they are getting cut off when the chart is drawn for Each Row. There is only a method to set the margins for the charts, that is currently not accounting for the margins of the x or y axes.

Please help. Thanks.

pv9

Create a bower package

Hello,
I see that there is a npmjs package what is very nice.
It can be also helpful if we can use bower repository.
Is it possible to create a new package in that repository ?
Thanks

TypeError: undefined is not an object (evaluating 'e.length')

Hello,
I've been working with d3 for a while, but I came across with EventDrops just yesterday and loved how it looks like. I put the demo's code into my own script and I keep getting this error:

TypeError: undefined is not an object (evaluating 'e.length')

When I delete this line:

eventDropsChart(element);

The error disappears, but the chart is not showed, not even the horizontal lines that are drawn when I keep that line in the code.

I've been trying to fix this, but I can't find my error.

I'd appreciate any help,

Thank you in advance!

Black box displays on top of chart

When I use EventDrops I see a black rectangle on top of the chart. The same happened with the example data you provided. There are no errors in console log. Do you have idea how to solve this?
eventdrops-bug

EventDrops Scroll on drop container issue

On the scroll of drops-container the drop-line overwhelm the labels.kindly find the below snapshot attached .Kindly help me out to fix the issue.

Thanks,
Rekha Jikki
captureeventdrops

changing the event icon

is it possible to change the circle to a rectangular or a line?

and if this is possible, is it possible to change the rectangular's size when zooming?
What I want is that the rect. would get broader the further you zoom in, so that events which follow each other look like a big single rect.?

Hope it is somehow clear what I mean...

Configuration properties can't be changed after construction

Please forgive me - I know very little about d3.js
But if in the example index.html I move start and end away from the constructor to a later phase,
the HTML will not reflect these (though the properties in the debugger seem to be correct)
(I've tested the same with other d3.js examples and there it works)

            var graph = d3.chart.eventDrops()
//move to after construction                .start(new Date(startTime))
//move to after construction                .end(new Date(endTime))
                .locale(locale)
                .eventColor(function (datum, index) {
                    return color(index);
                })
                .width(1200)
                .margin({ top: 100, left: 250, bottom: 0, right: 0 })
                .axisFormat(function(xAxis) {
                    xAxis.ticks(5);
                })
                .eventHover(function(el) { 
                    var series = el.parentNode.firstChild.innerHTML;
                    var timestamp = d3.select(el).data()[0]
                    document.getElementById('legend').innerHTML = 'Hovering [' + timestamp + '] in series "' + series + '"'; 
                });

//moved here
            graph.start = new Date(startTime);
            graph.end = new Date(endTime);

eventClick not a function?

I saw a closed issue about this, said the eventClick function disappeared. I'm looking at the 0.1.2 version and eventClick is still not here?

For Development.

How to setup the dev Environment ?

Example in custom/index.html ( in script tag src="../../src/eventDrops.js") instead of src point to lib. for debugging... but error is throwing.. error : Module name "util/configurable" has not been loaded yet for context: _. Use require([])

AMD Compatability

Would it be possible to wrap the provided built files using the UMD specification? That way we could use it in the AMD world too.

Thanks for the great plugin!

EventDrops local server

Forgive me for such an amateur question - I am new to javascript/html.

I am trying to use the EventDrops chart on a local webpage - but keep getting this 'Uncaught SyntaxError: Unexpected token import' which is pointing to a syntax error in the 'eventDrops.js' file.

Can anyone help? Thanks!!

Top scale doesn't line up with drops and not all drops initially displayed

The dots do not appear to line up with the labels on the top scale, either before or after zooming.

Also, when the chart is first displayed, not all of the drops are shown. If I drag the chart right or left, or scroll out, I can see the other drops. Should I see all drops when the chart is initially displayed?

JSFiddle using eventDrops master: https://jsfiddle.net/rteristi/ewvc8ttf/

Expected behavior (eventDrops 1.2): https://jsfiddle.net/rteristi/mczhgskL/

Screenshot of problem:
image

The behavior is consistent in Chrome and Firefox.

How can I draw dynamic line on the control

I want to use this event to make a video playback control? I would like to add this control function
When the progress of the video player during playback may occur on the controls to play.

How can I draw dynamic line on the control
image

Graph is right aligned

image

It seems regardless of label length, there is a translation of 210 pixels in the positive x direction. It should be dynamic depending on the longest label

Move configurable.js to its own repository

We use configurable.js in several projects because it is very useful. Maybe it would be great to create a dedicated repository for it? (to avoid duplicating it each time)

Generate a chart from any type of data array

The .date function should be used like this:

var eventDropsChart = d3.chart.eventDrops()
    .date(function(d){ return d.date; });

d3.select('#chart_placeholder')
    .datum(data)
    .call(eventDropsChart);`

Instead of

var eventDropsChart = d3.chart.eventDrops();

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

Question on customizations

I'm evaluating using this package for a project but one thing I need to be able to do is put a vertical line on a specific time point and then change the color/shape of any dots on that vertical line.

Is there an easy way to modify the circles to use custom shapes/colors via configuration and add a vertical line on a specific time point or would I have to fork and modify this lib directly to achieve both of these desired results?

The points overlap the labels in Firefox in the demo

When zooming on the demo (through the mouse scroll), the points overlap over the labels instead of disappearing. This is not the same behavior than the one shown in the gif in the readme.
I'm using Firefox 44.0.2 on Ubuntu 14.04

event_drops

No configuration to resolve 'date' from complex datasets

The 0.2.0 release appears to have removed documented support for a custom function to resolve the date from a more complex data set.

For example, after installing EventDrops from npm, I tried to make an example using the code from the README with data of the form

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'}, ...] }
];

The docs say that I should be able to configure the chart using .date(d => d.date). However, date was at some point removed as a configurable parameter from default config.js which means that this function doesn't work and errors out when it is used.

I was wondering if the documentation on GitHub should be synchronized with the 0.2.0 release, and if there was a new way to use this sort of functionality

Custom data per event

Hello,
this is a very nice tool and I think adding new features would make it even more awesome!

One of the features which might be implemented is offering custom data for each event, thus one can use different colors for the event drops considering some specific business logic. Also one could show different information regarding the event over which a user hovers. Someone built something similar to this (check http://hoonzis.blogspot.com/2014/11/events-visualization-with-evendrops-and.html) however latest version does not seem to work properly.

Best regards,
Robert

Circles not metaballing?

First of all, thank you for developing such a nice library.

I have an issue in which the metaballs seems not to be doing what they should (or at least the way I understood them...). I have daily data, and for some hours of the day I have more than 70 events per hour (!). However, when I initialize the chart like this:

const chart = d3.chart.eventDrops()
    .start(new Date(new Date(2016, 1, 9, 23, 59))) // day before
    .end(new Date(2016, 1, 11, 20, 0))  // day after with some margin...
    .date(function(d) {;
        return parseDate(d.date);
    })`

I can see that all the dots have the same size (i.e., there is no "merging" of very close dots to make bigger metaballs), although they're only separated by mere minutes (over the span of 2 days in the axes start and end dates).

Working JSFiddle here: https://jsfiddle.net/Infinity77/0x3L6gj9/3/

If this is not how the library is supposed to work, could you tell me how to modify it to make the metaballs appear for those high frequency hourly events?

I attach a plot of the frequency of the data, just in case...

Thank you in advance for your help.

image

Uncaught TypeError: d3.chart.eventDrops(...).eventClick is not a function

I'm using this with ZeptoJS and getting the above when I use the eventClick method.

    var eventDropsChart = d3.chart.eventDrops().eventClick(function(el) {...});
      ready: function(callback){
      if (readyRE.test(document.readyState) && document.body) callback($)
      else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
      return this
    },...

The above is created by Zepto and this is included in the output.

http://cl.ly/image/011i2m332x1u

eventHover Off or mouse out event?

Is there a mouse out event?

Ive set up the hover to show a tooltip, but dont see a mouse out?

suppose i could set a flag + timer combination but if there is a mouseout that would help a bit.

thanks!

Remove built files from repository

As discussed in #92 by @deevus, we should think about a solution to not pollute diffs and repository with built files. Probably by moving the built files on a dedicated branch and retrieve this release branch for npm releases?

Where is the supplied data used?

Hello! I'm both a college student and an intern at a software development company and I'm doing some research about charts such as this. Your solution is slick and very appealing for this project I'm helping develop. Right now I'm trying to learn how it works with more detail but I can't seem to find an answer. I hope this is the right place to ask for help.

I've done some changes to the source code as I get used to it (mostly just changing the circles with squares) but I can't find where the supplied data is used. I wanted to change the way the Date objects are received but I cannot find where that is. As of right now, your code does not support standart JSON files as input (at least as far as I can tell) and only those specific Date arrays work. Can you point me in the right direction? Thank you for your attention, in any case!

package.json errors

There is an error in your package.json on line 5

{
  "main": "src/EventDrop.js"
}

the file in the src/ directory is called eventDrops.js so this can't be resolved properly.

Disabling zoom

How do you disable zooming with the mouse wheel for the chart? I'm having trying the various mechanisms to unbind the zoom behavior on the chart itself. We'd ideally like to control zooming behavior with a separate control to prevent capture of the mouse.

I need your help with the excample

Thanks for your desigen.
I download the excample , there was not '../../d3/d3.js' in the zip.
I fix it with d3-3.1.0, but an error happened
Uncaught TypeError: Object # has no method 'locale'
How can I fix it, would you like help me?
I run it on ie10,chrome,FF
Thank you!

eventColor - access line info

Is there a way of accessing the event line name when inspecting a datum within eventColor?

I am plotting different types of dates within a row and I would like to colour each datum based upon what type of date they are.

I have hacked around this by cycling through the data in all event lines for a given date type (within .eventColor) and returning the specific colour for that date type if the datum value matches. This breaks if the same date value exists elsewhere on another line, as the same colour will get assigned to both irrespective of data type.

An improvement would be to look when index becomes zero, as this will signify that the datum is on the next line to the previous and from this I can work out what line it belonged to.

I was wondering however if there is a nicer way of doing this, if there is a way of getting the line name for a datum within eventColor?

Or to be able to pass in multiple lists to the createEvent function and colour a datum based upon which list it came from?

Getting event name on eventHover/eventClick

I have events, that I want to display a tooltip for with the repo name of the event.

var data = [
         {
             name: "Stars",
             dates: [new Date('2014/09/15 13:24:54'), new Date('2014/09/15 13:25:03')],
            repos: ['test/test','debug/debug']
         }, {
             name: "Pushs",
            dates: [new Date('2014/08/15 11:24:54'), new Date('2014/09/15 13:25:03')],
            repos: ['test/test','debug/debug']
         }];

Currently d returns only the datetime.

Style.css isn't a valid css file

https://github.com/marmelab/EventDrops/blob/master/css/style.css
has errors.
Please make it a valid css file.

Major error is https://github.com/marmelab/EventDrops/blob/master/css/style.css#L11.
The path class here is treated like a name of a property in plain css.
If your style.css would be style.scss it could be so.

The problem which I encounter is that I have a *.scss file in which I'm going to import your style.css
And sass processing fails with error:

// Unhandled 'error' event
Error: property missing ':' near line 11:9

it's because of your style.css is treated as plain css. If I rename your file to style.scss, it's imported correctly, because scss can handle such syntax.

Also CSS editor shows minor warning on line 9, it contains unneeded comma.

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.