Skip to content

Commit

Permalink
Merge pull request #3095 from plotly/carpet-template-axes
Browse files Browse the repository at this point in the history
Use Template.newContainer in carpet axis defaults
  • Loading branch information
etpinard authored Oct 11, 2018
2 parents 5a24245 + 76a4e65 commit d340150
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/plots/polar/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
}

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

Expand Down
6 changes: 2 additions & 4 deletions src/traces/carpet/ab_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'use strict';

var handleAxisDefaults = require('./axis_defaults');
var Template = require('../../plot_api/plot_template');

module.exports = function handleABDefaults(traceIn, traceOut, fullLayout, coerce, dfltColor) {
var a = coerce('a');
Expand All @@ -34,7 +35,7 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
axesList.forEach(function(axName) {
var axLetter = axName.charAt(0);
var axIn = traceIn[axName] || {};
var axOut = {};
var axOut = Template.newContainer(traceOut, axName);

var defaultOptions = {
tickfont: 'x',
Expand All @@ -50,11 +51,8 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
};

handleAxisDefaults(axIn, axOut, defaultOptions);

axOut._categories = axOut._categories || [];

traceOut[axName] = axOut;

// so we don't have to repeat autotype unnecessarily,
// copy an autotype back to traceIn
if(!traceIn[axName] && axIn.type !== '-') {
Expand Down
Binary file added test/image/baselines/carpet_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions test/image/mocks/carpet_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"data": [
{
"type": "carpet",
"a": [4, 4, 4, 4.5, 4.5, 4.5, 5, 5, 5, 6, 6, 6],
"b": [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
"y": [2, 3.5, 4, 3, 4.5, 5, 5.5, 6.5, 7.5, 8, 8.5, 10]
}
],
"layout": {
"template": {
"data": {
"carpet": [
{
"aaxis": {
"gridcolor": "cyan",
"linecolor": "cyan",
"tickcolor": "cyan",
"minorgridcolor": "cyan",
"startlinecolor": "cyan",
"endlinecolor": "cyan"
},
"baxis": {
"gridcolor": "cyan",
"linecolor": "cyan",
"tickcolor": "cyan",
"minorgridcolor": "cyan",
"startlinecolor": "cyan",
"endlinecolor": "cyan"
}
}
]
},
"layout": {
"plot_bgcolor": "black"
}
}
}
}

0 comments on commit d340150

Please sign in to comment.