Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's not possible to hide the initial tooltip on bar charts. #72

Open
IbrH opened this issue Feb 9, 2019 · 1 comment
Open

It's not possible to hide the initial tooltip on bar charts. #72

IbrH opened this issue Feb 9, 2019 · 1 comment

Comments

@IbrH
Copy link

IbrH commented Feb 9, 2019

I tried every possible options that is supposed to hide the initial tooltip before the image is created, but none work. My example code:

var chartNode = new ChartjsNode(550, 400);
  data = {
  datasets:[{
    data:[65,59,80,81,56,55,40],
    fill:false,
    backgroundColor:["rgba(255, 99, 132, 0.2)","rgba(255, 159, 64, 0.2)","rgba(255, 205, 86, 0.2)","rgba(75, 192, 192, 0.2)","rgba(54, 162, 235, 0.2)","rgba(153, 102, 255, 0.2)","rgba(201, 203, 207, 0.2)"],
    borderColor:["rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(54, 162, 235)","rgb(153, 102, 255)","rgb(201, 203, 207)"],
    borderWidth:1}]
  };
  var options = {
    type: 'bar',
    data: data,
    options: {
      title:{
        display: true,
        text: "Members in each category"
      },
      tooltips: {
        enabled: false,
        custom : function(tooltipModel){
          tooltipModel.opacity = 0;
        }
      },
      legend: {
        labels: {
          //fontColor: 'white',
          //fontSize: 18
        }
      },
      scales: {
        xAxes: [{
          gridLines: {
            color: 'rgba(255,255,255,0.1)'
          },
          type: 'category',
          labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
          ticks: {
            fontSize: 15,
            fontColor: 'white'
          }
        }],
        yAxes: [{
          gridLines: {
            color: 'rgba(255,255,255,0.1)'
          },
          ticks: {
            fontSize: 15,
            fontColor: 'white'
          }
        }]
      }
    }
  };
  await chartNode.on('beforeDraw', function (Chartjs) {
    Chartjs.defaults.global.showTooltips = false;
    Chartjs.defaults.global.tooltips.enabled = false;
  });
  await chartNode.drawChart(options);
  buffer = await chartNode.getImageBuffer('image/png');

grafik

@IbrH
Copy link
Author

IbrH commented Feb 9, 2019

I realized it's not a tooltip but just a box and label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant