Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

kurkle
Copy link
Member

@kurkle kurkle commented Feb 22, 2020

Contains some auxiliary changes:

  • borderSkipped support for 'start' / 'end'
  • dataset default scales definable by i and v (i = base/index axis, v = value axis)
  • radial charts don't require scale to be r (use _cachedMeta.rScale)
  • _getIndexScaleId, _getIndexScale, _getValueScaleId, _getValueScale helpers removed

@benmccann
Copy link
Contributor

You'll have to add a note to the migration guide. Also, lots of failing tests

@kurkle kurkle marked this pull request as ready for review February 22, 2020 17:56
@kurkle kurkle added this to the Version 3.0 milestone Feb 22, 2020
@@ -22,14 +23,14 @@ defaults.set('bar', {
},

scales: {
x: {
i: {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Contributor

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)

Copy link
Member Author

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.

src/core/core.controller.js Outdated Show resolved Hide resolved
@kurkle kurkle changed the title Replace horizontalBar with baseAxis: 'y' Replace horizontalBar with indexAxis: 'y' Feb 23, 2020
@@ -22,14 +22,14 @@ defaults.set('bar', {
},

scales: {
x: {
_index_: {
Copy link
Contributor

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"

Copy link
Member Author

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]]);
Copy link
Contributor

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

Copy link
Member Author

@kurkle kurkle Feb 23, 2020

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

@benmccann benmccann Feb 29, 2020

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&#124;object</code> | Yes | Yes | `0`
| [`clip`](#general) | <code>number&#124;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.
Copy link
Contributor

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]]);
Copy link
Contributor

@benmccann benmccann Feb 29, 2020

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?

@kurkle
Copy link
Member Author

kurkle commented Feb 29, 2020

right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants