JavaScript ChartJS hide labels on small screen sizes chartjs hide labels on x axis,chartjs hide labels,chart

I have a problem hiding xAxes and yAxes labels on small screen sizes (mobile phones). I know there is this option:

options:
        {
            scales:
            {
                xAxes: [{
                    ticks:{
                        display: false
                    }

                }];
            }
        }

But if i use it in the onResize function like this

var ctx = document.getElementById("chart");

var myChart = new Chart(ctx, {
    //chart data and options,

   onResize: function(myChart, size) {

   if (size.height < 140) {
        options:
        {
            scales:
            {
                xAxes: [{
                    ticks:{
                        display: false
                    }

                }];
            }
        }
     }
});

But it does not work on resize. Is hiding labels onResize even the right solution? I am testing on with Chrome responsive mode and on resize works, but would it if accessed from mobile phones?

Can somebody please help me with this problem and point me int the right direction?

Thanks, Gregor

Answer:1

Have a try with

var myChart = new Chart(ctx, {
    //chart data and options,

   onResize: function(myChart, size) {

     var showTicks = (size.height < 140) ? false : true;

     myChart.options = {
            scales: {
                xAxes: [{
                    ticks: {
                        display: showTicks
                    }
                }];
            }
     };

  }
});
Answer:2

I encountered a challenge when trying to activate autoload on scrolling to the bottom. The problem is that the jQuery doesn't work when I scroll to the bottom but when I scroll back to the top, it ...

I encountered a challenge when trying to activate autoload on scrolling to the bottom. The problem is that the jQuery doesn't work when I scroll to the bottom but when I scroll back to the top, it ...

  1. windows scroll not working
  2. windows scroll doesn't work
  3. scroll doesn't work windows
  4. windows scroll wheel not working
  5. windows scroll bar not working
  6. windows scroll pad not working
  7. windows scroll feature not working
  8. windows touchpad scroll not working
  9. windows 10 scroll not working
  10. windows mouse scroll not working
  11. windows 10 scroll not working touchpad
  12. windows trackpad scroll not working
  13. windows 7 scroll not working
  14. windows 10 scroll stopped working
  15. windows update scroll not working
  16. windows 8 scroll not working
  17. windows 10 scroll not working in settings
  18. windows horizontal scroll not working
  19. windows scroll inactive window not working
  20. windows page scroll not working

i am pretty new to javascript and doing a course to gain some experience but i am breaking my head on the return concept sometimes. Basically this is the task i am stuck at: There is an array of ...

i am pretty new to javascript and doing a course to gain some experience but i am breaking my head on the return concept sometimes. Basically this is the task i am stuck at: There is an array of ...

I have created a objects in .less, and i have created a few buttons in a php file, when the button is clicked in the php file I want some of the objects to hide. Here is my php code <label for="...

I have created a objects in .less, and i have created a few buttons in a php file, when the button is clicked in the php file I want some of the objects to hide. Here is my php code <label for="...

  1. function hides a non virtual function
  2. function hides a non-virtual function from class
  3. function hide password in c
  4. function hide javascript
  5. function hide show javascript
  6. function hide div
  7. function hide show jquery
  8. function hide and show
  9. function hide js
  10. function hideurlbar
  11. function hide div javascript
  12. function hide excel
  13. function hide row excel
  14. function hideurlbar() window.scrollto(0 1)
  15. function hide php
  16. function hide modal
  17. function hides inherited member
  18. function hide button
  19. function hide c++
  20. function hide html

I have response object i just assigned to "this" object. private data: Object = {}; this.http.post('url', { }) .subscribe( res => { console.log(res); this.data ...

I have response object i just assigned to "this" object. private data: Object = {}; this.http.post('url', { }) .subscribe( res => { console.log(res); this.data ...

  1. that does access mean