-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Float-bar support. The logic is to use array values [bottomY, topY] i… #5262
Changes from all commits
a31d179
ceafcaf
f2e7310
d07f183
4ae0988
5b5bd25
88aa1a5
fc478a6
6075e6f
85ea4da
b4c2994
87e6e38
0e55557
0dd7666
8e44c5e
70a11e5
362d5f9
12525ce
4a366a2
69b8ab0
256729c
42add1c
0aad0c8
e414eb7
2161fc3
84e89aa
8bfa7e1
b12e2fe
786c5c4
861ed13
df32e68
10c3831
614275d
cf6fd4b
d5ef434
a75e3ac
aaaac73
5e877aa
823160e
11bb986
1c526e3
a59a602
a4efcf0
25ff4ea
7e75bef
03b8167
659235b
fe0772c
730e468
122167c
3e42297
9b95637
2af134b
a0e1231
a65aa3c
901c96f
7a42562
4f5332e
63ce9e9
b626b57
b25db90
8f06bc5
2a07aaa
d165e24
c4148e9
a48b8ce
e1095fa
14bccfe
f4d7413
5590350
9f88e05
76e9ceb
f957e64
2d06063
a786cd1
74dc634
dba5bdb
0e58967
124688c
84dae3d
19a400c
87b0d91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -522,6 +522,12 @@ module.exports = Element.extend({ | |
if ((typeof rawValue === 'number' || rawValue instanceof Number) && !isFinite(rawValue)) { | ||
return NaN; | ||
} | ||
|
||
// Float-bar support. Handling arrays | ||
if (helpers.isArray(rawValue)) { | ||
return [this.getRightValue(rawValue[0]), this.getRightValue(rawValue[1])]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also allows data like |
||
} | ||
|
||
// If it is in fact an object, dive in one more level | ||
if (rawValue) { | ||
if (this.isHorizontal()) { | ||
|
@@ -537,6 +543,38 @@ module.exports = Element.extend({ | |
return rawValue; | ||
}, | ||
|
||
_parseValue: function(raw) { | ||
var value = +this.getRightValue(raw); | ||
var start, end, isarr; | ||
|
||
if (helpers.isArray(value)) { | ||
start = value[0]; | ||
end = value[1]; | ||
isarr = true; | ||
} else { | ||
start = 0; | ||
end = value; | ||
isarr = false; | ||
} | ||
|
||
return { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would consider calculating |
||
min: Math.min(start, end), | ||
max: Math.max(start, end), | ||
start: start, | ||
end: end, | ||
isarr: isarr | ||
}; | ||
}, | ||
|
||
getScaleLabel: function(rawValue) { | ||
var v = this._parseValue(rawValue); | ||
if (v.issar === true) { | ||
return v.min === v.max ? v.min : v.min + ' ; ' + v.max; | ||
} | ||
|
||
return +this.getRightValue(rawValue); | ||
}, | ||
|
||
/** | ||
* Used to get the value to display in the tooltip for the data at the given index | ||
* @param index | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,11 +124,11 @@ var supportsEventListenerOptions = (function() { | |
// https://github.com/chartjs/Chart.js/issues/4287 | ||
var eventListenerOptions = supportsEventListenerOptions ? {passive: true} : false; | ||
|
||
function addEventListener(node, type, listener) { | ||
function addListener(node, type, listener) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why cbb7ff7 is showing up on this PR. Seems the rebase didn't totally work There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when i has all that failing tests i thought that smth really bad went with merge last time. So, i downloaded lates Chart.js files, replaced with it all my local files and commited to my fork. So, in this case my repo should look like the current Chart.js version. So, all that changes came when i replaced files. I have put back my changes again on float-bat support after. Are thise chanages on this file are not correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have replaced all files from current chart.js version. Is this file is not correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think because this was commited only 2 days ago thats why i picked it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes shouldn't appear on your PR. The problem is that your PR is comparing to a version of the code from a few days ago probably instead of to the latest master. You should run It's probably really hard to rebase with 82 commits spanning a year on the PR. It's possible you might have an easier time opening a new PR at this point rather than rebasing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gwyneblaidd if you need help squashing / rebasing this PR, please join our Slack #dev channel. But please don't open a new PR with these 82 commits, it will be useless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forget my comment about squashing commits, I didn't realize you already merged many times our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rebased PR - #6056 |
||
node.addEventListener(type, listener, eventListenerOptions); | ||
} | ||
|
||
function removeEventListener(node, type, listener) { | ||
function removeListener(node, type, listener) { | ||
node.removeEventListener(type, listener, eventListenerOptions); | ||
} | ||
|
||
|
@@ -223,8 +223,8 @@ function createResizer(handler) { | |
handler(); | ||
}; | ||
|
||
addEventListener(expand, 'scroll', onScroll.bind(expand, 'expand')); | ||
addEventListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink')); | ||
addListener(expand, 'scroll', onScroll.bind(expand, 'expand')); | ||
addListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink')); | ||
|
||
return resizer; | ||
} | ||
|
@@ -239,7 +239,7 @@ function watchForRender(node, handler) { | |
}; | ||
|
||
helpers.each(ANIMATION_START_EVENTS, function(type) { | ||
addEventListener(node, type, proxy); | ||
addListener(node, type, proxy); | ||
}); | ||
|
||
// #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR class | ||
|
@@ -258,7 +258,7 @@ function unwatchForRender(node) { | |
|
||
if (proxy) { | ||
helpers.each(ANIMATION_START_EVENTS, function(type) { | ||
removeEventListener(node, type, proxy); | ||
removeListener(node, type, proxy); | ||
}); | ||
|
||
delete expando.renderProxy; | ||
|
@@ -429,7 +429,7 @@ module.exports = { | |
listener(fromNativeEvent(event, chart)); | ||
}; | ||
|
||
addEventListener(canvas, type, proxy); | ||
addListener(canvas, type, proxy); | ||
}, | ||
|
||
removeEventListener: function(chart, type, listener) { | ||
|
@@ -447,7 +447,7 @@ module.exports = { | |
return; | ||
} | ||
|
||
removeEventListener(canvas, type, proxy); | ||
removeListener(canvas, type, proxy); | ||
} | ||
}; | ||
|
||
|
@@ -462,7 +462,7 @@ module.exports = { | |
* @todo remove at version 3 | ||
* @private | ||
*/ | ||
helpers.addEvent = addEventListener; | ||
helpers.addEvent = addListener; | ||
|
||
/** | ||
* Provided for backward compatibility, use EventTarget.removeEventListener instead. | ||
|
@@ -473,4 +473,4 @@ helpers.addEvent = addEventListener; | |
* @todo remove at version 3 | ||
* @private | ||
*/ | ||
helpers.removeEvent = removeEventListener; | ||
helpers.removeEvent = removeListener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this to something like
For floating bar char you can use array of [start, end] for a point, where both start and end are values accepted by the scale used