]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Clean up a few sample issues (#8790)
authorEvert Timberg <evert.timberg+github@gmail.com>
Fri, 2 Apr 2021 21:25:14 +0000 (17:25 -0400)
committerGitHub <noreply@github.com>
Fri, 2 Apr 2021 21:25:14 +0000 (17:25 -0400)
docs/charts/bar.md
docs/samples/tooltip/interactions.md
docs/samples/tooltip/position.md

index c9806ac70ae4f1714e2d57aeec2422e8375f9a19..d71b553decabb092cfbbe92b01f428b5c587cb58 100644 (file)
@@ -237,7 +237,7 @@ It is common to want to apply a configuration setting to all created bar charts.
 
 The following shows the relationship between the bar percentage option and the category percentage option.
 
-```text
+```
 // categoryPercentage: 1.0
 // barPercentage: 1.0
 Bar:        | 1.0 | 1.0 |
index 0b1a995bc40af1296d136e4f238fceac9953aeee..2ee3deca89135fd12f50428f3b854aac6810f3ea 100644 (file)
@@ -8,6 +8,7 @@ const actions = [
   {
     name: 'Mode: index',
     handler(chart) {
+      chart.options.interaction.axis = 'xy';
       chart.options.interaction.mode = 'index';
       chart.update();
     }
@@ -15,6 +16,7 @@ const actions = [
   {
     name: 'Mode: dataset',
     handler(chart) {
+      chart.options.interaction.axis = 'xy';
       chart.options.interaction.mode = 'dataset';
       chart.update();
     }
@@ -22,6 +24,7 @@ const actions = [
   {
     name: 'Mode: point',
     handler(chart) {
+      chart.options.interaction.axis = 'xy';
       chart.options.interaction.mode = 'point';
       chart.update();
     }
@@ -29,6 +32,7 @@ const actions = [
   {
     name: 'Mode: nearest',
     handler(chart) {
+      chart.options.interaction.axis = 'xy';
       chart.options.interaction.mode = 'nearest';
       chart.update();
     }
index e5e1d5fa3ca2609eb0466d1e09cfd60baca5776f..fba8eaa3615a6d02987d7f659ad9e20bd54241cc 100644 (file)
@@ -57,6 +57,12 @@ const data = {
 // Create a custom tooltip positioner to put at the bottom of the chart area
 components.Tooltip.positioners.bottom = function(items) {
   const pos = components.Tooltip.positioners.average(items);
+
+  // Happens when nothing is found
+  if (pos === false) {
+    return false;
+  }
+
   const chart = this._chart;
 
   return {