Skip to content

Instantly share code, notes, and snippets.

@P1xt
Created March 15, 2017 22:52
Show Gist options
  • Save P1xt/c57ddb63dadf774582a848083fbbabfd to your computer and use it in GitHub Desktop.
Save P1xt/c57ddb63dadf774582a848083fbbabfd to your computer and use it in GitHub Desktop.
Snippet containing the relevant code for getting d3-tip to work in an Angular 2 app
var d3 = require("d3");
var d3tip = require('d3-tip')(d3);
//---------------------------------
const tip = d3tip
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function (d) {
const date = new Date(d[0]);
const year = date.getFullYear();
const month = months[date.getMonth()];
return d3.format("$,.1f")(d[1]) + "&nbsp;Billion<br>" + year + ' - ' + month + ""
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment