Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

Canvas BarChart Tooltip Angular

I am using canvas barchart to display number of votes. The problem that I am facing is that the tooltip only appears on mousehover. Is there a way to display the tooltip always, I mean that it does not disappear ever. Thanks. enter image description here

Below is my current options array.

 public chartOptions: any = {
tooltips: {enabled: true},
// hover: {mode: null},
responsive: true,
scales: {
  yAxes: [{
    display: true,
    ticks: {
      beginAtZero: true,
    }
  }]
},
 animation: {
  duration: 0,
  onComplete: function () {
    const chartInstance = this.chart,
      ctx = chartInstance.ctx;

    const fontSize = 20;
    const fontStyle = '600';
    const fontFamily = 'Open Sans';
    // ctx.font = Chart.helpers.fontString(fontSize, fontStyle, fontFamily);

    ctx.textAlign = 'center';
    ctx.textBaseline = 'bottom';
    
    ctx.fillStyle = '#676A6C';

    this.data.datasets.forEach(function (dataset, i) {
      const meta = chartInstance.controller.getDatasetMeta(i);
      meta.data.forEach(function (bar, index) {
        if (dataset.data[index] !== 0) {
          const data = dataset.data[index];
          ctx.fillText(data, bar._model.x, bar._model.y);
        }
      });
    });
  }
}

};


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...