Skip to content

Use Template.newContainer in polar axis defaults #3092

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

Merged
merged 1 commit into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/plots/polar/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

var Lib = require('../../lib');
var Color = require('../../components/color');
var Template = require('../../plot_api/plot_template');

var handleSubplotDefaults = require('../subplot_defaults');
var getSubplotData = require('../get_data').getSubplotData;

Expand Down Expand Up @@ -49,11 +51,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
}

var axIn = contIn[axName];
// Note: does not need template propagation, since coerceAxis is still
// based on the subplot-wide coerce function. Though it may be more
// efficient to make a new coerce function, then we *would* need to
// propagate the template.
Copy link
Collaborator

Choose a reason for hiding this comment

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

huh, so was this comment wrong all along, or did something change since I wrote this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That comment was only partially correct/wrong.

We didn't have to propagate the templates for attributes getting coerced by the coerce function in the polar/layout_defaults.js scope, but we do need to for attributes getting coerced by coerce2 like here:

function coerce2(attr, dflt) {
return Lib.coerce2(containerIn, containerOut, opts.attributes, attr, dflt);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

but we do need to for attributes getting coerced by coerce2 like here

Ah... there it is, thanks.

var axOut = contOut[axName] = {};
var axOut = contOut[axName] = Template.newContainer(contOut, axName);
axOut._id = axOut._name = axName;
axOut._traceIndices = subplotData.map(function(t) { return t._expandedIndex; });

Expand Down
Binary file added test/image/baselines/polar_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions test/image/mocks/polar_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"data": [
{
"r": [1, 2, 3],
"theta": [4, 1, 2],
"type": "scatterpolar"
}
],
"layout": {
"template": {
"data": {
"scatterpolar": [
{
"thetaunit": "radians",
"marker": {
"color": "hotpink",
"size": 20
},
"line": {
"color": "cyan"
}
}
]
},
"layout": {
"polar": {
"bgcolor": "black",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white"
},
"angularaxis": {
"gridcolor": "white",
"linecolor": "white"
}
}
}
}
}
}