【问题标题】:PrimeNg Pie Chart - By default show all tooltip?PrimeNg 饼图 - 默认显示所有工具提示?
【发布时间】:2018-08-19 16:58:51
【问题描述】:

我在我的 Angular 6 应用程序中使用基于 Charts.js 2.7.x 的 PrimeNg(最新)创建饼图。一切正常。 但我有一个要求,默认情况下我想在饼图中显示所有工具提示。 我要实现:this

我找到并尝试了如下选项,但它不起作用。只有标题和图例有效:

<p-chart type="pie" [data]="data" [options]="options"></p-chart>

this.options = {
  onAnimationComplete: function() {
    this.showTooltip(this.segments, true);
  },

  tooltipEvents: [],

  showTooltips: true,
  title: {
    display: true,
    text: 'My Title',
    fontSize: 16
  },
  legend: {
    position: 'bottom'
  }
}

有什么方法可以在 PrimeNg 中实现这一点?已添加Plunk

【问题讨论】:

    标签: angular chart.js primeng


    【解决方案1】:

    根据this,你需要将intersect作为false传递。默认为true

    尝试像这样更新您的配置:

    this.options = {
      onAnimationComplete: function() {
        this.showTooltip(this.segments, true);
      },
    
      tooltipEvents: [],
    
      tooltips: {
        intersect: false
      },
    
      showTooltips: true,
      title: {
        display: true,
        text: 'My Title',
        fontSize: 16
      },
      legend: {
        position: 'bottom'
      }
    }
    

    【讨论】:

    • 它解决了我图表中的另一个问题 :) 但不是我提到的那个。我试过但看不到所有的工具提示。
    • 如果可能,请创建一个小提琴并分享链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多