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

Drop legacy polar #5399

Merged
merged 2 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
101 changes: 0 additions & 101 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ var Queue = require('../lib/queue');
var Registry = require('../registry');
var PlotSchema = require('./plot_schema');
var Plots = require('../plots/plots');
var Polar = require('../plots/polar/legacy');

var Axes = require('../plots/cartesian/axes');
var Drawing = require('../components/drawing');
var Color = require('../components/color');
var initInteractions = require('../plots/cartesian/graph_interact').initInteractions;
var xmlnsNamespaces = require('../constants/xmlns_namespaces');
var svgTextUtils = require('../lib/svg_text_utils');
var clearSelect = require('../plots/cartesian/select').clearSelect;

var dfltConfig = require('./plot_config').dfltConfig;
Expand Down Expand Up @@ -141,12 +139,6 @@ function plot(gd, data, layout, config) {
var fullLayout = gd._fullLayout;
var hasCartesian = fullLayout._has('cartesian');

// Legacy polar plots
if(!fullLayout._has('polar') && data && data[0] && data[0].r) {
Lib.log('Legacy polar charts are deprecated!');
return plotLegacyPolar(gd, data, layout);
}

// so we don't try to re-call Plotly.plot from inside
// legend and colorbar, if margins changed
fullLayout._replotting = true;
Expand Down Expand Up @@ -547,99 +539,6 @@ function setPlotContext(gd, config) {
}
}

function plotLegacyPolar(gd, data, layout) {
// build or reuse the container skeleton
var plotContainer = d3.select(gd).selectAll('.plot-container')
.data([0]);
plotContainer.enter()
.insert('div', ':first-child')
.classed('plot-container plotly', true);
var paperDiv = plotContainer.selectAll('.svg-container')
.data([0]);
paperDiv.enter().append('div')
.classed('svg-container', true)
.style('position', 'relative');

// empty it everytime for now
paperDiv.html('');

// fulfill gd requirements
if(data) gd.data = data;
if(layout) gd.layout = layout;
Polar.manager.fillLayout(gd);

// resize canvas
paperDiv.style({
width: gd._fullLayout.width + 'px',
height: gd._fullLayout.height + 'px'
});

// instantiate framework
gd.framework = Polar.manager.framework(gd);

// plot
gd.framework({data: gd.data, layout: gd.layout}, paperDiv.node());

// set undo point
gd.framework.setUndoPoint();

// get the resulting svg for extending it
var polarPlotSVG = gd.framework.svg();

// editable title
var opacity = 1;
var txt = gd._fullLayout.title ? gd._fullLayout.title.text : '';
if(txt === '' || !txt) opacity = 0;

var titleLayout = function() {
this.call(svgTextUtils.convertToTspans, gd);
// TODO: html/mathjax
// TODO: center title
};

var title = polarPlotSVG.select('.title-group text')
.call(titleLayout);

if(gd._context.edits.titleText) {
var placeholderText = Lib._(gd, 'Click to enter Plot title');
if(!txt || txt === placeholderText) {
opacity = 0.2;
// placeholder is not going through convertToTspans
// so needs explicit data-unformatted
title.attr({'data-unformatted': placeholderText})
.text(placeholderText)
.style({opacity: opacity})
.on('mouseover.opacity', function() {
d3.select(this).transition().duration(100)
.style('opacity', 1);
})
.on('mouseout.opacity', function() {
d3.select(this).transition().duration(1000)
.style('opacity', 0);
});
}

var setContenteditable = function() {
this.call(svgTextUtils.makeEditable, {gd: gd})
.on('edit', function(text) {
gd.framework({layout: {title: {text: text}}});
this.text(text)
.call(titleLayout);
this.call(setContenteditable);
})
.on('cancel', function() {
var txt = this.attr('data-unformatted');
this.text(txt).call(titleLayout);
});
};
title.call(setContenteditable);
}

gd._context.setBackground(gd, gd._fullLayout.paper_bgcolor);
Plots.addLinks(gd);

return Promise.resolve();
}

