-
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
Introduce formatter -options for tooltips and tick labels #6037
Conversation
@@ -217,8 +217,8 @@ function createTooltipItem(element) { | |||
return { | |||
xLabel: xScale ? xScale.getLabelForIndex(index, datasetIndex) : '', | |||
yLabel: yScale ? yScale.getLabelForIndex(index, datasetIndex) : '', | |||
label: indexScale ? indexScale.getLabelForIndex(index, datasetIndex) : '', | |||
value: valueScale ? valueScale.getLabelForIndex(index, datasetIndex) : '', | |||
label: indexScale ? indexScale._formatTooltip(index, datasetIndex) : '', |
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.
Not sure about a private function here
/** | ||
* @private | ||
*/ | ||
_configure: function() { |
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 think this is an interesting concept for supporting these options
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.
Only things that should need an update
to change can be resolved here though.
Docs would have to be added as well |
I'm wondering what the tick is when it's passed to the user-supplied formatter function. Is it a |
64795ee
to
c832c17
Compare
how hard can it be to rebase 😄 changescore.scale:
scale.time:
|
- alias globalDefaults globally - pass tick object to formatter time scale: - pass tick object to tickFormatFunction - use already figured `tick.major` in tickFormatFunction - use _formatTick in tickFormatFunction
test/specs/core.scale.tests.js
Outdated
@@ -73,6 +73,22 @@ describe('Core.scale', function() { | |||
|
|||
expect(lastTick(chart).label).toBeUndefined(); | |||
}); | |||
|
|||
it('should display multiline-labels correctly', function() { |
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.
nit: "multiline labels" or "multi-line labels" would both be fine. current hyphen location is unexpected
test/specs/core.scale.tests.js
Outdated
}); | ||
|
||
expect(lastTick(chart).label).toEqual(['September', '2018']); | ||
|
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.
nit: I'd probably remove this blank line
This looks pretty good to me. I'm wondering if there are any other tests we need? Maybe one for the new |
var labels = []; | ||
var i, ilen, tick; | ||
|
||
if (helpers.isArray(ticks) && ticks.length) { |
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.
It might be nicer to make whether the ticks are being passed in and whether it's the new format be independent. Can we check if the tick is an object instead?
@benmccann just want to know why have you referenced #2442 at the bottom here. Any reasons ?? |
Ah, I guess this only handles textual formatting and not styling |
Couple of things going on here:
callback
instead of legacyuserCallback
_configure
step to scale for resolving optionsformatter
options in_configure
_formatTick
and_formatTooltip
method namesvalue
/label
inTooltipItem
Todo if merging is plausible:
formatter
'sFor testing: CodePen