-
Notifications
You must be signed in to change notification settings - Fork 12k
Add onLeave callback to legend #6059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9ba01cf
Add onLeave callback to legend
jonrimmer 336d4b2
Fix field privacy and eixstence check
jonrimmer 0d442a7
Remove comment
jonrimmer 95b9c61
Fix comment indentation
jonrimmer 6ee892a
Fix sample title and path
jonrimmer 6234480
Refactor handleEvent
jonrimmer e64be0b
Fix types and return value
jonrimmer 29623eb
Review fixes
jonrimmer 61a9eb8
Fix indent
jonrimmer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <title>Legend Callbacks</title> | ||
| <script src="../../dist/Chart.min.js"></script> | ||
| <script src="../utils.js"></script> | ||
| <style> | ||
| body, html { | ||
| height: 100%; | ||
| font-family: sans-serif; | ||
| } | ||
| canvas{ | ||
| -moz-user-select: none; | ||
| -webkit-user-select: none; | ||
| -ms-user-select: none; | ||
| } | ||
|
|
||
| #log { | ||
| position: absolute; | ||
| right: 0; | ||
| top: 0; | ||
| bottom: 0; | ||
| background-color: #EEE; | ||
| float: right; | ||
| width: 20%; | ||
| padding: 8px; | ||
| overflow-y: auto; | ||
| white-space: pre; | ||
| line-height: 1.5em; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="log"></div> | ||
| <div style="width:75%;"> | ||
| <canvas id="canvas"></canvas> | ||
| </div> | ||
| <script> | ||
| var logEntry = 1; | ||
| var logElement = document.getElementById('log'); | ||
| var utils = Samples.utils; | ||
| var inputs = { | ||
| min: 20, | ||
| max: 80, | ||
| count: 8, | ||
| decimals: 2, | ||
| continuity: 1 | ||
| }; | ||
| var config; | ||
|
|
||
| function log(text) { | ||
| logElement.innerText += logEntry + '. ' + text + '\n'; | ||
| logElement.scrollTop = logElement.scrollHeight; | ||
| logEntry++; | ||
| } | ||
|
|
||
| function generateData() { | ||
| return utils.numbers(inputs); | ||
| } | ||
| function generateLabels() { | ||
| return utils.months({count: inputs.count}); | ||
| } | ||
|
|
||
| utils.srand(42); | ||
|
|
||
| config = { | ||
| type: 'line', | ||
| data: { | ||
| labels: generateLabels(), | ||
| datasets: [{ | ||
| label: 'My First dataset', | ||
| backgroundColor: utils.color(0), | ||
| borderColor: utils.color(0), | ||
| data: generateData(), | ||
| fill: false, | ||
| }, { | ||
| label: 'My Second dataset', | ||
| fill: false, | ||
| backgroundColor: utils.color(1), | ||
| borderColor: utils.color(1), | ||
| data: generateData(), | ||
| }] | ||
| }, | ||
| options: { | ||
| legend: { | ||
| onHover: function(event, legendItem) { | ||
| log('onHover: ' + legendItem.text); | ||
| }, | ||
| onLeave: function(event, legendItem) { | ||
| log('onLeave: ' + legendItem.text); | ||
| }, | ||
| onClick: function(event, legendItem) { | ||
| log('onClick:' + legendItem.text); | ||
| } | ||
| }, | ||
| title: { | ||
| display: true, | ||
| text: 'Chart.js Line Chart' | ||
| }, | ||
| scales: { | ||
| xAxes: [{ | ||
| display: true, | ||
| scaleLabel: { | ||
| display: true, | ||
| labelString: 'Month' | ||
| } | ||
| }], | ||
| yAxes: [{ | ||
| display: true, | ||
| scaleLabel: { | ||
| display: true, | ||
| labelString: 'Value' | ||
| } | ||
| }] | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| new Chart(document.getElementById('canvas'), config); | ||
| </script> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.