diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 96d0a3f8c4c..3ae3bcf42d6 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -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; @@ -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; @@ -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) { diff --git a/src/plot_api/plot_schema.js b/src/plot_api/plot_schema.js index 56c772510e1..a67c8909f28 100644 --- a/src/plot_api/plot_schema.js +++ b/src/plot_api/plot_schema.js @@ -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; @@ -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); }); @@ -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 @@ -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) { @@ -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 = {}; @@ -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]; @@ -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); diff --git a/src/plots/plots.js b/src/plots/plots.js index 57504a7cb00..e0ec0575abd 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -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); diff --git a/src/plots/polar/legacy/area_attributes.js b/src/plots/polar/legacy/area_attributes.js deleted file mode 100644 index 3220f032369..00000000000 --- a/src/plots/polar/legacy/area_attributes.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* Copyright 2012-2021, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -var scatterAttrs = require('../../../traces/scatter/attributes'); -var scatterMarkerAttrs = scatterAttrs.marker; -var extendFlat = require('../../../lib/extend').extendFlat; - -var deprecationWarning = [ - 'Area traces are deprecated!', - 'Please switch to the *barpolar* trace type.' -].join(' '); - -module.exports = { - r: extendFlat({}, scatterAttrs.r, { - description: [ - deprecationWarning, - 'Sets the radial coordinates', - 'for legacy polar chart only.' - ].join(' ') - }), - t: extendFlat({}, scatterAttrs.t, { - description: [ - deprecationWarning, - 'Sets the angular coordinates', - 'for legacy polar chart only.' - ].join(' ') - }), - marker: { - color: extendFlat({}, scatterMarkerAttrs.color, { - description: [ - deprecationWarning, - scatterMarkerAttrs.color.description - ].join(' ') - }), - size: extendFlat({}, scatterMarkerAttrs.size, { - description: [ - deprecationWarning, - scatterMarkerAttrs.size.description - ].join(' ') - }), - symbol: extendFlat({}, scatterMarkerAttrs.symbol, { - description: [ - deprecationWarning, - scatterMarkerAttrs.symbol.description - ].join(' ') - }), - opacity: extendFlat({}, scatterMarkerAttrs.opacity, { - description: [ - deprecationWarning, - scatterMarkerAttrs.opacity.description - ].join(' ') - }), - editType: 'calc' - } -}; diff --git a/src/plots/polar/legacy/axis_attributes.js b/src/plots/polar/legacy/axis_attributes.js deleted file mode 100644 index 839f7b0cd05..00000000000 --- a/src/plots/polar/legacy/axis_attributes.js +++ /dev/null @@ -1,167 +0,0 @@ -/** -* Copyright 2012-2021, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var axesAttrs = require('../../cartesian/layout_attributes'); -var extendFlat = require('../../../lib/extend').extendFlat; -var overrideAll = require('../../../plot_api/edit_types').overrideAll; - -var deprecationWarning = [ - 'Legacy polar charts are deprecated!', - 'Please switch to *polar* subplots.' -].join(' '); - -var domainAttr = extendFlat({}, axesAttrs.domain, { - description: [ - 'Polar chart subplots are not supported yet.', - 'This key has currently no effect.' - ].join(' ') -}); - -function mergeAttrs(axisName, nonCommonAttrs) { - var commonAttrs = { - showline: { - valType: 'boolean', - role: 'style', - description: [ - deprecationWarning, - 'Determines whether or not the line bounding this', - axisName, 'axis', - 'will be shown on the figure.' - ].join(' ') - }, - showticklabels: { - valType: 'boolean', - role: 'style', - description: [ - deprecationWarning, - 'Determines whether or not the', - axisName, 'axis ticks', - 'will feature tick labels.' - ].join(' ') - }, - tickorientation: { - valType: 'enumerated', - values: ['horizontal', 'vertical'], - role: 'style', - description: [ - deprecationWarning, - 'Sets the orientation (from the paper perspective)', - 'of the', axisName, 'axis tick labels.' - ].join(' ') - }, - ticklen: { - valType: 'number', - min: 0, - role: 'style', - description: [ - deprecationWarning, - 'Sets the length of the tick lines on this', axisName, 'axis.' - ].join(' ') - }, - tickcolor: { - valType: 'color', - role: 'style', - description: [ - deprecationWarning, - 'Sets the color of the tick lines on this', axisName, 'axis.' - ].join(' ') - }, - ticksuffix: { - valType: 'string', - role: 'style', - description: [ - deprecationWarning, - 'Sets the length of the tick lines on this', axisName, 'axis.' - ].join(' ') - }, - endpadding: { - valType: 'number', - role: 'style', - description: deprecationWarning, - }, - visible: { - valType: 'boolean', - role: 'info', - description: [ - deprecationWarning, - 'Determines whether or not this axis will be visible.' - ].join(' ') - } - }; - - return extendFlat({}, nonCommonAttrs, commonAttrs); -} - -module.exports = overrideAll({ - radialaxis: mergeAttrs('radial', { - range: { - valType: 'info_array', - role: 'info', - items: [ - { valType: 'number' }, - { valType: 'number' } - ], - description: [ - deprecationWarning, - 'Defines the start and end point of this radial axis.' - ].join(' ') - }, - domain: domainAttr, - orientation: { - valType: 'number', - role: 'style', - description: [ - deprecationWarning, - 'Sets the orientation (an angle with respect to the origin)', - 'of the radial axis.' - ].join(' ') - } - }), - - angularaxis: mergeAttrs('angular', { - range: { - valType: 'info_array', - role: 'info', - items: [ - { valType: 'number', dflt: 0 }, - { valType: 'number', dflt: 360 } - ], - description: [ - deprecationWarning, - 'Defines the start and end point of this angular axis.' - ].join(' ') - }, - domain: domainAttr - }), - - // attributes that appear at layout root - layout: { - direction: { - valType: 'enumerated', - values: ['clockwise', 'counterclockwise'], - role: 'info', - description: [ - deprecationWarning, - 'Sets the direction corresponding to positive angles', - 'in legacy polar charts.' - ].join(' ') - }, - orientation: { - valType: 'angle', - role: 'info', - description: [ - deprecationWarning, - 'Rotates the entire polar by the given angle', - 'in legacy polar charts.' - ].join(' ') - } - } -}, 'plot', 'nested'); diff --git a/src/plots/polar/legacy/index.js b/src/plots/polar/legacy/index.js deleted file mode 100644 index 4f983345195..00000000000 --- a/src/plots/polar/legacy/index.js +++ /dev/null @@ -1,13 +0,0 @@ -/** -* Copyright 2012-2021, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -var Polar = module.exports = require('./micropolar'); - -Polar.manager = require('./micropolar_manager'); diff --git a/src/plots/polar/legacy/micropolar.js b/src/plots/polar/legacy/micropolar.js deleted file mode 100644 index 4d979fb1a18..00000000000 --- a/src/plots/polar/legacy/micropolar.js +++ /dev/null @@ -1,1418 +0,0 @@ -/** -* Copyright 2012-2021, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -var d3 = require('@plotly/d3'); -var Lib = require('../../../lib'); -var extendDeepAll = Lib.extendDeepAll; -var MID_SHIFT = require('../../../constants/alignment').MID_SHIFT; - -var µ = module.exports = { version: '0.2.2' }; - -µ.Axis = function module() { - var config = { - data: [], - layout: {} - }, inputConfig = {}, liveConfig = {}; - var svg, container, dispatch = d3.dispatch('hover'), radialScale, angularScale; - var exports = {}; - function render(_container) { - container = _container || container; - var data = config.data; - var axisConfig = config.layout; - if (typeof container == 'string' || container.nodeName) container = d3.select(container); - container.datum(data).each(function(_data, _index) { - var dataOriginal = _data.slice(); - liveConfig = { - data: µ.util.cloneJson(dataOriginal), - layout: µ.util.cloneJson(axisConfig) - }; - var colorIndex = 0; - dataOriginal.forEach(function(d, i) { - if (!d.color) { - d.color = axisConfig.defaultColorRange[colorIndex]; - colorIndex = (colorIndex + 1) % axisConfig.defaultColorRange.length; - } - if (!d.strokeColor) { - d.strokeColor = d.geometry === 'LinePlot' ? d.color : d3.rgb(d.color).darker().toString(); - } - liveConfig.data[i].color = d.color; - liveConfig.data[i].strokeColor = d.strokeColor; - liveConfig.data[i].strokeDash = d.strokeDash; - liveConfig.data[i].strokeSize = d.strokeSize; - }); - var data = dataOriginal.filter(function(d, i) { - var visible = d.visible; - return typeof visible === 'undefined' || visible === true; - }); - var isStacked = false; - var dataWithGroupId = data.map(function(d, i) { - isStacked = isStacked || typeof d.groupId !== 'undefined'; - return d; - }); - if (isStacked) { - var grouped = d3.nest().key(function(d, i) { - return typeof d.groupId != 'undefined' ? d.groupId : 'unstacked'; - }).entries(dataWithGroupId); - var dataYStack = []; - var stacked = grouped.map(function(d, i) { - if (d.key === 'unstacked') return d.values; else { - var prevArray = d.values[0].r.map(function(d, i) { - return 0; - }); - d.values.forEach(function(d, i, a) { - d.yStack = [ prevArray ]; - dataYStack.push(prevArray); - prevArray = µ.util.sumArrays(d.r, prevArray); - }); - return d.values; - } - }); - data = d3.merge(stacked); - } - data.forEach(function(d, i) { - d.t = Array.isArray(d.t[0]) ? d.t : [ d.t ]; - d.r = Array.isArray(d.r[0]) ? d.r : [ d.r ]; - }); - var radius = Math.min(axisConfig.width - axisConfig.margin.left - axisConfig.margin.right, axisConfig.height - axisConfig.margin.top - axisConfig.margin.bottom) / 2; - radius = Math.max(10, radius); - var chartCenter = [ axisConfig.margin.left + radius, axisConfig.margin.top + radius ]; - var extent; - if (isStacked) { - var highestStackedValue = d3.max(µ.util.sumArrays(µ.util.arrayLast(data).r[0], µ.util.arrayLast(dataYStack))); - extent = [ 0, highestStackedValue ]; - } else extent = d3.extent(µ.util.flattenArray(data.map(function(d, i) { - return d.r; - }))); - if (axisConfig.radialAxis.domain != µ.DATAEXTENT) extent[0] = 0; - radialScale = d3.scale.linear().domain(axisConfig.radialAxis.domain != µ.DATAEXTENT && axisConfig.radialAxis.domain ? axisConfig.radialAxis.domain : extent).range([ 0, radius ]); - liveConfig.layout.radialAxis.domain = radialScale.domain(); - var angularDataMerged = µ.util.flattenArray(data.map(function(d, i) { - return d.t; - })); - var isOrdinal = typeof angularDataMerged[0] === 'string'; - var ticks; - if (isOrdinal) { - angularDataMerged = µ.util.deduplicate(angularDataMerged); - ticks = angularDataMerged.slice(); - angularDataMerged = d3.range(angularDataMerged.length); - data = data.map(function(d, i) { - var result = d; - d.t = [ angularDataMerged ]; - if (isStacked) result.yStack = d.yStack; - return result; - }); - } - var hasOnlyLineOrDotPlot = data.filter(function(d, i) { - return d.geometry === 'LinePlot' || d.geometry === 'DotPlot'; - }).length === data.length; - var needsEndSpacing = axisConfig.needsEndSpacing === null ? isOrdinal || !hasOnlyLineOrDotPlot : axisConfig.needsEndSpacing; - var useProvidedDomain = axisConfig.angularAxis.domain && axisConfig.angularAxis.domain != µ.DATAEXTENT && !isOrdinal && axisConfig.angularAxis.domain[0] >= 0; - var angularDomain = useProvidedDomain ? axisConfig.angularAxis.domain : d3.extent(angularDataMerged); - var angularDomainStep = Math.abs(angularDataMerged[1] - angularDataMerged[0]); - if (hasOnlyLineOrDotPlot && !isOrdinal) angularDomainStep = 0; - var angularDomainWithPadding = angularDomain.slice(); - if (needsEndSpacing && isOrdinal) angularDomainWithPadding[1] += angularDomainStep; - var tickCount = axisConfig.angularAxis.ticksCount || 4; - if (tickCount > 8) tickCount = tickCount / (tickCount / 8) + tickCount % 8; - if (axisConfig.angularAxis.ticksStep) { - tickCount = (angularDomainWithPadding[1] - angularDomainWithPadding[0]) / tickCount; - } - var angularTicksStep = axisConfig.angularAxis.ticksStep || (angularDomainWithPadding[1] - angularDomainWithPadding[0]) / (tickCount * (axisConfig.minorTicks + 1)); - if (ticks) angularTicksStep = Math.max(Math.round(angularTicksStep), 1); - if (!angularDomainWithPadding[2]) angularDomainWithPadding[2] = angularTicksStep; - var angularAxisRange = d3.range.apply(this, angularDomainWithPadding); - angularAxisRange = angularAxisRange.map(function(d, i) { - return parseFloat(d.toPrecision(12)); - }); - angularScale = d3.scale.linear().domain(angularDomainWithPadding.slice(0, 2)).range(axisConfig.direction === 'clockwise' ? [ 0, 360 ] : [ 360, 0 ]); - liveConfig.layout.angularAxis.domain = angularScale.domain(); - liveConfig.layout.angularAxis.endPadding = needsEndSpacing ? angularDomainStep : 0; - svg = d3.select(this).select('svg.chart-root'); - if (typeof svg === 'undefined' || svg.empty()) { - var skeleton = "' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '"; - var doc = new DOMParser().parseFromString(skeleton, 'application/xml'); - var newSvg = this.appendChild(this.ownerDocument.importNode(doc.documentElement, true)); - svg = d3.select(newSvg); - } - svg.select('.guides-group').style({ - 'pointer-events': 'none' - }); - svg.select('.angular.axis-group').style({ - 'pointer-events': 'none' - }); - svg.select('.radial.axis-group').style({ - 'pointer-events': 'none' - }); - var chartGroup = svg.select('.chart-group'); - var lineStyle = { - fill: 'none', - stroke: axisConfig.tickColor - }; - var fontStyle = { - 'font-size': axisConfig.font.size, - 'font-family': axisConfig.font.family, - fill: axisConfig.font.color, - 'text-shadow': [ '-1px 0px', '1px -1px', '-1px 1px', '1px 1px' ].map(function(d, i) { - return ' ' + d + ' 0 ' + axisConfig.font.outlineColor; - }).join(',') - }; - var legendContainer; - if (axisConfig.showLegend) { - legendContainer = svg.select('.legend-group').attr({ - transform: 'translate(' + [ radius, axisConfig.margin.top ] + ')' - }).style({ - display: 'block' - }); - var elements = data.map(function(d, i) { - var datumClone = µ.util.cloneJson(d); - datumClone.symbol = d.geometry === 'DotPlot' ? d.dotType || 'circle' : d.geometry != 'LinePlot' ? 'square' : 'line'; - datumClone.visibleInLegend = typeof d.visibleInLegend === 'undefined' || d.visibleInLegend; - datumClone.color = d.geometry === 'LinePlot' ? d.strokeColor : d.color; - return datumClone; - }); - - µ.Legend().config({ - data: data.map(function(d, i) { - return d.name || 'Element' + i; - }), - legendConfig: extendDeepAll({}, - µ.Legend.defaultConfig().legendConfig, - { - container: legendContainer, - elements: elements, - reverseOrder: axisConfig.legend.reverseOrder - } - ) - })(); - - var legendBBox = legendContainer.node().getBBox(); - radius = Math.min(axisConfig.width - legendBBox.width - axisConfig.margin.left - axisConfig.margin.right, axisConfig.height - axisConfig.margin.top - axisConfig.margin.bottom) / 2; - radius = Math.max(10, radius); - chartCenter = [ axisConfig.margin.left + radius, axisConfig.margin.top + radius ]; - radialScale.range([ 0, radius ]); - liveConfig.layout.radialAxis.domain = radialScale.domain(); - legendContainer.attr('transform', 'translate(' + [ chartCenter[0] + radius, chartCenter[1] - radius ] + ')'); - } else { - legendContainer = svg.select('.legend-group').style({ - display: 'none' - }); - } - svg.attr({ - width: axisConfig.width, - height: axisConfig.height - }).style({ - opacity: axisConfig.opacity - }); - chartGroup.attr('transform', 'translate(' + chartCenter + ')').style({ - cursor: 'crosshair' - }); - var centeringOffset = [ (axisConfig.width - (axisConfig.margin.left + axisConfig.margin.right + radius * 2 + (legendBBox ? legendBBox.width : 0))) / 2, (axisConfig.height - (axisConfig.margin.top + axisConfig.margin.bottom + radius * 2)) / 2 ]; - centeringOffset[0] = Math.max(0, centeringOffset[0]); - centeringOffset[1] = Math.max(0, centeringOffset[1]); - svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title && axisConfig.title.text) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); - var titleBBox = title.node().getBBox(); - title.attr({ - x: chartCenter[0] - titleBBox.width / 2, - y: chartCenter[1] - radius - 20 - }); - } - var radialAxis = svg.select('.radial.axis-group'); - if (axisConfig.radialAxis.gridLinesVisible) { - var gridCircles = radialAxis.selectAll('circle.grid-circle').data(radialScale.ticks(5)); - gridCircles.enter().append('circle').attr({ - 'class': 'grid-circle' - }).style(lineStyle); - gridCircles.attr('r', radialScale); - gridCircles.exit().remove(); - } - radialAxis.select('circle.outside-circle').attr({ - r: radius - }).style(lineStyle); - var backgroundCircle = svg.select('circle.background-circle').attr({ - r: radius - }).style({ - fill: axisConfig.backgroundColor, - stroke: axisConfig.stroke - }); - function currentAngle(d, i) { - return angularScale(d) % 360 + axisConfig.orientation; - } - if (axisConfig.radialAxis.visible) { - var axis = d3.svg.axis().scale(radialScale).ticks(5).tickSize(5); - radialAxis.call(axis).attr({ - transform: 'rotate(' + axisConfig.radialAxis.orientation + ')' - }); - radialAxis.selectAll('.domain').style(lineStyle); - radialAxis.selectAll('g>text').text(function(d, i) { - return this.textContent + axisConfig.radialAxis.ticksSuffix; - }).style(fontStyle).style({ - 'text-anchor': 'start' - }).attr({ - x: 0, - y: 0, - dx: 0, - dy: 0, - transform: function(d, i) { - if (axisConfig.radialAxis.tickOrientation === 'horizontal') { - return 'rotate(' + -axisConfig.radialAxis.orientation + ') translate(' + [ 0, fontStyle['font-size'] ] + ')'; - } else return 'translate(' + [ 0, fontStyle['font-size'] ] + ')'; - } - }); - radialAxis.selectAll('g>line').style({ - stroke: 'black' - }); - } - var angularAxis = svg.select('.angular.axis-group').selectAll('g.angular-tick').data(angularAxisRange); - var angularAxisEnter = angularAxis.enter().append('g').classed('angular-tick', true); - angularAxis.attr({ - transform: function(d, i) { - return 'rotate(' + currentAngle(d, i) + ')'; - } - }).style({ - display: axisConfig.angularAxis.visible ? 'block' : 'none' - }); - angularAxis.exit().remove(); - angularAxisEnter.append('line').classed('grid-line', true).classed('major', function(d, i) { - return i % (axisConfig.minorTicks + 1) == 0; - }).classed('minor', function(d, i) { - return !(i % (axisConfig.minorTicks + 1) == 0); - }).style(lineStyle); - angularAxisEnter.selectAll('.minor').style({ - stroke: axisConfig.minorTickColor - }); - angularAxis.select('line.grid-line').attr({ - x1: axisConfig.tickLength ? radius - axisConfig.tickLength : 0, - x2: radius - }).style({ - display: axisConfig.angularAxis.gridLinesVisible ? 'block' : 'none' - }); - angularAxisEnter.append('text').classed('axis-text', true).style(fontStyle); - var ticksText = angularAxis.select('text.axis-text').attr({ - x: radius + axisConfig.labelOffset, - dy: MID_SHIFT + 'em', - transform: function(d, i) { - var angle = currentAngle(d, i); - var rad = radius + axisConfig.labelOffset; - var orient = axisConfig.angularAxis.tickOrientation; - if (orient == 'horizontal') return 'rotate(' + -angle + ' ' + rad + ' 0)'; else if (orient == 'radial') return angle < 270 && angle > 90 ? 'rotate(180 ' + rad + ' 0)' : null; else return 'rotate(' + (angle <= 180 && angle > 0 ? -90 : 90) + ' ' + rad + ' 0)'; - } - }).style({ - 'text-anchor': 'middle', - display: axisConfig.angularAxis.labelsVisible ? 'block' : 'none' - }).text(function(d, i) { - if (i % (axisConfig.minorTicks + 1) != 0) return ''; - if (ticks) { - return ticks[d] + axisConfig.angularAxis.ticksSuffix; - } else return d + axisConfig.angularAxis.ticksSuffix; - }).style(fontStyle); - if (axisConfig.angularAxis.rewriteTicks) ticksText.text(function(d, i) { - if (i % (axisConfig.minorTicks + 1) != 0) return ''; - return axisConfig.angularAxis.rewriteTicks(this.textContent, i); - }); - var rightmostTickEndX = d3.max(chartGroup.selectAll('.angular-tick text')[0].map(function(d, i) { - return d.getCTM().e + d.getBBox().width; - })); - legendContainer.attr({ - transform: 'translate(' + [ radius + rightmostTickEndX, axisConfig.margin.top ] + ')' - }); - var hasGeometry = svg.select('g.geometry-group').selectAll('g').size() > 0; - var geometryContainer = svg.select('g.geometry-group').selectAll('g.geometry').data(data); - geometryContainer.enter().append('g').attr({ - 'class': function(d, i) { - return 'geometry geometry' + i; - } - }); - geometryContainer.exit().remove(); - if (data[0] || hasGeometry) { - var geometryConfigs = []; - data.forEach(function(d, i) { - var geometryConfig = {}; - geometryConfig.radialScale = radialScale; - geometryConfig.angularScale = angularScale; - geometryConfig.container = geometryContainer.filter(function(dB, iB) { - return iB == i; - }); - geometryConfig.geometry = d.geometry; - geometryConfig.orientation = axisConfig.orientation; - geometryConfig.direction = axisConfig.direction; - geometryConfig.index = i; - geometryConfigs.push({ - data: d, - geometryConfig: geometryConfig - }); - }); - var geometryConfigsGrouped = d3.nest().key(function(d, i) { - return typeof d.data.groupId != 'undefined' || 'unstacked'; - }).entries(geometryConfigs); - var geometryConfigsGrouped2 = []; - geometryConfigsGrouped.forEach(function(d, i) { - if (d.key === 'unstacked') geometryConfigsGrouped2 = geometryConfigsGrouped2.concat(d.values.map(function(d, i) { - return [ d ]; - })); else geometryConfigsGrouped2.push(d.values); - }); - geometryConfigsGrouped2.forEach(function(d, i) { - var geometry; - if (Array.isArray(d)) geometry = d[0].geometryConfig.geometry; else geometry = d.geometryConfig.geometry; - var finalGeometryConfig = d.map(function(dB, iB) { - return extendDeepAll(µ[geometry].defaultConfig(), dB); - }); - µ[geometry]().config(finalGeometryConfig)(); - }); - } - var guides = svg.select('.guides-group'); - var tooltipContainer = svg.select('.tooltips-group'); - var angularTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - fontSize: 8 - })(); - var radialTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - fontSize: 8 - })(); - var geometryTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - hasTick: true - })(); - var angularValue, radialValue; - if (!isOrdinal) { - var angularGuideLine = guides.select('line').attr({ - x1: 0, - y1: 0, - y2: 0 - }).style({ - stroke: 'grey', - 'pointer-events': 'none' - }); - chartGroup.on('mousemove.angular-guide', function(d, i) { - var mouseAngle = µ.util.getMousePos(backgroundCircle).angle; - angularGuideLine.attr({ - x2: -radius, - transform: 'rotate(' + mouseAngle + ')' - }).style({ - opacity: .5 - }); - var angleWithOriginOffset = (mouseAngle + 180 + 360 - axisConfig.orientation) % 360; - angularValue = angularScale.invert(angleWithOriginOffset); - var pos = µ.util.convertToCartesian(radius + 12, mouseAngle + 180); - angularTooltip.text(µ.util.round(angularValue)).move([ pos[0] + chartCenter[0], pos[1] + chartCenter[1] ]); - }).on('mouseout.angular-guide', function(d, i) { - guides.select('line').style({ - opacity: 0 - }); - }); - } - var angularGuideCircle = guides.select('circle').style({ - stroke: 'grey', - fill: 'none' - }); - chartGroup.on('mousemove.radial-guide', function(d, i) { - var r = µ.util.getMousePos(backgroundCircle).radius; - angularGuideCircle.attr({ - r: r - }).style({ - opacity: .5 - }); - radialValue = radialScale.invert(µ.util.getMousePos(backgroundCircle).radius); - var pos = µ.util.convertToCartesian(r, axisConfig.radialAxis.orientation); - radialTooltip.text(µ.util.round(radialValue)).move([ pos[0] + chartCenter[0], pos[1] + chartCenter[1] ]); - }).on('mouseout.radial-guide', function(d, i) { - angularGuideCircle.style({ - opacity: 0 - }); - geometryTooltip.hide(); - angularTooltip.hide(); - radialTooltip.hide(); - }); - svg.selectAll('.geometry-group .mark').on('mouseover.tooltip', function(d, i) { - var el = d3.select(this); - var color = this.style.fill; - var newColor = 'black'; - var opacity = this.style.opacity || 1; - el.attr({ - 'data-opacity': opacity - }); - if (color && color !== 'none') { - el.attr({ - 'data-fill': color - }); - newColor = d3.hsl(color).darker().toString(); - el.style({ - fill: newColor, - opacity: 1 - }); - var textData = { - t: µ.util.round(d[0]), - r: µ.util.round(d[1]) - }; - if (isOrdinal) textData.t = ticks[d[0]]; - var text = 't: ' + textData.t + ', r: ' + textData.r; - var bbox = this.getBoundingClientRect(); - var svgBBox = svg.node().getBoundingClientRect(); - var pos = [ bbox.left + bbox.width / 2 - centeringOffset[0] - svgBBox.left, bbox.top + bbox.height / 2 - centeringOffset[1] - svgBBox.top ]; - geometryTooltip.config({ - color: newColor - }).text(text); - geometryTooltip.move(pos); - } else { - color = this.style.stroke || 'black'; - el.attr({ - 'data-stroke': color - }); - newColor = d3.hsl(color).darker().toString(); - el.style({ - stroke: newColor, - opacity: 1 - }); - } - }).on('mousemove.tooltip', function(d, i) { - if (d3.event.which != 0) return false; - if (d3.select(this).attr('data-fill')) geometryTooltip.show(); - }).on('mouseout.tooltip', function(d, i) { - geometryTooltip.hide(); - var el = d3.select(this); - var fillColor = el.attr('data-fill'); - if (fillColor) el.style({ - fill: fillColor, - opacity: el.attr('data-opacity') - }); else el.style({ - stroke: el.attr('data-stroke'), - opacity: el.attr('data-opacity') - }); - }); - }); - return exports; - } - exports.render = function(_container) { - render(_container); - return this; - }; - exports.config = function(_x) { - if (!arguments.length) return config; - var xClone = µ.util.cloneJson(_x); - xClone.data.forEach(function(d, i) { - if (!config.data[i]) config.data[i] = {}; - extendDeepAll(config.data[i], µ.Axis.defaultConfig().data[0]); - extendDeepAll(config.data[i], d); - }); - extendDeepAll(config.layout, µ.Axis.defaultConfig().layout); - extendDeepAll(config.layout, xClone.layout); - return this; - }; - exports.getLiveConfig = function() { - return liveConfig; - }; - exports.getinputConfig = function() { - return inputConfig; - }; - exports.radialScale = function(_x) { - return radialScale; - }; - exports.angularScale = function(_x) { - return angularScale; - }; - exports.svg = function() { - return svg; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.Axis.defaultConfig = function(d, i) { - var config = { - data: [ { - t: [ 1, 2, 3, 4 ], - r: [ 10, 11, 12, 13 ], - name: 'Line1', - geometry: 'LinePlot', - color: null, - strokeDash: 'solid', - strokeColor: null, - strokeSize: '1', - visibleInLegend: true, - opacity: 1 - } ], - layout: { - defaultColorRange: d3.scale.category10().range(), - title: null, - height: 450, - width: 500, - margin: { - top: 40, - right: 40, - bottom: 40, - left: 40 - }, - font: { - size: 12, - color: 'gray', - outlineColor: 'white', - family: 'Tahoma, sans-serif' - }, - direction: 'clockwise', - orientation: 0, - labelOffset: 10, - radialAxis: { - domain: null, - orientation: -45, - ticksSuffix: '', - visible: true, - gridLinesVisible: true, - tickOrientation: 'horizontal', - rewriteTicks: null - }, - angularAxis: { - domain: [ 0, 360 ], - ticksSuffix: '', - visible: true, - gridLinesVisible: true, - labelsVisible: true, - tickOrientation: 'horizontal', - rewriteTicks: null, - ticksCount: null, - ticksStep: null - }, - minorTicks: 0, - tickLength: null, - tickColor: 'silver', - minorTickColor: '#eee', - backgroundColor: 'none', - needsEndSpacing: null, - showLegend: true, - legend: { - reverseOrder: false - }, - opacity: 1 - } - }; - return config; -}; - -µ.util = {}; - -µ.DATAEXTENT = 'dataExtent'; - -µ.AREA = 'AreaChart'; - -µ.LINE = 'LinePlot'; - -µ.DOT = 'DotPlot'; - -µ.BAR = 'BarChart'; - -µ.util._override = function(_objA, _objB) { - for (var x in _objA) if (x in _objB) _objB[x] = _objA[x]; -}; - -µ.util._extend = function(_objA, _objB) { - for (var x in _objA) _objB[x] = _objA[x]; -}; - -µ.util._rndSnd = function() { - return Math.random() * 2 - 1 + (Math.random() * 2 - 1) + (Math.random() * 2 - 1); -}; - -µ.util.dataFromEquation2 = function(_equation, _step) { - var step = _step || 6; - var data = d3.range(0, 360 + step, step).map(function(deg, index) { - var theta = deg * Math.PI / 180; - var radius = _equation(theta); - return [ deg, radius ]; - }); - return data; -}; - -µ.util.dataFromEquation = function(_equation, _step, _name) { - var step = _step || 6; - var t = [], r = []; - d3.range(0, 360 + step, step).forEach(function(deg, index) { - var theta = deg * Math.PI / 180; - var radius = _equation(theta); - t.push(deg); - r.push(radius); - }); - var result = { - t: t, - r: r - }; - if (_name) result.name = _name; - return result; -}; - -µ.util.ensureArray = function(_val, _count) { - if (typeof _val === 'undefined') return null; - var arr = [].concat(_val); - return d3.range(_count).map(function(d, i) { - return arr[i] || arr[0]; - }); -}; - -µ.util.fillArrays = function(_obj, _valueNames, _count) { - _valueNames.forEach(function(d, i) { - _obj[d] = µ.util.ensureArray(_obj[d], _count); - }); - return _obj; -}; - -µ.util.cloneJson = function(json) { - return JSON.parse(JSON.stringify(json)); -}; - -µ.util.validateKeys = function(obj, keys) { - if (typeof keys === 'string') keys = keys.split('.'); - var next = keys.shift(); - return obj[next] && (!keys.length || objHasKeys(obj[next], keys)); -}; - -µ.util.sumArrays = function(a, b) { - return d3.zip(a, b).map(function(d, i) { - return d3.sum(d); - }); -}; - -µ.util.arrayLast = function(a) { - return a[a.length - 1]; -}; - -µ.util.arrayEqual = function(a, b) { - var i = Math.max(a.length, b.length, 1); - while (i-- >= 0 && a[i] === b[i]) ; - return i === -2; -}; - -µ.util.flattenArray = function(arr) { - var r = []; - while (!µ.util.arrayEqual(r, arr)) { - r = arr; - arr = [].concat.apply([], arr); - } - return arr; -}; - -µ.util.deduplicate = function(arr) { - return arr.filter(function(v, i, a) { - return a.indexOf(v) == i; - }); -}; - -µ.util.convertToCartesian = function(radius, theta) { - var thetaRadians = theta * Math.PI / 180; - var x = radius * Math.cos(thetaRadians); - var y = radius * Math.sin(thetaRadians); - return [ x, y ]; -}; - -µ.util.round = function(_value, _digits) { - var digits = _digits || 2; - var mult = Math.pow(10, digits); - return Math.round(_value * mult) / mult; -}; - -µ.util.getMousePos = function(_referenceElement) { - var mousePos = d3.mouse(_referenceElement.node()); - var mouseX = mousePos[0]; - var mouseY = mousePos[1]; - var mouse = {}; - mouse.x = mouseX; - mouse.y = mouseY; - mouse.pos = mousePos; - mouse.angle = (Math.atan2(mouseY, mouseX) + Math.PI) * 180 / Math.PI; - mouse.radius = Math.sqrt(mouseX * mouseX + mouseY * mouseY); - return mouse; -}; - -µ.util.duplicatesCount = function(arr) { - var uniques = {}, val; - var dups = {}; - for (var i = 0, len = arr.length; i < len; i++) { - val = arr[i]; - if (val in uniques) { - uniques[val]++; - dups[val] = uniques[val]; - } else { - uniques[val] = 1; - } - } - return dups; -}; - -µ.util.duplicates = function(arr) { - return Object.keys(µ.util.duplicatesCount(arr)); -}; - -µ.util.translator = function(obj, sourceBranch, targetBranch, reverse) { - if (reverse) { - var targetBranchCopy = targetBranch.slice(); - targetBranch = sourceBranch; - sourceBranch = targetBranchCopy; - } - var value = sourceBranch.reduce(function(previousValue, currentValue) { - if (typeof previousValue != 'undefined') return previousValue[currentValue]; - }, obj); - if (typeof value === 'undefined') return; - sourceBranch.reduce(function(previousValue, currentValue, index) { - if (typeof previousValue == 'undefined') return; - if (index === sourceBranch.length - 1) delete previousValue[currentValue]; - return previousValue[currentValue]; - }, obj); - targetBranch.reduce(function(previousValue, currentValue, index) { - if (typeof previousValue[currentValue] === 'undefined') previousValue[currentValue] = {}; - if (index === targetBranch.length - 1) previousValue[currentValue] = value; - return previousValue[currentValue]; - }, obj); -}; - -µ.PolyChart = function module() { - var config = [ µ.PolyChart.defaultConfig() ]; - var dispatch = d3.dispatch('hover'); - var dashArray = { - solid: 'none', - dash: [ 5, 2 ], - dot: [ 2, 5 ] - }; - var colorScale; - function exports() { - var geometryConfig = config[0].geometryConfig; - var container = geometryConfig.container; - if (typeof container == 'string') container = d3.select(container); - container.datum(config).each(function(_config, _index) { - var isStack = !!_config[0].data.yStack; - var data = _config.map(function(d, i) { - if (isStack) return d3.zip(d.data.t[0], d.data.r[0], d.data.yStack[0]); else return d3.zip(d.data.t[0], d.data.r[0]); - }); - var angularScale = geometryConfig.angularScale; - var domainMin = geometryConfig.radialScale.domain()[0]; - var generator = {}; - generator.bar = function(d, i, pI) { - var dataConfig = _config[pI].data; - var h = geometryConfig.radialScale(d[1]) - geometryConfig.radialScale(0); - var stackTop = geometryConfig.radialScale(d[2] || 0); - var w = dataConfig.barWidth; - d3.select(this).attr({ - 'class': 'mark bar', - d: 'M' + [ [ h + stackTop, -w / 2 ], [ h + stackTop, w / 2 ], [ stackTop, w / 2 ], [ stackTop, -w / 2 ] ].join('L') + 'Z', - transform: function(d, i) { - return 'rotate(' + (geometryConfig.orientation + angularScale(d[0])) + ')'; - } - }); - }; - generator.dot = function(d, i, pI) { - var stackedData = d[2] ? [ d[0], d[1] + d[2] ] : d; - var symbol = d3.svg.symbol().size(_config[pI].data.dotSize).type(_config[pI].data.dotType)(d, i); - d3.select(this).attr({ - 'class': 'mark dot', - d: symbol, - transform: function(d, i) { - var coord = convertToCartesian(getPolarCoordinates(stackedData)); - return 'translate(' + [ coord.x, coord.y ] + ')'; - } - }); - }; - var line = d3.svg.line.radial().interpolate(_config[0].data.lineInterpolation).radius(function(d) { - return geometryConfig.radialScale(d[1]); - }).angle(function(d) { - return geometryConfig.angularScale(d[0]) * Math.PI / 180; - }); - generator.line = function(d, i, pI) { - var lineData = d[2] ? data[pI].map(function(d, i) { - return [ d[0], d[1] + d[2] ]; - }) : data[pI]; - d3.select(this).each(generator['dot']).style({ - opacity: function(dB, iB) { - return +_config[pI].data.dotVisible; - }, - fill: markStyle.stroke(d, i, pI) - }).attr({ - 'class': 'mark dot' - }); - if (i > 0) return; - var lineSelection = d3.select(this.parentNode).selectAll('path.line').data([ 0 ]); - lineSelection.enter().insert('path'); - lineSelection.attr({ - 'class': 'line', - d: line(lineData), - transform: function(dB, iB) { - return 'rotate(' + (geometryConfig.orientation + 90) + ')'; - }, - 'pointer-events': 'none' - }).style({ - fill: function(dB, iB) { - return markStyle.fill(d, i, pI); - }, - 'fill-opacity': 0, - stroke: function(dB, iB) { - return markStyle.stroke(d, i, pI); - }, - 'stroke-width': function(dB, iB) { - return markStyle['stroke-width'](d, i, pI); - }, - 'stroke-dasharray': function(dB, iB) { - return markStyle['stroke-dasharray'](d, i, pI); - }, - opacity: function(dB, iB) { - return markStyle.opacity(d, i, pI); - }, - display: function(dB, iB) { - return markStyle.display(d, i, pI); - } - }); - }; - var angularRange = geometryConfig.angularScale.range(); - var triangleAngle = Math.abs(angularRange[1] - angularRange[0]) / data[0].length * Math.PI / 180; - var arc = d3.svg.arc().startAngle(function(d) { - return -triangleAngle / 2; - }).endAngle(function(d) { - return triangleAngle / 2; - }).innerRadius(function(d) { - return geometryConfig.radialScale(domainMin + (d[2] || 0)); - }).outerRadius(function(d) { - return geometryConfig.radialScale(domainMin + (d[2] || 0)) + geometryConfig.radialScale(d[1]); - }); - generator.arc = function(d, i, pI) { - d3.select(this).attr({ - 'class': 'mark arc', - d: arc, - transform: function(d, i) { - return 'rotate(' + (geometryConfig.orientation + angularScale(d[0]) + 90) + ')'; - } - }); - }; - var markStyle = { - fill: function(d, i, pI) { - return _config[pI].data.color; - }, - stroke: function(d, i, pI) { - return _config[pI].data.strokeColor; - }, - 'stroke-width': function(d, i, pI) { - return _config[pI].data.strokeSize + 'px'; - }, - 'stroke-dasharray': function(d, i, pI) { - return dashArray[_config[pI].data.strokeDash]; - }, - opacity: function(d, i, pI) { - return _config[pI].data.opacity; - }, - display: function(d, i, pI) { - return typeof _config[pI].data.visible === 'undefined' || _config[pI].data.visible ? 'block' : 'none'; - } - }; - var geometryLayer = d3.select(this).selectAll('g.layer').data(data); - geometryLayer.enter().append('g').attr({ - 'class': 'layer' - }); - var geometry = geometryLayer.selectAll('path.mark').data(function(d, i) { - return d; - }); - geometry.enter().append('path').attr({ - 'class': 'mark' - }); - geometry.style(markStyle).each(generator[geometryConfig.geometryType]); - geometry.exit().remove(); - geometryLayer.exit().remove(); - function getPolarCoordinates(d, i) { - var r = geometryConfig.radialScale(d[1]); - var t = (geometryConfig.angularScale(d[0]) + geometryConfig.orientation) * Math.PI / 180; - return { - r: r, - t: t - }; - } - function convertToCartesian(polarCoordinates) { - var x = polarCoordinates.r * Math.cos(polarCoordinates.t); - var y = polarCoordinates.r * Math.sin(polarCoordinates.t); - return { - x: x, - y: y - }; - } - }); - } - exports.config = function(_x) { - if (!arguments.length) return config; - _x.forEach(function(d, i) { - if (!config[i]) config[i] = {}; - extendDeepAll(config[i], µ.PolyChart.defaultConfig()); - extendDeepAll(config[i], d); - }); - return this; - }; - exports.getColorScale = function() { - return colorScale; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.PolyChart.defaultConfig = function() { - var config = { - data: { - name: 'geom1', - t: [ [ 1, 2, 3, 4 ] ], - r: [ [ 1, 2, 3, 4 ] ], - dotType: 'circle', - dotSize: 64, - dotVisible: false, - barWidth: 20, - color: '#ffa500', - strokeSize: 1, - strokeColor: 'silver', - strokeDash: 'solid', - opacity: 1, - index: 0, - visible: true, - visibleInLegend: true - }, - geometryConfig: { - geometry: 'LinePlot', - geometryType: 'arc', - direction: 'clockwise', - orientation: 0, - container: 'body', - radialScale: null, - angularScale: null, - colorScale: d3.scale.category20() - } - }; - return config; -}; - -µ.BarChart = function module() { - return µ.PolyChart(); -}; - -µ.BarChart.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'bar' - } - }; - return config; -}; - -µ.AreaChart = function module() { - return µ.PolyChart(); -}; - -µ.AreaChart.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'arc' - } - }; - return config; -}; - -µ.DotPlot = function module() { - return µ.PolyChart(); -}; - -µ.DotPlot.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'dot', - dotType: 'circle' - } - }; - return config; -}; - -µ.LinePlot = function module() { - return µ.PolyChart(); -}; - -µ.LinePlot.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'line' - } - }; - return config; -}; - -µ.Legend = function module() { - var config = µ.Legend.defaultConfig(); - var dispatch = d3.dispatch('hover'); - function exports() { - var legendConfig = config.legendConfig; - var flattenData = config.data.map(function(d, i) { - return [].concat(d).map(function(dB, iB) { - var element = extendDeepAll({}, legendConfig.elements[i]); - element.name = dB; - element.color = [].concat(legendConfig.elements[i].color)[iB]; - return element; - }); - }); - var data = d3.merge(flattenData); - data = data.filter(function(d, i) { - return legendConfig.elements[i] && (legendConfig.elements[i].visibleInLegend || typeof legendConfig.elements[i].visibleInLegend === 'undefined'); - }); - if (legendConfig.reverseOrder) data = data.reverse(); - var container = legendConfig.container; - if (typeof container == 'string' || container.nodeName) container = d3.select(container); - var colors = data.map(function(d, i) { - return d.color; - }); - var lineHeight = legendConfig.fontSize; - var isContinuous = legendConfig.isContinuous == null ? typeof data[0] === 'number' : legendConfig.isContinuous; - var height = isContinuous ? legendConfig.height : lineHeight * data.length; - var legendContainerGroup = container.classed('legend-group', true); - var svg = legendContainerGroup.selectAll('svg').data([ 0 ]); - var svgEnter = svg.enter().append('svg').attr({ - width: 300, - height: height + lineHeight, - xmlns: 'http://www.w3.org/2000/svg', - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', - version: '1.1' - }); - svgEnter.append('g').classed('legend-axis', true); - svgEnter.append('g').classed('legend-marks', true); - var dataNumbered = d3.range(data.length); - var colorScale = d3.scale[isContinuous ? 'linear' : 'ordinal']().domain(dataNumbered).range(colors); - var dataScale = d3.scale[isContinuous ? 'linear' : 'ordinal']().domain(dataNumbered)[isContinuous ? 'range' : 'rangePoints']([ 0, height ]); - var shapeGenerator = function(_type, _size) { - var squareSize = _size * 3; - if (_type === 'line') { - return 'M' + [ [ -_size / 2, -_size / 12 ], [ _size / 2, -_size / 12 ], [ _size / 2, _size / 12 ], [ -_size / 2, _size / 12 ] ] + 'Z'; - } else if (d3.svg.symbolTypes.indexOf(_type) != -1) return d3.svg.symbol().type(_type).size(squareSize)(); else return d3.svg.symbol().type('square').size(squareSize)(); - }; - if (isContinuous) { - var gradient = svg.select('.legend-marks').append('defs').append('linearGradient').attr({ - id: 'grad1', - x1: '0%', - y1: '0%', - x2: '0%', - y2: '100%' - }).selectAll('stop').data(colors); - gradient.enter().append('stop'); - gradient.attr({ - offset: function(d, i) { - return i / (colors.length - 1) * 100 + '%'; - } - }).style({ - 'stop-color': function(d, i) { - return d; - } - }); - svg.append('rect').classed('legend-mark', true).attr({ - height: legendConfig.height, - width: legendConfig.colorBandWidth, - fill: 'url(#grad1)' - }); - } else { - var legendElement = svg.select('.legend-marks').selectAll('path.legend-mark').data(data); - legendElement.enter().append('path').classed('legend-mark', true); - legendElement.attr({ - transform: function(d, i) { - return 'translate(' + [ lineHeight / 2, dataScale(i) + lineHeight / 2 ] + ')'; - }, - d: function(d, i) { - var symbolType = d.symbol; - return shapeGenerator(symbolType, lineHeight); - }, - fill: function(d, i) { - return colorScale(i); - } - }); - legendElement.exit().remove(); - } - var legendAxis = d3.svg.axis().scale(dataScale).orient('right'); - var axis = svg.select('g.legend-axis').attr({ - transform: 'translate(' + [ isContinuous ? legendConfig.colorBandWidth : lineHeight, lineHeight / 2 ] + ')' - }).call(legendAxis); - axis.selectAll('.domain').style({ - fill: 'none', - stroke: 'none' - }); - axis.selectAll('line').style({ - fill: 'none', - stroke: isContinuous ? legendConfig.textColor : 'none' - }); - axis.selectAll('text').style({ - fill: legendConfig.textColor, - 'font-size': legendConfig.fontSize - }).text(function(d, i) { - return data[i].name; - }); - return exports; - } - exports.config = function(_x) { - if (!arguments.length) return config; - extendDeepAll(config, _x); - return this; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.Legend.defaultConfig = function(d, i) { - var config = { - data: [ 'a', 'b', 'c' ], - legendConfig: { - elements: [ { - symbol: 'line', - color: 'red' - }, { - symbol: 'square', - color: 'yellow' - }, { - symbol: 'diamond', - color: 'limegreen' - } ], - height: 150, - colorBandWidth: 30, - fontSize: 12, - container: 'body', - isContinuous: null, - textColor: 'grey', - reverseOrder: false - } - }; - return config; -}; - -µ.tooltipPanel = function() { - var tooltipEl, tooltipTextEl, backgroundEl; - var config = { - container: null, - hasTick: false, - fontSize: 12, - color: 'white', - padding: 5 - }; - var id = 'tooltip-' + µ.tooltipPanel.uid++; - var tickSize = 10; - var exports = function() { - tooltipEl = config.container.selectAll('g.' + id).data([ 0 ]); - var tooltipEnter = tooltipEl.enter().append('g').classed(id, true).style({ - 'pointer-events': 'none', - display: 'none' - }); - backgroundEl = tooltipEnter.append('path').style({ - fill: 'white', - 'fill-opacity': .9 - }).attr({ - d: 'M0 0' - }); - tooltipTextEl = tooltipEnter.append('text').attr({ - dx: config.padding + tickSize, - dy: +config.fontSize * .3 - }); - return exports; - }; - exports.text = function(_text) { - var l = d3.hsl(config.color).l; - var strokeColor = l >= .5 ? '#aaa' : 'white'; - var fillColor = l >= .5 ? 'black' : 'white'; - var text = _text || ''; - tooltipTextEl.style({ - fill: fillColor, - 'font-size': config.fontSize + 'px' - }).text(text); - var padding = config.padding; - var bbox = tooltipTextEl.node().getBBox(); - var boxStyle = { - fill: config.color, - stroke: strokeColor, - 'stroke-width': '2px' - }; - var backGroundW = bbox.width + padding * 2 + tickSize; - var backGroundH = bbox.height + padding * 2; - backgroundEl.attr({ - d: 'M' + [ [ tickSize, -backGroundH / 2 ], [ tickSize, -backGroundH / 4 ], [ config.hasTick ? 0 : tickSize, 0 ], [ tickSize, backGroundH / 4 ], [ tickSize, backGroundH / 2 ], [ backGroundW, backGroundH / 2 ], [ backGroundW, -backGroundH / 2 ] ].join('L') + 'Z' - }).style(boxStyle); - tooltipEl.attr({ - transform: 'translate(' + [ tickSize, -backGroundH / 2 + padding * 2 ] + ')' - }); - tooltipEl.style({ - display: 'block' - }); - return exports; - }; - exports.move = function(_pos) { - if (!tooltipEl) return; - tooltipEl.attr({ - transform: 'translate(' + [ _pos[0], _pos[1] ] + ')' - }).style({ - display: 'block' - }); - return exports; - }; - exports.hide = function() { - if (!tooltipEl) return; - tooltipEl.style({ - display: 'none' - }); - return exports; - }; - exports.show = function() { - if (!tooltipEl) return; - tooltipEl.style({ - display: 'block' - }); - return exports; - }; - exports.config = function(_x) { - extendDeepAll(config, _x); - return exports; - }; - return exports; -}; - -µ.tooltipPanel.uid = 1; - -µ.adapter = {}; - -µ.adapter.plotly = function module() { - var exports = {}; - exports.convert = function(_inputConfig, reverse) { - var outputConfig = {}; - if (_inputConfig.data) { - outputConfig.data = _inputConfig.data.map(function(d, i) { - var r = extendDeepAll({}, d); - var toTranslate = [ - [ r, [ 'marker', 'color' ], [ 'color' ] ], - [ r, [ 'marker', 'opacity' ], [ 'opacity' ] ], - [ r, [ 'marker', 'line', 'color' ], [ 'strokeColor' ] ], - [ r, [ 'marker', 'line', 'dash' ], [ 'strokeDash' ] ], - [ r, [ 'marker', 'line', 'width' ], [ 'strokeSize' ] ], - [ r, [ 'marker', 'symbol' ], [ 'dotType' ] ], - [ r, [ 'marker', 'size' ], [ 'dotSize' ] ], - [ r, [ 'marker', 'barWidth' ], [ 'barWidth' ] ], - [ r, [ 'line', 'interpolation' ], [ 'lineInterpolation' ] ], - [ r, [ 'showlegend' ], [ 'visibleInLegend' ] ] - ]; - toTranslate.forEach(function(d, i) { - µ.util.translator.apply(null, d.concat(reverse)); - }); - - if (!reverse) delete r.marker; - if (reverse) delete r.groupId; - if (!reverse) { - if (r.type === 'scatter') { - if (r.mode === 'lines') r.geometry = 'LinePlot'; else if (r.mode === 'markers') r.geometry = 'DotPlot'; else if (r.mode === 'lines+markers') { - r.geometry = 'LinePlot'; - r.dotVisible = true; - } - } else if (r.type === 'area') r.geometry = 'AreaChart'; else if (r.type === 'bar') r.geometry = 'BarChart'; - delete r.mode; - delete r.type; - } else { - if (r.geometry === 'LinePlot') { - r.type = 'scatter'; - if (r.dotVisible === true) { - delete r.dotVisible; - r.mode = 'lines+markers'; - } else r.mode = 'lines'; - } else if (r.geometry === 'DotPlot') { - r.type = 'scatter'; - r.mode = 'markers'; - } else if (r.geometry === 'AreaChart') r.type = 'area'; else if (r.geometry === 'BarChart') r.type = 'bar'; - delete r.geometry; - } - return r; - }); - if (!reverse && _inputConfig.layout && _inputConfig.layout.barmode === 'stack') { - var duplicates = µ.util.duplicates(outputConfig.data.map(function(d, i) { - return d.geometry; - })); - outputConfig.data.forEach(function(d, i) { - var idx = duplicates.indexOf(d.geometry); - if (idx != -1) outputConfig.data[i].groupId = idx; - }); - } - } - if (_inputConfig.layout) { - var r = extendDeepAll({}, _inputConfig.layout); - var toTranslate = [ - [ r, [ 'plot_bgcolor' ], [ 'backgroundColor' ] ], - [ r, [ 'showlegend' ], [ 'showLegend' ] ], - [ r, [ 'radialaxis' ], [ 'radialAxis' ] ], - [ r, [ 'angularaxis' ], [ 'angularAxis' ] ], - [ r.angularaxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.angularaxis, [ 'showticklabels' ], [ 'labelsVisible' ] ], - [ r.angularaxis, [ 'nticks' ], [ 'ticksCount' ] ], - [ r.angularaxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.angularaxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.angularaxis, [ 'range' ], [ 'domain' ] ], - [ r.angularaxis, [ 'endpadding' ], [ 'endPadding' ] ], - [ r.radialaxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.radialaxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.radialaxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.radialaxis, [ 'range' ], [ 'domain' ] ], - [ r.angularAxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.angularAxis, [ 'showticklabels' ], [ 'labelsVisible' ] ], - [ r.angularAxis, [ 'nticks' ], [ 'ticksCount' ] ], - [ r.angularAxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.angularAxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.angularAxis, [ 'range' ], [ 'domain' ] ], - [ r.angularAxis, [ 'endpadding' ], [ 'endPadding' ] ], - [ r.radialAxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.radialAxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.radialAxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.radialAxis, [ 'range' ], [ 'domain' ] ], - [ r.font, [ 'outlinecolor' ], [ 'outlineColor' ] ], - [ r.legend, [ 'traceorder' ], [ 'reverseOrder' ] ], - [ r, [ 'labeloffset' ], [ 'labelOffset' ] ], - [ r, [ 'defaultcolorrange' ], [ 'defaultColorRange' ] ] - ]; - toTranslate.forEach(function(d, i) { - µ.util.translator.apply(null, d.concat(reverse)); - }); - - if (!reverse) { - if (r.angularAxis && typeof r.angularAxis.ticklen !== 'undefined') r.tickLength = r.angularAxis.ticklen; - if (r.angularAxis && typeof r.angularAxis.tickcolor !== 'undefined') r.tickColor = r.angularAxis.tickcolor; - } else { - if (typeof r.tickLength !== 'undefined') { - r.angularaxis.ticklen = r.tickLength; - delete r.tickLength; - } - if (r.tickColor) { - r.angularaxis.tickcolor = r.tickColor; - delete r.tickColor; - } - } - if (r.legend && typeof r.legend.reverseOrder != 'boolean') { - r.legend.reverseOrder = r.legend.reverseOrder != 'normal'; - } - if (r.legend && typeof r.legend.traceorder == 'boolean') { - r.legend.traceorder = r.legend.traceorder ? 'reversed' : 'normal'; - delete r.legend.reverseOrder; - } - if (r.margin && typeof r.margin.t != 'undefined') { - var source = [ 't', 'r', 'b', 'l', 'pad' ]; - var target = [ 'top', 'right', 'bottom', 'left', 'pad' ]; - var margin = {}; - d3.entries(r.margin).forEach(function(dB, iB) { - margin[target[source.indexOf(dB.key)]] = dB.value; - }); - r.margin = margin; - } - if (reverse) { - delete r.needsEndSpacing; - delete r.minorTickColor; - delete r.minorTicks; - delete r.angularaxis.ticksCount; - delete r.angularaxis.ticksCount; - delete r.angularaxis.ticksStep; - delete r.angularaxis.rewriteTicks; - delete r.angularaxis.nticks; - delete r.radialaxis.ticksCount; - delete r.radialaxis.ticksCount; - delete r.radialaxis.ticksStep; - delete r.radialaxis.rewriteTicks; - delete r.radialaxis.nticks; - } - outputConfig.layout = r; - } - return outputConfig; - }; - return exports; -}; diff --git a/src/plots/polar/legacy/micropolar_manager.js b/src/plots/polar/legacy/micropolar_manager.js deleted file mode 100644 index e9237025314..00000000000 --- a/src/plots/polar/legacy/micropolar_manager.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* Copyright 2012-2021, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -/* eslint-disable new-cap */ - -'use strict'; - -var d3 = require('@plotly/d3'); -var Lib = require('../../../lib'); -var Color = require('../../../components/color'); - -var micropolar = require('./micropolar'); -var UndoManager = require('./undo_manager'); -var extendDeepAll = Lib.extendDeepAll; - -var manager = module.exports = {}; - -manager.framework = function(_gd) { - var config, previousConfigClone, plot, convertedInput, container; - var undoManager = new UndoManager(); - - function exports(_inputConfig, _container) { - if(_container) container = _container; - d3.select(d3.select(container).node().parentNode).selectAll('.svg-container>*:not(.chart-root)').remove(); - - config = (!config) ? - _inputConfig : - extendDeepAll(config, _inputConfig); - - if(!plot) plot = micropolar.Axis(); - convertedInput = micropolar.adapter.plotly().convert(config); - plot.config(convertedInput).render(container); - _gd.data = config.data; - _gd.layout = config.layout; - manager.fillLayout(_gd); - return config; - } - exports.isPolar = true; - exports.svg = function() { return plot.svg(); }; - exports.getConfig = function() { return config; }; - exports.getLiveConfig = function() { - return micropolar.adapter.plotly().convert(plot.getLiveConfig(), true); - }; - exports.getLiveScales = function() { return {t: plot.angularScale(), r: plot.radialScale()}; }; - exports.setUndoPoint = function() { - var that = this; - var configClone = micropolar.util.cloneJson(config); - (function(_configClone, _previousConfigClone) { - undoManager.add({ - undo: function() { - if(_previousConfigClone) that(_previousConfigClone); - }, - redo: function() { - that(_configClone); - } - }); - })(configClone, previousConfigClone); - previousConfigClone = micropolar.util.cloneJson(configClone); - }; - exports.undo = function() { undoManager.undo(); }; - exports.redo = function() { undoManager.redo(); }; - return exports; -}; - -manager.fillLayout = function(_gd) { - var container = d3.select(_gd).selectAll('.plot-container'); - var paperDiv = container.selectAll('.svg-container'); - var paper = _gd.framework && _gd.framework.svg && _gd.framework.svg(); - var dflts = { - width: 800, - height: 600, - paper_bgcolor: Color.background, - _container: container, - _paperdiv: paperDiv, - _paper: paper - }; - - _gd._fullLayout = extendDeepAll(dflts, _gd.layout); -}; diff --git a/src/plots/polar/legacy/undo_manager.js b/src/plots/polar/legacy/undo_manager.js deleted file mode 100644 index 36dadb4eafe..00000000000 --- a/src/plots/polar/legacy/undo_manager.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* Copyright 2012-2021, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -// Modified from https://github.com/ArthurClemens/Javascript-Undo-Manager -// Copyright (c) 2010-2013 Arthur Clemens, arthur@visiblearea.com -module.exports = function UndoManager() { - var undoCommands = []; - var index = -1; - var isExecuting = false; - var callback; - - function execute(command, action) { - if(!command) return this; - - isExecuting = true; - command[action](); - isExecuting = false; - - return this; - } - - return { - add: function(command) { - if(isExecuting) return this; - undoCommands.splice(index + 1, undoCommands.length - index); - undoCommands.push(command); - index = undoCommands.length - 1; - return this; - }, - setCallback: function(callbackFunc) { callback = callbackFunc; }, - undo: function() { - var command = undoCommands[index]; - if(!command) return this; - execute(command, 'undo'); - index -= 1; - if(callback) callback(command.undo); - return this; - }, - redo: function() { - var command = undoCommands[index + 1]; - if(!command) return this; - execute(command, 'redo'); - index += 1; - if(callback) callback(command.redo); - return this; - }, - clear: function() { - undoCommands = []; - index = -1; - }, - hasUndo: function() { return index !== -1; }, - hasRedo: function() { return index < (undoCommands.length - 1); }, - getCommands: function() { return undoCommands; }, - getPreviousCommand: function() { return undoCommands[index - 1]; }, - getIndex: function() { return index; } - }; -}; diff --git a/src/registry.js b/src/registry.js index 2040ab98890..f3b0feb2477 100644 --- a/src/registry.js +++ b/src/registry.js @@ -144,7 +144,7 @@ exports.traceIs = function(traceType, category) { var _module = exports.modules[traceType]; if(!_module) { - if(traceType && traceType !== 'area') { + if(traceType) { Loggers.log('Unrecognized trace type ' + traceType + '.'); } diff --git a/src/snapshot/helpers.js b/src/snapshot/helpers.js index 75b9326c571..ede584c7e06 100644 --- a/src/snapshot/helpers.js +++ b/src/snapshot/helpers.js @@ -22,13 +22,7 @@ exports.getDelay = function(fullLayout) { exports.getRedrawFunc = function(gd) { return function() { - var fullLayout = gd._fullLayout || {}; - var hasPolar = fullLayout._has && fullLayout._has('polar'); - var hasLegacyPolar = !hasPolar && gd.data && gd.data[0] && gd.data[0].r; - - if(!hasLegacyPolar) { - Registry.getComponentMethod('colorbar', 'draw')(gd); - } + Registry.getComponentMethod('colorbar', 'draw')(gd); }; }; diff --git a/src/traces/scatter/attributes.js b/src/traces/scatter/attributes.js index 7927a13ee7f..7792e7cf046 100644 --- a/src/traces/scatter/attributes.js +++ b/src/traces/scatter/attributes.js @@ -611,25 +611,4 @@ module.exports = { arrayOk: true, description: 'Sets the text font.' }), - - r: { - valType: 'data_array', - editType: 'calc', - description: [ - 'r coordinates in scatter traces are deprecated!', - 'Please switch to the *scatterpolar* trace type.', - 'Sets the radial coordinates', - 'for legacy polar chart only.' - ].join('') - }, - t: { - valType: 'data_array', - editType: 'calc', - description: [ - 't coordinates in scatter traces are deprecated!', - 'Please switch to the *scatterpolar* trace type.', - 'Sets the angular coordinates', - 'for legacy polar chart only.' - ].join('') - } }; diff --git a/test/image/baselines/6.png b/test/image/baselines/6.png deleted file mode 100644 index e05e5738fa5..00000000000 Binary files a/test/image/baselines/6.png and /dev/null differ diff --git a/test/image/baselines/7.png b/test/image/baselines/7.png deleted file mode 100644 index f223320669d..00000000000 Binary files a/test/image/baselines/7.png and /dev/null differ diff --git a/test/image/baselines/8.png b/test/image/baselines/8.png deleted file mode 100644 index 42556fb16e4..00000000000 Binary files a/test/image/baselines/8.png and /dev/null differ diff --git a/test/image/baselines/polar_area_chart.png b/test/image/baselines/polar_area_chart.png deleted file mode 100644 index 948febef78e..00000000000 Binary files a/test/image/baselines/polar_area_chart.png and /dev/null differ diff --git a/test/image/mocks/6.json b/test/image/mocks/6.json deleted file mode 100644 index e1ca4892762..00000000000 --- a/test/image/mocks/6.json +++ /dev/null @@ -1,713 +0,0 @@ -{ - "data": [ - { - "r": [ - 1, - 0.995, - 0.978, - 0.951, - 0.914, - 0.866, - 0.809, - 0.743, - 0.669, - 0.588, - 0.5, - 0.407, - 0.309, - 0.208, - 0.105, - 0, - 0.105, - 0.208, - 0.309, - 0.407, - 0.5, - 0.588, - 0.669, - 0.743, - 0.809, - 0.866, - 0.914, - 0.951, - 0.978, - 0.995, - 1, - 0.995, - 0.978, - 0.951, - 0.914, - 0.866, - 0.809, - 0.743, - 0.669, - 0.588, - 0.5, - 0.407, - 0.309, - 0.208, - 0.105, - 0, - 0.105, - 0.208, - 0.309, - 0.407, - 0.5, - 0.588, - 0.669, - 0.743, - 0.809, - 0.866, - 0.914, - 0.951, - 0.978, - 0.995, - 1 - ], - "t": [ - 0, - 6, - 12, - 18, - 24, - 30, - 36, - 42, - 48, - 54, - 60, - 66, - 72, - 78, - 84, - 90, - 96, - 102, - 108, - 114, - 120, - 126, - 132, - 138, - 144, - 150, - 156, - 162, - 168, - 174, - 180, - 186, - 192, - 198, - 204, - 210, - 216, - 222, - 228, - 234, - 240, - 246, - 252, - 258, - 264, - 270, - 276, - 282, - 288, - 294, - 300, - 306, - 312, - 318, - 324, - 330, - 336, - 342, - 348, - 354, - 360 - ], - "mode": "lines", - "name": "Figure8", - "marker": { - "color": "none", - "line": { - "color": "peru" - } - }, - "type": "scatter" - }, - { - "r": [ - 1, - 0.997, - 0.989, - 0.976, - 0.957, - 0.933, - 0.905, - 0.872, - 0.835, - 0.794, - 0.75, - 0.703, - 0.655, - 0.604, - 0.552, - 0.5, - 0.448, - 0.396, - 0.345, - 0.297, - 0.25, - 0.206, - 0.165, - 0.128, - 0.095, - 0.067, - 0.043, - 0.024, - 0.011, - 0.003, - 0, - 0.003, - 0.011, - 0.024, - 0.043, - 0.067, - 0.095, - 0.128, - 0.165, - 0.206, - 0.25, - 0.297, - 0.345, - 0.396, - 0.448, - 0.5, - 0.552, - 0.604, - 0.655, - 0.703, - 0.75, - 0.794, - 0.835, - 0.872, - 0.905, - 0.933, - 0.957, - 0.976, - 0.989, - 0.997, - 1 - ], - "t": [ - 0, - 6, - 12, - 18, - 24, - 30, - 36, - 42, - 48, - 54, - 60, - 66, - 72, - 78, - 84, - 90, - 96, - 102, - 108, - 114, - 120, - 126, - 132, - 138, - 144, - 150, - 156, - 162, - 168, - 174, - 180, - 186, - 192, - 198, - 204, - 210, - 216, - 222, - 228, - 234, - 240, - 246, - 252, - 258, - 264, - 270, - 276, - 282, - 288, - 294, - 300, - 306, - 312, - 318, - 324, - 330, - 336, - 342, - 348, - 354, - 360 - ], - "mode": "lines", - "name": "Cardioid", - "marker": { - "color": "none", - "line": { - "color": "darkviolet" - } - }, - "type": "scatter" - }, - { - "r": [ - 1, - 0.996, - 0.984, - 0.963, - 0.935, - 0.9, - 0.857, - 0.807, - 0.752, - 0.691, - 0.625, - 0.555, - 0.482, - 0.406, - 0.328, - 0.25, - 0.172, - 0.094, - 0.018, - 0.055, - 0.125, - 0.191, - 0.252, - 0.307, - 0.357, - 0.4, - 0.435, - 0.463, - 0.484, - 0.496, - 0.5, - 0.496, - 0.484, - 0.463, - 0.435, - 0.4, - 0.357, - 0.307, - 0.252, - 0.191, - 0.125, - 0.055, - 0.018, - 0.094, - 0.172, - 0.25, - 0.328, - 0.406, - 0.482, - 0.555, - 0.625, - 0.691, - 0.752, - 0.807, - 0.857, - 0.9, - 0.935, - 0.963, - 0.984, - 0.996, - 1 - ], - "t": [ - 0, - 6, - 12, - 18, - 24, - 30, - 36, - 42, - 48, - 54, - 60, - 66, - 72, - 78, - 84, - 90, - 96, - 102, - 108, - 114, - 120, - 126, - 132, - 138, - 144, - 150, - 156, - 162, - 168, - 174, - 180, - 186, - 192, - 198, - 204, - 210, - 216, - 222, - 228, - 234, - 240, - 246, - 252, - 258, - 264, - 270, - 276, - 282, - 288, - 294, - 300, - 306, - 312, - 318, - 324, - 330, - 336, - 342, - 348, - 354, - 360 - ], - "mode": "lines", - "name": "Hypercardioid", - "marker": { - "color": "none", - "line": { - "color": "deepskyblue" - } - }, - "type": "scatter" - }, - { - "r": [ - 1, - 0.998, - 0.993, - 0.985, - 0.974, - 0.96, - 0.943, - 0.923, - 0.901, - 0.876, - 0.85, - 0.822, - 0.793, - 0.762, - 0.731, - 0.7, - 0.669, - 0.638, - 0.607, - 0.578, - 0.55, - 0.524, - 0.499, - 0.477, - 0.457, - 0.44, - 0.426, - 0.415, - 0.407, - 0.402, - 0.4, - 0.402, - 0.407, - 0.415, - 0.426, - 0.44, - 0.457, - 0.477, - 0.499, - 0.524, - 0.55, - 0.578, - 0.607, - 0.638, - 0.669, - 0.7, - 0.731, - 0.762, - 0.793, - 0.822, - 0.85, - 0.876, - 0.901, - 0.923, - 0.943, - 0.96, - 0.974, - 0.985, - 0.993, - 0.998, - 1 - ], - "t": [ - 0, - 6, - 12, - 18, - 24, - 30, - 36, - 42, - 48, - 54, - 60, - 66, - 72, - 78, - 84, - 90, - 96, - 102, - 108, - 114, - 120, - 126, - 132, - 138, - 144, - 150, - 156, - 162, - 168, - 174, - 180, - 186, - 192, - 198, - 204, - 210, - 216, - 222, - 228, - 234, - 240, - 246, - 252, - 258, - 264, - 270, - 276, - 282, - 288, - 294, - 300, - 306, - 312, - 318, - 324, - 330, - 336, - 342, - 348, - 354, - 360 - ], - "mode": "lines", - "name": "Subcardioid", - "marker": { - "color": "none", - "line": { - "color": "orangered" - } - }, - "type": "scatter" - }, - { - "r": [ - 1, - 0.997, - 0.986, - 0.969, - 0.946, - 0.916, - 0.88, - 0.838, - 0.792, - 0.74, - 0.685, - 0.626, - 0.565, - 0.501, - 0.436, - 0.37, - 0.304, - 0.239, - 0.175, - 0.114, - 0.055, - 0, - 0.052, - 0.098, - 0.14, - 0.176, - 0.206, - 0.229, - 0.246, - 0.257, - 0.26, - 0.257, - 0.246, - 0.229, - 0.206, - 0.176, - 0.14, - 0.098, - 0.052, - 0, - 0.055, - 0.114, - 0.175, - 0.239, - 0.304, - 0.37, - 0.436, - 0.501, - 0.565, - 0.626, - 0.685, - 0.74, - 0.792, - 0.838, - 0.88, - 0.916, - 0.946, - 0.969, - 0.986, - 0.997, - 1 - ], - "t": [ - 0, - 6, - 12, - 18, - 24, - 30, - 36, - 42, - 48, - 54, - 60, - 66, - 72, - 78, - 84, - 90, - 96, - 102, - 108, - 114, - 120, - 126, - 132, - 138, - 144, - 150, - 156, - 162, - 168, - 174, - 180, - 186, - 192, - 198, - 204, - 210, - 216, - 222, - 228, - 234, - 240, - 246, - 252, - 258, - 264, - 270, - 276, - 282, - 288, - 294, - 300, - 306, - 312, - 318, - 324, - 330, - 336, - 342, - 348, - 354, - 360 - ], - "mode": "lines", - "name": "Supercardioid", - "marker": { - "color": "none", - "line": { - "color": "green" - } - }, - "type": "scatter" - } - ], - "layout": { - "title": { - "text": "Mic Patterns" - }, - "font": { - "family": "Arial, sans-serif", - "size": 12, - "color": "#000" - }, - "showlegend": false, - "width": 500, - "height": 400, - "margin": { - "l": 40, - "r": 40, - "b": 20, - "t": 40, - "pad": 0 - }, - "paper_bgcolor": "#fff", - "plot_bgcolor": "#fff", - "orientation": -90, - "needsEndSpacing": false - } -} diff --git a/test/image/mocks/7.json b/test/image/mocks/7.json deleted file mode 100644 index bb645a1d167..00000000000 --- a/test/image/mocks/7.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "data": [ - { - "r": [ - 85, - 22, - 12, - 10, - 84, - 24, - 97, - 57 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "Layer0", - "type": "area" - }, - { - "r": [ - 6, - 66, - 46, - 86, - 86, - 85, - 55, - 2 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "Layer1", - "type": "area" - }, - { - "r": [ - 89, - 46, - 17, - 19, - 65, - 65, - 75, - 44 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "Layer2", - "type": "area" - }, - { - "r": [ - 87, - 92, - 95, - 60, - 70, - 83, - 59, - 16 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "Layer3", - "type": "area" - }, - { - "r": [ - 90, - 13, - 17, - 71, - 71, - 43, - 12, - 16 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "Layer4", - "type": "area" - } - ], - "layout": { - "title": { - "text": "Polar area chart" - }, - "font": { - "family": "Arial, sans-serif", - "size": 12, - "color": "grey" - }, - "showlegend": false, - "width": 400, - "height": 400, - "margin": { - "l": 30, - "r": 30, - "b": 30, - "t": 30, - "pad": 0 - }, - "plot_bgcolor": "ghostwhite", - "barmode": "stack", - "direction": "clockwise" - } -} diff --git a/test/image/mocks/8.json b/test/image/mocks/8.json deleted file mode 100644 index ce1833c6024..00000000000 --- a/test/image/mocks/8.json +++ /dev/null @@ -1,1274 +0,0 @@ -{ - "data": [ - { - "r": [ - 1, - 1, - 1, - 1, - 1, - 1, - 0.99, - 0.98, - 0.93, - 0.84, - 0.69, - 0.52, - 0.36, - 0.24, - 0.17, - 0.12, - 0.1, - 0.1, - 0.11, - 0.14, - 0.2, - 0.3, - 0.44, - 0.61, - 0.77, - 0.89, - 0.96, - 0.99, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0.99, - 0.96, - 0.89, - 0.77, - 0.61, - 0.44, - 0.3, - 0.2, - 0.14, - 0.11, - 0.1, - 0.1, - 0.12, - 0.17, - 0.24, - 0.36, - 0.52, - 0.69, - 0.84, - 0.93, - 0.98, - 0.99, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0.99, - 0.98, - 0.93, - 0.84, - 0.69, - 0.52, - 0.36, - 0.24, - 0.17, - 0.12, - 0.1, - 0.1, - 0.11, - 0.14, - 0.2, - 0.3, - 0.44, - 0.61, - 0.77, - 0.89, - 0.96, - 0.99, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0.99, - 0.96, - 0.89, - 0.77, - 0.61, - 0.44, - 0.3, - 0.2, - 0.14, - 0.11, - 0.1, - 0.1, - 0.12, - 0.17, - 0.24, - 0.36, - 0.52, - 0.69, - 0.84, - 0.93, - 0.98, - 0.99, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0.99, - 0.98, - 0.93, - 0.84, - 0.69, - 0.52, - 0.36, - 0.24, - 0.17, - 0.12, - 0.1, - 0.1, - 0.11, - 0.14, - 0.2, - 0.3, - 0.44, - 0.61, - 0.77, - 0.89, - 0.96, - 0.99, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0.99, - 0.96, - 0.89, - 0.77, - 0.61, - 0.44, - 0.3, - 0.2, - 0.14, - 0.11, - 0.1, - 0.1, - 0.12, - 0.17, - 0.24, - 0.36, - 0.52, - 0.69, - 0.84, - 0.93, - 0.98, - 0.99, - 1, - 1, - 1, - 1, - 1 - ], - "t": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - 154, - 155, - 156, - 157, - 158, - 159, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - 184, - 185, - 186, - 187, - 188, - 189, - 190, - 191, - 192, - 193, - 194, - 195, - 196, - 197, - 198, - 199, - 200 - ], - "mode": "markers", - "name": "m:12, n1:.3, n2:0, n3:10", - "marker": { - "color": "orange", - "size": 16 - }, - "type": "scatter" - }, - { - "r": [ - 0.75, - 0.99, - 0.65, - 0.47, - 0.38, - 0.35, - 0.36, - 0.41, - 0.53, - 0.78, - 0.92, - 0.66, - 0.51, - 0.43, - 0.38, - 0.36, - 0.35, - 0.36, - 0.39, - 0.45, - 0.54, - 0.71, - 0.99, - 0.69, - 0.49, - 0.39, - 0.35, - 0.36, - 0.4, - 0.51, - 0.73, - 0.97, - 0.69, - 0.53, - 0.44, - 0.39, - 0.36, - 0.35, - 0.36, - 0.38, - 0.44, - 0.53, - 0.68, - 0.95, - 0.74, - 0.51, - 0.4, - 0.36, - 0.35, - 0.39, - 0.48, - 0.68, - 1, - 0.72, - 0.55, - 0.45, - 0.39, - 0.36, - 0.35, - 0.36, - 0.38, - 0.43, - 0.51, - 0.65, - 0.9, - 0.8, - 0.54, - 0.42, - 0.36, - 0.35, - 0.38, - 0.46, - 0.64, - 0.98, - 0.76, - 0.57, - 0.46, - 0.4, - 0.37, - 0.35, - 0.35, - 0.37, - 0.42, - 0.49, - 0.62, - 0.85, - 0.86, - 0.57, - 0.43, - 0.37, - 0.35, - 0.37, - 0.45, - 0.6, - 0.92, - 0.8, - 0.6, - 0.48, - 0.41, - 0.37, - 0.35, - 0.35, - 0.37, - 0.41, - 0.48, - 0.6, - 0.8, - 0.92, - 0.6, - 0.45, - 0.37, - 0.35, - 0.37, - 0.43, - 0.57, - 0.86, - 0.85, - 0.62, - 0.49, - 0.42, - 0.37, - 0.35, - 0.35, - 0.37, - 0.4, - 0.46, - 0.57, - 0.76, - 0.98, - 0.64, - 0.46, - 0.38, - 0.35, - 0.36, - 0.42, - 0.54, - 0.8, - 0.9, - 0.65, - 0.51, - 0.43, - 0.38, - 0.36, - 0.35, - 0.36, - 0.39, - 0.45, - 0.55, - 0.72, - 1, - 0.68, - 0.48, - 0.39, - 0.35, - 0.36, - 0.4, - 0.51, - 0.74, - 0.95, - 0.68, - 0.53, - 0.44, - 0.38, - 0.36, - 0.35, - 0.36, - 0.39, - 0.44, - 0.53, - 0.69, - 0.97, - 0.73, - 0.51, - 0.4, - 0.36, - 0.35, - 0.39, - 0.49, - 0.69, - 0.99, - 0.71, - 0.54, - 0.45, - 0.39, - 0.36, - 0.35, - 0.36, - 0.38, - 0.43, - 0.51, - 0.66, - 0.92, - 0.78, - 0.53, - 0.41, - 0.36, - 0.35, - 0.38, - 0.47, - 0.65, - 0.99 - ], - "t": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - 154, - 155, - 156, - 157, - 158, - 159, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - 184, - 185, - 186, - 187, - 188, - 189, - 190, - 191, - 192, - 193, - 194, - 195, - 196, - 197, - 198, - 199, - 200 - ], - "mode": "markers", - "name": "m:19, n1:100, n2:50, n3:50", - "marker": { - "color": "skyblue", - "line": { - "color": "none" - } - }, - "opacity": 0.5, - "type": "scatter" - }, - { - "r": [ - 1, - 0.99, - 0.95, - 0.9, - 0.84, - 0.78, - 0.72, - 0.67, - 0.63, - 0.59, - 0.56, - 0.53, - 0.5, - 0.48, - 0.46, - 0.45, - 0.44, - 0.43, - 0.43, - 0.42, - 0.42, - 0.42, - 0.42, - 0.43, - 0.44, - 0.45, - 0.46, - 0.48, - 0.5, - 0.52, - 0.55, - 0.58, - 0.62, - 0.66, - 0.71, - 0.77, - 0.83, - 0.89, - 0.94, - 0.98, - 1, - 0.99, - 0.96, - 0.91, - 0.85, - 0.79, - 0.74, - 0.68, - 0.64, - 0.6, - 0.56, - 0.53, - 0.51, - 0.49, - 0.47, - 0.45, - 0.44, - 0.43, - 0.43, - 0.42, - 0.42, - 0.42, - 0.42, - 0.43, - 0.44, - 0.45, - 0.46, - 0.47, - 0.49, - 0.52, - 0.54, - 0.58, - 0.61, - 0.65, - 0.7, - 0.76, - 0.82, - 0.88, - 0.93, - 0.97, - 1, - 1, - 0.97, - 0.92, - 0.86, - 0.8, - 0.75, - 0.69, - 0.65, - 0.6, - 0.57, - 0.54, - 0.51, - 0.49, - 0.47, - 0.46, - 0.44, - 0.43, - 0.43, - 0.42, - 0.42, - 0.42, - 0.42, - 0.43, - 0.43, - 0.44, - 0.46, - 0.47, - 0.49, - 0.51, - 0.54, - 0.57, - 0.6, - 0.65, - 0.69, - 0.75, - 0.8, - 0.86, - 0.92, - 0.97, - 1, - 1, - 0.97, - 0.93, - 0.88, - 0.82, - 0.76, - 0.7, - 0.65, - 0.61, - 0.58, - 0.54, - 0.52, - 0.49, - 0.47, - 0.46, - 0.45, - 0.44, - 0.43, - 0.42, - 0.42, - 0.42, - 0.42, - 0.43, - 0.43, - 0.44, - 0.45, - 0.47, - 0.49, - 0.51, - 0.53, - 0.56, - 0.6, - 0.64, - 0.68, - 0.74, - 0.79, - 0.85, - 0.91, - 0.96, - 0.99, - 1, - 0.98, - 0.94, - 0.89, - 0.83, - 0.77, - 0.71, - 0.66, - 0.62, - 0.58, - 0.55, - 0.52, - 0.5, - 0.48, - 0.46, - 0.45, - 0.44, - 0.43, - 0.42, - 0.42, - 0.42, - 0.42, - 0.43, - 0.43, - 0.44, - 0.45, - 0.46, - 0.48, - 0.5, - 0.53, - 0.56, - 0.59, - 0.63, - 0.67, - 0.72, - 0.78, - 0.84, - 0.9, - 0.95, - 0.99 - ], - "t": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - 154, - 155, - 156, - 157, - 158, - 159, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - 184, - 185, - 186, - 187, - 188, - 189, - 190, - 191, - 192, - 193, - 194, - 195, - 196, - 197, - 198, - 199, - 200 - ], - "mode": "markers", - "name": "m:5, n1:2, n2:7, n3:7", - "marker": { - "color": "lime" - }, - "opacity": 0.8, - "type": "scatter" - } - ], - "layout": { - "title": { - "text": "Superformula" - }, - "font": { - "family": "Arial, sans-serif", - "size": 12, - "color": "grey" - }, - "width": 500, - "height": 500, - "margin": { - "l": 20, - "r": 10, - "b": 20, - "t": 40, - "pad": 0 - }, - "showlegend": false, - "plot_bgcolor": "ghostwhite", - "needsEndSpacing": false - } -} diff --git a/test/image/mocks/polar_area_chart.json b/test/image/mocks/polar_area_chart.json deleted file mode 100644 index 366c323e57c..00000000000 --- a/test/image/mocks/polar_area_chart.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "data": [ - { - "r": [ - 77.5, - 72.5, - 70, - 45, - 22.5, - 42.5, - 40, - 62.5 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "11-14 m/s", - "marker": { - "color": "rgb(106,81,163)" - }, - "type": "area" - }, - { - "r": [ - 57.5, - 50, - 45, - 35, - 20, - 22.5, - 37.5, - 55 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "8-11 m/s", - "marker": { - "color": "rgb(158,154,200)" - }, - "type": "area" - }, - { - "r": [ - 40, - 30, - 30, - 35, - 7.5, - 7.5, - 32.5, - 40 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "5-8 m/s", - "marker": { - "color": "rgb(203,201,226)" - }, - "type": "area" - }, - { - "r": [ - 20, - 7.5, - 15, - 22.5, - 2.5, - 2.5, - 12.5, - 22.5 - ], - "t": [ - "North", - "N-E", - "East", - "S-E", - "South", - "S-W", - "West", - "N-W" - ], - "name": "< 5 m/s", - "marker": { - "color": "rgb(242,240,247)" - }, - "font": { - "family": "Arial, sans-serif", - "size": 16 - }, - "type": "area" - } - ], - "layout": { - "title": {"text": "Wind Speed Distribution in Laurel, NE"}, - "font": { - "family": "Arial, sans-serif", - "size": 16 - }, - "showlegend": false, - "radialaxis": { - "ticksuffix": "%" - }, - "orientation": 270 - } -} diff --git a/test/jasmine/bundle_tests/plotschema_test.js b/test/jasmine/bundle_tests/plotschema_test.js index 7011aa61a8e..4ac720049a0 100644 --- a/test/jasmine/bundle_tests/plotschema_test.js +++ b/test/jasmine/bundle_tests/plotschema_test.js @@ -11,7 +11,6 @@ var surface = require('@src/traces/surface'); var baseLayoutAttrs = require('@src/plots/layout_attributes'); var cartesianAttrs = require('@src/plots/cartesian').layoutAttributes; var gl3dAttrs = require('@src/plots/gl3d').layoutAttributes; -var polarLayoutAttrs = require('@src/plots/polar/legacy/axis_attributes'); var annotationAttrs = require('@src/components/annotations').layoutAttributes; var updatemenuAttrs = require('@src/components/updatemenus').layoutAttributes; var cartesianIdRegex = require('@src/plots/cartesian/constants').idRegex; @@ -466,13 +465,6 @@ describe('getTraceValObject', function() { expect(getTraceValObject({}, ['transforms', 0, 'operation'])).toBe(false); }); - it('supports polar area attributes', function() { - var areaAttrs = require('@src/plots/polar/legacy/area_attributes'); - expect(getTraceValObject({type: 'area'}, ['r'])).toBe(areaAttrs.r); - expect(getTraceValObject({type: 'area'}, ['t', 23])).toBe(areaAttrs.t); - expect(getTraceValObject({type: 'area'}, ['q'])).toBe(false); - }); - it('does not return attribute properties', function() { // it still returns the attribute itself - but maybe we should only do this // for valType: any? (or data_array/arrayOk with just an index) @@ -584,17 +576,6 @@ describe('getLayoutValObject', function() { expect(getLayoutValObject(layout3D, ['scene2k', 'bgcolor'])).toBe(false); }); - it('finds polar attributes', function() { - expect(getLayoutValObject(blankLayout, ['direction'])) - .toBe(polarLayoutAttrs.layout.direction); - - expect(getLayoutValObject(blankLayout, ['radialaxis', 'range', 0])) - .toBe(polarLayoutAttrs.radialaxis.range.items[0]); - - expect(getLayoutValObject(blankLayout, ['angularaxis', 'domain'])) - .toBe(polarLayoutAttrs.angularaxis.domain); - }); - it('lets gl2d override cartesian & global attrs', function() { var svgModule = Registry.subplotsRegistry.cartesian; var gl2dModule = Registry.subplotsRegistry.gl2d; diff --git a/test/jasmine/tests/mock_test.js b/test/jasmine/tests/mock_test.js index 2b41dcf51f2..44811150551 100644 --- a/test/jasmine/tests/mock_test.js +++ b/test/jasmine/tests/mock_test.js @@ -5,9 +5,6 @@ var list = [ '1', '4', '5', - '6', - '7', - '8', '10', '11', '12', @@ -807,7 +804,6 @@ var list = [ 'plot_types', 'point-selection', 'point-selection2', - 'polar_area_chart', 'polar_bar-overlay', 'polar_bar-stacked', 'polar_bar-width-base-offset', @@ -1097,9 +1093,6 @@ figs['0'] = require('@mocks/0'); // figs['1'] = require('@mocks/1'); figs['4'] = require('@mocks/4'); figs['5'] = require('@mocks/5'); -// figs['6'] = require('@mocks/6'); -// figs['7'] = require('@mocks/7'); -// figs['8'] = require('@mocks/8'); figs['10'] = require('@mocks/10'); // figs['11'] = require('@mocks/11'); // figs['12'] = require('@mocks/12'); @@ -1899,7 +1892,6 @@ figs['pie_title_variations'] = require('@mocks/pie_title_variations'); // figs['plot_types'] = require('@mocks/plot_types'); figs['point-selection'] = require('@mocks/point-selection'); figs['point-selection2'] = require('@mocks/point-selection2'); -// figs['polar_area_chart'] = require('@mocks/polar_area_chart'); figs['polar_bar-overlay'] = require('@mocks/polar_bar-overlay'); figs['polar_bar-stacked'] = require('@mocks/polar_bar-stacked'); figs['polar_bar-width-base-offset'] = require('@mocks/polar_bar-width-base-offset'); diff --git a/test/jasmine/tests/polar_test.js b/test/jasmine/tests/polar_test.js index 34b8eea96d0..21ac4b3f17d 100644 --- a/test/jasmine/tests/polar_test.js +++ b/test/jasmine/tests/polar_test.js @@ -17,50 +17,6 @@ var delay = require('../assets/delay'); var customAssertions = require('../assets/custom_assertions'); var assertNodeDisplay = customAssertions.assertNodeDisplay; -describe('Test legacy polar plots logs:', function() { - var gd; - - beforeEach(function() { - spyOn(Lib, 'log'); - gd = createGraphDiv(); - }); - - afterEach(destroyGraphDiv); - - var specs = [{ - name: 'legacy polar scatter traces', - data: [{ - r: [1, 2, 3], - t: [1, 2, 3] - }] - }, { - name: 'legacy polar bar traces', - data: [{ - type: 'bar', - r: [1, 2, 3], - t: [1, 2, 3] - }] - }, { - name: 'legacy area traces', - data: [{ - type: 'area', - r: [1, 2, 3], - t: [1, 2, 3] - }] - }]; - - specs.forEach(function(s) { - it('should log deprecation warning on ' + s.name, function(done) { - Plotly.newPlot(gd, s.data) - .then(function() { - expect(Lib.log).toHaveBeenCalledTimes(1); - expect(Lib.log).toHaveBeenCalledWith('Legacy polar charts are deprecated!'); - }) - .then(done, done.fail); - }); - }); -}); - describe('Test polar plots defaults:', function() { var layoutOut;