Created
March 15, 2017 22:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) + " Billion<br>" + year + ' - ' + month + "" | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment