Skip to content

Conversation

@kurkle
Copy link
Member

@kurkle kurkle commented Nov 20, 2019

Another step further from #6770, completely rewritten scale option resolution.

  • Take the options.scales
  • If options.scale is specified, consider that too (for now, I got tired of changing tests)
  • Take note of first scale per axis
  • Apply each datasets defaults to their scales, using axis (x/y/r) instead of scale.id
  • Apply scale defaults

I had to add offset: false to bunch of bar tests, those dataset defaults were not applied before if not using default scales.

etimberg and others added 4 commits November 19, 2019 09:21
* 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
@benmccann
Copy link
Contributor

benmccann commented Nov 20, 2019

If options.scale is specified, consider that too (for now, I got tired of changing tests)

That sounds fine to me. I don't think we need to update them all this PR. Just FYI, I fixed about half the fixtures doing a command-line search and replace with grep -rl Axes test/fixtures | xargs sed -r -i 's/Axes: \[(.*?)\]/: \1/'. It only got the ones that were on one line, so it still took me forever to update the rest, but it made it go a lot faster. There probably would have been a way to make it work multi-line as well.

I just realized that I forgot to update the docs. It looks like there weren't too many references there and you may have already gotten them, but you may want to do a search grep -r Axes docs/ to make sure we didn't miss any. It'd also be good to double check that the new r scale got documented and that the migration guide got updated

benmccann
benmccann previously approved these changes Nov 20, 2019
Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. It's getting hard to review now that we're up to 200 files, but I think we could merge it and clean up anything we missed over time since it looks pretty close

benmccann
benmccann previously approved these changes Nov 20, 2019
etimberg
etimberg previously approved these changes Nov 20, 2019
Copy link
Member

@etimberg etimberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks for taking my MR and making it great! Just one minor comment re a test

defaults.line.spanGaps = false;
});

it('should override axis positions that are incorrect', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add this back at all? I realize this might have been removed from my original MR but I think we can support it still in this form

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, added the test back!

@kurkle kurkle dismissed stale reviews from etimberg and benmccann via 2800fc2 November 21, 2019 07:23
Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. just some minor notes. I'm okay if we prefer to do anything else in a follow up

### Axis ID
The properties `dataset.xAxisID` or `dataset.yAxisID` have to match the scale properties `scales.xAxes.id` or `scales.yAxes.id`. This is especially needed if multi-axes charts are used.

The properties `dataset.xAxisID` or `dataset.yAxisID` have to match to `scales` property. This is especially needed if multi-axes charts are used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might sound more natural to say "have to match a property of scales"

scales: {
yAxes: [{
id: 'first-y-axis',
'first-y-axis': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this syntax works though it's a bit awkward as an example. Maybe firstYAxis would be easier since it wouldn't require the single quotes

}, {
type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
},
y1: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y and y1 is not quite what I'd expect. Would y1 and y2 work? (same in the other samples)

Object.entries(options.scales).map(function(entry) {
var axisID = entry[0];
var axisOptions = entry[1];
var isRadial = axisID.charAt(0).toLowerCase === 'r';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a TODO here or document that the first character must be x, y, or r?

@etimberg etimberg merged commit ce74eb7 into chartjs:master Nov 21, 2019
@kurkle kurkle deleted the axes branch December 7, 2019 05:35
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