简体   繁体   English

不能在打字稿上使用d3 v5上的提示?

[英]can't use tip on d3 v5 on typescript?

i have this code: 我有这个代码:

 var tip = d3.tip()
      .attr('class', 'd3-tip')
      .attr('id', 'tooltip')
      .html(function(d) {
        return d;
      })
      .direction('n')
      .offset([-10, 0]);

i am getting this error: 我收到此错误:

property tip does not exist on type @types/d3/index 类型@ types / d3 / index上不存在属性提示

I tried this without success: 我尝试了这个没有成功:

import * as d3 from 'd3';
import * as d3Tip from "d3-tip";
(d3 as any).tip = d3Tip;

how do i make this work? 我怎么做这个工作?

This should work. 这应该工作。

import * as d3Tip from "d3-tip";

var tip = d3Tip.tip()
      .attr('class', 'd3-tip')
      .attr('id', 'tooltip')
      .html(function(d) {
        return d;
      })
      .direction('n')
      .offset([-10, 0]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM