forked from chartjs/Chart.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
Chart.defaults/Ticks/Interaction
importable (chartjs#4512)
Default options can now be accessed by importing `core/core.defaults`. The returned object acts as a singleton and is populated when importing classes that expose their own default values (meaning that importing only `code.defaults` results in an empty object). Also make `Chart.Ticks` and `Chart.Interaction` importable since existing defaults rely on these values. Add the `defaults._set` method that make easier declaring new defaults by merging given values with existing ones for a specific scope (`global`, `scale`, `bar`, etc).
- Loading branch information
1 parent
56a63f4
commit b17c452
Showing
32 changed files
with
1,126 additions
and
1,069 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,8 @@ | ||
'use strict'; | ||
|
||
module.exports = function(Chart) { | ||
|
||
var defaultConfig = { | ||
hover: { | ||
mode: 'single' | ||
}, | ||
|
||
scales: { | ||
xAxes: [{ | ||
type: 'linear', // scatter should not use a category axis | ||
position: 'bottom', | ||
id: 'x-axis-1' // need an ID so datasets can reference the scale | ||
}], | ||
yAxes: [{ | ||
type: 'linear', | ||
position: 'left', | ||
id: 'y-axis-1' | ||
}] | ||
}, | ||
showLines: false, | ||
|
||
tooltips: { | ||
callbacks: { | ||
title: function() { | ||
// Title doesn't make sense for scatter since we format the data as a point | ||
return ''; | ||
}, | ||
label: function(tooltipItem) { | ||
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.type = 'scatter'; | ||
return new Chart(context, config); | ||
}; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.