Hide min and max values from y Axis in Chart.js

前端 未结 3 2091
伪装坚强ぢ
伪装坚强ぢ 2021-02-08 22:37

I have assigned the min and max of Y axes with the tick configuration.But I do not want these min max values to be shown in the graph.I need to hide these values at both the end

3条回答
  •  忘了有多久
    2021-02-08 22:57

    When using the plugin chartjs-plugin-zoom I only wanted to remove those ticks if they had decimals, as it created a flickering effect when panning.

    Implementation:

    afterTickToLabelConversion: (scaleInstance) => {
        if (scaleInstance.ticks[0].indexOf(".") > -1) {
            scaleInstance.ticks[0] = null;
            scaleInstance.ticksAsNumbers[0] = null;
        }
        if (scaleInstance.ticks[scaleInstance.ticks.length - 1].indexOf(".") > -1) {
            scaleInstance.ticks[scaleInstance.ticks.length - 1] = null;
            scaleInstance.ticksAsNumbers[scaleInstance.ticksAsNumbers.length - 1] = null;
        }
    }
    

提交回复
热议问题