// convenience function to force a full redraw, mostly for use by plotly.js
function redraw(gd) {
Expand Down
38 changes: 4 additions & 34 deletions src/plot_api/plot_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ var frameAttributes = require('../plots/frame_attributes');
var animationAttributes = require('../plots/animation_attributes');
var configAttributes = require('./plot_config').configAttributes;

// polar attributes are not part of the Registry yet
var polarAreaAttrs = require('../plots/polar/legacy/area_attributes');
var polarAxisAttrs = require('../plots/polar/legacy/axis_attributes');

var editTypes = require('./edit_types');

var extendFlat = Lib.extendFlat;
var extendDeepAll = Lib.extendDeepAll;
var isPlainObject = Lib.isPlainObject;
var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
Expand Down Expand Up @@ -55,7 +50,7 @@ exports.UNDERSCORE_ATTRS = UNDERSCORE_ATTRS;
exports.get = function() {
var traces = {};

Registry.allTypes.concat('area').forEach(function(type) {
Registry.allTypes.forEach(function(type) {
traces[type] = getTraceAttributes(type);
});

Expand Down Expand Up @@ -282,8 +277,6 @@ exports.getTraceValObject = function(trace, parts) {
moduleAttrs = (Registry.transformsRegistry[transforms[tNum].type] || {}).attributes;
valObject = moduleAttrs && moduleAttrs[parts[2]];
i = 3; // start recursing only inside the transform
} else if(trace.type === 'area') {
valObject = polarAreaAttrs[head];
} else {
// first look in the module for this trace
// components have already merged their trace attributes in here
Expand Down Expand Up @@ -384,12 +377,7 @@ function layoutHeadAttr(fullLayout, head) {

if(head in baseLayoutAttributes) return baseLayoutAttributes[head];

// Polar doesn't populate _modules or _basePlotModules
// just fall back on these when the others fail
if(head === 'radialaxis' || head === 'angularaxis') {
return polarAxisAttrs[head];
}
return polarAxisAttrs.layout[head] || false;
return false;
}

function recurseIntoValObject(valObject, parts, i) {
Expand Down Expand Up @@ -447,13 +435,8 @@ function isIndex(val) {
function getTraceAttributes(type) {
var _module, basePlotModule;

if(type === 'area') {
_module = { attributes: polarAreaAttrs };
basePlotModule = {};
} else {
_module = Registry.modules[type]._module,
basePlotModule = _module.basePlotModule;
}
_module = Registry.modules[type]._module,
basePlotModule = _module.basePlotModule;

var attributes = {};

Expand Down Expand Up @@ -551,9 +534,6 @@ function getLayoutAttributes() {
}
}

// polar layout attributes
layoutAttributes = assignPolarLayoutAttrs(layoutAttributes);

// add registered components layout attributes
for(key in Registry.componentsRegistry) {
_module = Registry.componentsRegistry[key];
Expand Down Expand Up @@ -701,16 +681,6 @@ function stringify(attrs) {
walk(attrs);
}

function assignPolarLayoutAttrs(layoutAttributes) {
extendFlat(layoutAttributes, {
radialaxis: polarAxisAttrs.radialaxis,
angularaxis: polarAxisAttrs.angularaxis
});

extendFlat(layoutAttributes, polarAxisAttrs.layout);

return layoutAttributes;
}

function handleBasePlotModule(layoutAttributes, _module, astr) {
var np = nestedProperty(layoutAttributes, astr);
Expand Down
7 changes: 0 additions & 7 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ plots.hasSimpleAPICommandBindings = commandModule.hasSimpleAPICommandBindings;
plots.redrawText = function(gd) {
gd = Lib.getGraphDiv(gd);

var fullLayout = gd._fullLayout || {};
var hasPolar = fullLayout._has && fullLayout._has('polar');
var hasLegacyPolar = !hasPolar && gd.data && gd.data[0] && gd.data[0].r;

// do not work if polar is present
if(hasLegacyPolar) return;

return new Promise(function(resolve) {
setTimeout(function() {
Registry.getComponentMethod('annotations', 'draw')(gd);
Expand Down
62 changes: 0 additions & 62 deletions src/plots/polar/legacy/area_attributes.js

This file was deleted.

Loading