Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting error for d3-tip in angular2

Tags:

angular

d3.js

I am using both d3 and d3-tip along with their @types,

 "@types/d3": "^4.4.0",
"@types/d3-tip": "^3.5.2",

"d3": "^4.4.0",
"d3-tip": "^0.7.1",

I have below import statement,

import * as d3 from 'd3';

When trying to compile below typescript code, got below error,

 var tip = d3.tip()
        .attr('class', 'd3-tip')
        .offset([-10, 0])
        .html(function (d) {
            return "<strong>Frequency:</strong> <span style='color:red'></span>";
        })

Error,

error TS2339: Property 'tip' does not exist on type 'typeof "C:/bugFix/WebPackPOC/src/WebPackApp/node_modules/@types/d3/index"'. 
like image 269
shazia perween Avatar asked Dec 13 '16 15:12

shazia perween


1 Answers

You are importing d3 but not d3-tip, which is another package.

import 'd3-tip';
like image 109
Yonet Avatar answered Oct 31 '22 17:10

Yonet