]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Update default tooltip configs for scatter charts. Made scatter charts a first class...
authorEvert Timberg <evert.timberg@gmail.com>
Fri, 20 Nov 2015 02:15:59 +0000 (21:15 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Fri, 20 Nov 2015 02:15:59 +0000 (21:15 -0500)
src/charts/Chart.Scatter.js

index ee1ec474a368446aa641883eb4381658cc0ae29e..124cbad7794d629aa73a0bcf6776b750064ed38f 100644 (file)
                },
 
                tooltips: {
-                       template: "(<%= value.x %>, <%= value.y %>)",
-                       multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%>(<%= value.x %>, <%= value.y %>)",
+                       callbacks: {
+                               title: function(tooltipItems, data) {
+                                       // Title doesn't make sense for scatter since we format the data as a point
+                                       return '';
+                               },
+                               label: function(tooltipItem, data) {
+                                       return '(' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ')';
+                               }
+                       }
                },
-
        };
 
+       // Register the default config for this type
+       Chart.defaults.scatter = defaultConfig;
+
+       // Scatter charts use line controllers
+       Chart.controllers.scatter = Chart.controllers.line;
+
        Chart.Scatter = function(context, config) {
-               config.options = helpers.configMerge(defaultConfig, config.options);
-               config.type = 'line';
+               //config.options = helpers.configMerge(defaultConfig, config.options);
+               config.type = 'scatter';
                return new Chart(context, config);
        };