compwright / chartjs-plugin-draggable

Draggable element plugin for Chart.js
MIT License
44 stars 17 forks source link

Dragging annotations invalidates custom ticks callback #11

Open scharnyw opened 5 years ago

scharnyw commented 5 years ago

Hi,

The chart refresh that occurs when dragging line annotations does not honor the custom ticks callback that user provides in chart options, i.e.

options = {
    scales: {
      xAxes: [{
        display: true,
        type: "linear",
        ticks: {
          callback: (tick, index, ticks) => {
              // custom ticks formatter
          }
    }
}

Instead the default callback is always used. One solution is to override the default callback but this is hardly the optimal solution especially when I'd want different types of ticks on multiple plots:

Chart.scaleService.updateScaleDefaults('logarithmic', {
    ticks: {
        callback: function(tick, index, ticks) {
            // new default callback
        }
    }
});

Any idea why the custom cb is skipped in this case?