Friday, 5 February 2021

MVC - Chart.js - how to hide tooltips

 Watch this example on YouTube


 

1. To create simple chart 

https://www.youtube.com/watch?v=prkjQ1bFcE0&feature=emb_logo

2. To hide tooltips replace


<script>
    var c = document.getElementById("barChart");
    var ctx = c.getContext("2d");
    var tData = $.getValues("/Home/BarChartData");
    var myBarChart = new Chart(ctx, {
        type: 'bar',
        data: tData,
        options: {
            tooltips: {
                enabled: false,
            }
        }
    });
</script>

with

<script>
    var c = document.getElementById("barChart");
    var ctx = c.getContext("2d");
    var tData = $.getValues("/Home/BarChartData");
    var myBarChart = new Chart(ctx, {
        type: 'bar',
        data: tData,
        options: {
            tooltips: {
                enabled: false,
            }
        }

    });
</script>

No comments:

Post a Comment