chart.js - Remove space for unrequired ticks -


i'm trying generate chart has year & week numbers (201601, 201602 ... 201651, 201652) across x-axis. i've managed trim out unwanted ticks, chartjs not trimming out dead space. here's example:

enter image description here

here's code have tried far... don't worry white bar on blue bar, i'm happy artefact now, i'm trying trim out dead space. ignore fact data empty, being loaded in dynamically via ajax call:

chart = new chart(canvas, {     type: 'horizontalbar',     data: {         labels: [],         datasets: []     },     options: {         legend: { display: false },         scales: {             xaxes: [{                 ticks: {                     autoskip: true,                     beginatzero: false,                     stepsize: 1                 },                 position: 'top',                 type: "linear",                 afterbuildticks: function (scale) {                     var tickslength = scale.ticks.length;                      var newticks = [];                      (var index = 0; index < tickslength; index++) {                         if ((scale.ticks[index] % 100 >= 1) && (scale.ticks[index] % 100 <= 52)) {                             newticks.push(scale.ticks[index]);                         }                     }                      scale.ticks = newticks;                 }             }],             yaxes: [{                 stacked: true             }]         },         tooltips: { enabled: true }     } }); 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -