-
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
Replace horizontalBar with indexAxis: 'y' #7144
Conversation
You'll have to add a note to the migration guide. Also, lots of failing tests |
src/controllers/controller.bar.js
Outdated
@@ -22,14 +23,14 @@ defaults.set('bar', { | |||
}, | |||
|
|||
scales: { | |||
x: { | |||
i: { |
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.
How do we detect the positions now?
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
is replaced with the baseAxis
and v
with the other one. maybe more verbose names here would be good.
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.
Maybe use index
and value
? (sort of makes me wonder if it should be indexAxis
instead of baseAxis
)
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.
Changed to _index_
, _value_
and indexAxis
.
Now also reads the indexAxis
from chart options directly.
Can have different indexAxis
per dataset, but that would be uncommon use case.
@@ -22,14 +22,14 @@ defaults.set('bar', { | |||
}, | |||
|
|||
scales: { | |||
x: { | |||
_index_: { |
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.
Why the underscore before and after? I'm assuming you want them to be private, but what's the reason for that? We haven't done this with any other options, so I would probably lean towards just "index"
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.
Because index
is not the actual value its going to end up with. Also to try to not collide with user specified values.
configScales[id], | ||
defaultScaleOptions[defaultID] | ||
]); | ||
helpers.mergeIf(scales[id], [{axis}, configScales[id], defaultScaleOptions[defaultID]]); |
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 it might be a bit confusing that there's two ways to do things now. I wonder if we should also replace x
and y
configs in the other chart types by index
and value
. E.g. if you wanted to set indexAxis
on a bubble
or line
dataset it wouldn't necessarily just work right now because we only updated the defaults for the BarController
. I think it'd be clearer how things worked if we did that universally. And in that case we probably wouldn't want the underscores because I think they're options that users would be setting more frequently
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.
Those controllers use same defaults for both axes, so makes no difference. Its also likely that some (external) chart types want to use some defaults for x and others for y regardless of the indexAxis.
I think you misunderstand how this works. Users are not supposed to use _index_
and _value_
in their configuration. They use 'x' and 'y' (or whatever they like) and the defaults from the _index_
placeholder are applied to the scale that is on the axis marked as indexAxis
. And the _value_
defaults are applied to the other scale.
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 was thinking it might be nice if they could use index
though. Imagine if you wanted to build a chart builder like the dialog to insert a chart in Excel or Google Spreadsheets. You could just toggle back and forth between horizontal and vertical by changing only a single property. Otherwise you need to move all the properties between x
and y
. I think it'd be fairly messy without using _index_
and _value_
to make a bar chart that can toggle between horizontal and vertical
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 see. So we'd require the scales to be defined as index
and value
. What if the user needs multiple value scales?
Add iScaleID
and vScaleID
? then the user would be free to name the scales again, but we still need to match the defaults for correct scales.
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.
Yeah, you've raised some good points. Maybe we should just leave it the way it is.
Though I do still wonder if we should use _index_
and _value_
in the other controllers. You said the other controllers use the same defaults for both axes, but I'm not sure that's true. The line
controller has a line
y-axis and category
x-axis, right? Maybe it should be line
for _value_
and category
for _index_
instead?
| [`borderWidth`](#borderwidth) | <code>number|object</code> | Yes | Yes | `0` | ||
| [`clip`](#general) | <code>number|object</code> | - | - | `undefined` | ||
| [`data`](#data-structure) | `object[]` | - | - | **required** | ||
| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | - | Yes | `undefined` | ||
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | - | Yes | `undefined` | ||
| [`hoverBorderWidth`](#interactions) | `number` | - | Yes | `1` | ||
| [`indexAxis`](#general) | `string` | `'x'` | The base axis for the dataset. Use `'y'` for horizontal bar. |
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 realized this might be a little confusing in the case that you have multiple axes because it kind of sounds like it's asking for an axis ID. Perhaps it should just be a boolean
called horizontal
?
configScales[id], | ||
defaultScaleOptions[defaultID] | ||
]); | ||
helpers.mergeIf(scales[id], [{axis}, configScales[id], defaultScaleOptions[defaultID]]); |
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.
Yeah, you've raised some good points. Maybe we should just leave it the way it is.
Though I do still wonder if we should use _index_
and _value_
in the other controllers. You said the other controllers use the same defaults for both axes, but I'm not sure that's true. The line
controller has a line
y-axis and category
x-axis, right? Maybe it should be line
for _value_
and category
for _index_
instead?
right |
Contains some auxiliary changes:
borderSkipped
support for'start'
/'end'
i
andv
(i = base/index axis, v = value axis)r
(use_cachedMeta.rScale
)_getIndexScaleId
,_getIndexScale
,_getValueScaleId
,_getValueScale
helpers removed