Chart.Scatter.js 966 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. module.exports = function(Chart) {
  3. var defaultConfig = {
  4. hover: {
  5. mode: 'single'
  6. },
  7. scales: {
  8. xAxes: [{
  9. type: 'linear', // scatter should not use a category axis
  10. position: 'bottom',
  11. id: 'x-axis-1' // need an ID so datasets can reference the scale
  12. }],
  13. yAxes: [{
  14. type: 'linear',
  15. position: 'left',
  16. id: 'y-axis-1'
  17. }]
  18. },
  19. tooltips: {
  20. callbacks: {
  21. title: function() {
  22. // Title doesn't make sense for scatter since we format the data as a point
  23. return '';
  24. },
  25. label: function(tooltipItem) {
  26. return '(' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ')';
  27. }
  28. }
  29. }
  30. };
  31. // Register the default config for this type
  32. Chart.defaults.scatter = defaultConfig;
  33. // Scatter charts use line controllers
  34. Chart.controllers.scatter = Chart.controllers.line;
  35. Chart.Scatter = function(context, config) {
  36. config.type = 'scatter';
  37. return new Chart(context, config);
  38. };
  39. };