WIP Scale options as an object instead of an array#6626
WIP Scale options as an object instead of an array#6626etimberg wants to merge 9 commits intochartjs:masterfrom
Conversation
* Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs
|
I like it. How about allowing |
|
Yup, One other downside I realized is that if one creates new axes |
|
What's the primary goal here? I'll probably have some thoughts, but want to make sure I'm not going in a different direction |
|
I think the |
|
@benmccann the goal here was to try and simplify the axis option code by changing the format of the config object. |
benmccann
left a comment
There was a problem hiding this comment.
I like it
One thing I was thinking is that we should probably have a migration guide that we update each time we make a breaking change. I think it will be easier to do as we go than to have to go back and do it all at the end. And easier for the person originally making the change than for one person to have to do it all
| id: 'firstYScaleID' | ||
| }] | ||
| } | ||
| } |
There was a problem hiding this comment.
I think we need to figure out how to default to first configured axis instead of x/y
There was a problem hiding this comment.
Agreed. I think the thing that may sink this attempt is taht one cannot remove the x and y axis IDs because of how we merge the config.
There was a problem hiding this comment.
I think we can map defaults.x to firstX and defaults.y to firstY in merge, but might have to rewrite the merge totally.
| if (meta.yAxisID === null || !(meta.yAxisID in scales) || dataset.yAxisID) { | ||
| meta.yAxisID = dataset.yAxisID || scalesOpts.yAxes[0].id; | ||
| meta.yAxisID = dataset.yAxisID || scalesOpts.y.id; | ||
| } |
There was a problem hiding this comment.
We could do something like:
var firstX = Object.keys(scales).filter(key => scales[key].position === 'top' || scales[key].position === 'bottom').shift();
var firstY = Object.keys(scales).filter(key => scales[key].position === 'left' || scales[key].position === 'right').shift();
if (meta.xAxisID === null || !(meta.xAxisID in scales) || dataset.xAxisID) {
meta.xAxisID = dataset.xAxisID || firstX;
}
if (meta.yAxisID === null || !(meta.yAxisID in scales) || dataset.yAxisID) {
meta.yAxisID = dataset.yAxisID || firstY;
}There was a problem hiding this comment.
Good idea, let me see how that goes
|
@etimberg this one will need to be rebased |
|
Merged in #6773 |
I want to get some feedback on this before I go any further.
This PR changes the axis options format to one that is easier to work with. The challenges are that we can't do as many default actions for X vs Y axes. I kept some basic functionality by assuming that axes that have an ID starting with "x" are horizontal.
to
To Do