]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove smallestLabelSeparation from TimeScale (#3186)
authorTomasz Moń <desowin@gmail.com>
Mon, 22 Aug 2016 18:50:48 +0000 (21:50 +0300)
committerEvert Timberg <evert.timberg+github@gmail.com>
Mon, 22 Aug 2016 18:50:48 +0000 (14:50 -0400)
In case of charts with over 4000 points, smallestLabelSeparation
calculation contributes significantly to total cpu usage (about 25% according
to built-in Chrome profiler). Important thing to note is that result
of this calculation is not used at all.

Related commits:
  * 677c249b613bf1a4ebccb1bebda9f04f7346b866
    introduced smallestLabelSeparation. It was used in calculateBaseWidth
    function.
  * d198157fb8ea479ec9286bcf0ffb72e2e62e9661
    removed last use of smallestLabelSeparation. Since then the calculated
    value was never used.

src/scales/scale.time.js

index 4e668cb67f2cdbf85427761ad1257c0929d9c169..11585bcab2aca75e0d8127dca9e2eeda35fce11f 100755 (executable)
@@ -255,14 +255,6 @@ module.exports = function(Chart) {
                                me.scaleSizeInUnits = me.lastTick.diff(me.firstTick, me.tickUnit, true);
                        }
 
-                       me.smallestLabelSeparation = me.width;
-
-                       helpers.each(me.chart.data.datasets, function(dataset, datasetIndex) {
-                               for (var i = 1; i < me.labelMoments[datasetIndex].length; i++) {
-                                       me.smallestLabelSeparation = Math.min(me.smallestLabelSeparation, me.labelMoments[datasetIndex][i].diff(me.labelMoments[datasetIndex][i - 1], me.tickUnit, true));
-                               }
-                       }, me);
-
                        // Tick displayFormat override
                        if (me.options.time.displayFormat) {
                                me.displayFormat = me.options.time.displayFormat;