]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix tooltip in financial sample (#7638)
authorBen McCann <322311+benmccann@users.noreply.github.com>
Fri, 17 Jul 2020 13:19:20 +0000 (06:19 -0700)
committerGitHub <noreply@github.com>
Fri, 17 Jul 2020 13:19:20 +0000 (09:19 -0400)
samples/scales/financial.html

index 922ced60cee331ecd58da2c1ec7f7c719530d6e1..425f1657f47171da3d1deb4f0a30f1b1ee122cf6 100644 (file)
@@ -39,7 +39,7 @@
        </select>
        <button id="update">update</button>
        <script>
-               // Generate data between the stock market hours of 9:30am - 5pm.
+               // Generate data between the stock market hours of 9:30am - 4pm.
                // This method is slow and unoptimized, but in real life we'd be fetching it from the server.
                function generateData() {
                        const unit = document.getElementById('unit').value;
@@ -54,7 +54,7 @@
 
 
                        function after4pm(date) {
-                               return date.hour > 16 || (date.hour === 16 && date.minute > 0);
+                               return date.hour >= 16;
                        }
 
                        // Returns true if outside 9:30am-4pm on a weekday
                                                        if (label) {
                                                                label += ': ';
                                                        }
-                                                       label += parseFloat(context.value).toFixed(2);
+                                                       label += context.dataPoint.y.toFixed(2);
                                                        return label;
                                                }
                                        }