diff --git a/lib/contourgl.js b/lib/contourgl.js deleted file mode 100644 index 7bbbae74a15..00000000000 --- a/lib/contourgl.js +++ /dev/null @@ -1,11 +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'; - -module.exports = require('../src/traces/contourgl'); diff --git a/lib/index-gl2d.js b/lib/index-gl2d.js index 9f27ddf3167..a6d010cd910 100644 --- a/lib/index-gl2d.js +++ b/lib/index-gl2d.js @@ -13,9 +13,7 @@ var Plotly = require('./core'); Plotly.register([ require('./scattergl'), require('./splom'), - require('./pointcloud'), require('./heatmapgl'), - require('./contourgl'), require('./parcoords') ]); diff --git a/lib/index.js b/lib/index.js index 97e0734862f..443fa207259 100644 --- a/lib/index.js +++ b/lib/index.js @@ -44,7 +44,6 @@ Plotly.register([ require('./scattergl'), require('./splom'), - require('./pointcloud'), require('./heatmapgl'), require('./parcoords'), diff --git a/lib/pointcloud.js b/lib/pointcloud.js deleted file mode 100644 index 15d851007e8..00000000000 --- a/lib/pointcloud.js +++ /dev/null @@ -1,11 +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'; - -module.exports = require('../src/traces/pointcloud'); diff --git a/package-lock.json b/package-lock.json index 9712fe17db8..8f24af22d2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4994,102 +4994,6 @@ "resolved": "https://registry.npmjs.org/gl-constants/-/gl-constants-1.0.0.tgz", "integrity": "sha1-WXpQTjZHUP9QJTqjX43qevSl0jM=" }, - "gl-contour2d": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/gl-contour2d/-/gl-contour2d-1.1.7.tgz", - "integrity": "sha512-GdebvJ9DtT3pJDpoE+eU2q+Wo9S3MijPpPz5arZbhK85w2bARmpFpVfPaDlZqWkB644W3BlH8TVyvAo1KE4Bhw==", - "requires": { - "binary-search-bounds": "^2.0.4", - "cdt2d": "^1.0.0", - "clean-pslg": "^1.1.2", - "gl-buffer": "^2.1.2", - "gl-shader": "^4.2.1", - "glslify": "^7.0.0", - "iota-array": "^1.0.0", - "ndarray": "^1.0.18", - "surface-nets": "^1.0.2" - }, - "dependencies": { - "glslify": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/glslify/-/glslify-7.1.1.tgz", - "integrity": "sha512-bud98CJ6kGZcP9Yxcsi7Iz647wuDz3oN+IZsjCRi5X1PI7t/xPKeL0mOwXJjo+CRZMqvq0CkSJiywCcY7kVYog==", - "requires": { - "bl": "^2.2.1", - "concat-stream": "^1.5.2", - "duplexify": "^3.4.5", - "falafel": "^2.1.0", - "from2": "^2.3.0", - "glsl-resolve": "0.0.1", - "glsl-token-whitespace-trim": "^1.0.0", - "glslify-bundle": "^5.0.0", - "glslify-deps": "^1.2.5", - "minimist": "^1.2.5", - "resolve": "^1.1.5", - "stack-trace": "0.0.9", - "static-eval": "^2.0.5", - "through2": "^2.0.1", - "xtend": "^4.0.0" - } - }, - "glslify-deps": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/glslify-deps/-/glslify-deps-1.3.2.tgz", - "integrity": "sha512-7S7IkHWygJRjcawveXQjRXLO2FTjijPDYC7QfZyAQanY+yGLCFHYnPtsGT9bdyHiwPTw/5a1m1M9hamT2aBpag==", - "requires": { - "@choojs/findup": "^0.2.0", - "events": "^3.2.0", - "glsl-resolve": "0.0.1", - "glsl-tokenizer": "^2.0.0", - "graceful-fs": "^4.1.2", - "inherits": "^2.0.1", - "map-limit": "0.0.1", - "resolve": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - } - } - }, "gl-error3d": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/gl-error3d/-/gl-error3d-1.0.16.tgz", @@ -5698,97 +5602,6 @@ } } }, - "gl-pointcloud2d": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/gl-pointcloud2d/-/gl-pointcloud2d-1.0.3.tgz", - "integrity": "sha512-OS2e1irvJXVRpg/GziXj10xrFJm9kkRfFoB6BLUvkjCQV7ZRNNcs2CD+YSK1r0gvMwTg2T3lfLM3UPwNtz+4Xw==", - "requires": { - "gl-buffer": "^2.1.2", - "gl-shader": "^4.2.1", - "glslify": "^7.0.0", - "typedarray-pool": "^1.1.0" - }, - "dependencies": { - "glslify": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/glslify/-/glslify-7.1.1.tgz", - "integrity": "sha512-bud98CJ6kGZcP9Yxcsi7Iz647wuDz3oN+IZsjCRi5X1PI7t/xPKeL0mOwXJjo+CRZMqvq0CkSJiywCcY7kVYog==", - "requires": { - "bl": "^2.2.1", - "concat-stream": "^1.5.2", - "duplexify": "^3.4.5", - "falafel": "^2.1.0", - "from2": "^2.3.0", - "glsl-resolve": "0.0.1", - "glsl-token-whitespace-trim": "^1.0.0", - "glslify-bundle": "^5.0.0", - "glslify-deps": "^1.2.5", - "minimist": "^1.2.5", - "resolve": "^1.1.5", - "stack-trace": "0.0.9", - "static-eval": "^2.0.5", - "through2": "^2.0.1", - "xtend": "^4.0.0" - } - }, - "glslify-deps": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/glslify-deps/-/glslify-deps-1.3.2.tgz", - "integrity": "sha512-7S7IkHWygJRjcawveXQjRXLO2FTjijPDYC7QfZyAQanY+yGLCFHYnPtsGT9bdyHiwPTw/5a1m1M9hamT2aBpag==", - "requires": { - "@choojs/findup": "^0.2.0", - "events": "^3.2.0", - "glsl-resolve": "0.0.1", - "glsl-tokenizer": "^2.0.0", - "graceful-fs": "^4.1.2", - "inherits": "^2.0.1", - "map-limit": "0.0.1", - "resolve": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - } - } - }, "gl-quat": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gl-quat/-/gl-quat-1.0.0.tgz", diff --git a/package.json b/package.json index a5dd0e4cbe1..ad0bf2d7816 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,6 @@ "delaunay-triangulate": "^1.1.6", "fast-isnumeric": "^1.1.4", "gl-cone3d": "^1.5.2", - "gl-contour2d": "^1.1.7", "gl-error3d": "^1.0.16", "gl-heatmap2d": "^1.1.0", "gl-line3d": "1.2.1", @@ -87,7 +86,6 @@ "gl-mesh3d": "^2.3.1", "gl-plot2d": "^1.4.5", "gl-plot3d": "^2.4.7", - "gl-pointcloud2d": "^1.0.3", "gl-scatter3d": "^1.2.3", "gl-select-box": "^1.0.4", "gl-spikes2d": "^1.0.2", diff --git a/src/components/images/draw.js b/src/components/images/draw.js index 4393ad07214..61dcfe5757e 100644 --- a/src/components/images/draw.js +++ b/src/components/images/draw.js @@ -236,8 +236,8 @@ module.exports = function draw(gd) { subplot = allSubplots[i]; var subplotObj = fullLayout._plots[subplot]; - // filter out overlaid plots (which havd their images on the main plot) - // and gl2d plots (which don't support below images, at least not yet) + // filter out overlaid plots (which have their images on the main plot) + // and heatmapgl plots (which don't support below images, at least not yet) if(!subplotObj.imagelayer) continue; var imagesOnSubplot = subplotObj.imagelayer.selectAll('image') diff --git a/src/components/modebar/manage.js b/src/components/modebar/manage.js index 6743ba5aae5..264e8f0062b 100644 --- a/src/components/modebar/manage.js +++ b/src/components/modebar/manage.js @@ -89,7 +89,7 @@ function getButtonGroups(gd) { var hasGeo = fullLayout._has('geo'); var hasPie = fullLayout._has('pie'); var hasFunnelarea = fullLayout._has('funnelarea'); - var hasGL2D = fullLayout._has('gl2d'); + var hasHeatmapgl = fullLayout._has('gl2d'); var hasTernary = fullLayout._has('ternary'); var hasMapbox = fullLayout._has('mapbox'); var hasPolar = fullLayout._has('polar'); @@ -124,7 +124,7 @@ function getButtonGroups(gd) { var resetGroup = []; var dragModeGroup = []; - if((hasCartesian || hasGL2D || hasPie || hasFunnelarea || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) { + if((hasCartesian || hasHeatmapgl || hasPie || hasFunnelarea || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) { // graphs with more than one plot types get 'union buttons' // which reset the view or toggle hover labels across all subplots. hoverGroup = ['toggleHover']; @@ -140,7 +140,7 @@ function getButtonGroups(gd) { zoomGroup = ['zoomInMapbox', 'zoomOutMapbox']; hoverGroup = ['toggleHover']; resetGroup = ['resetViewMapbox']; - } else if(hasGL2D) { + } else if(hasHeatmapgl) { hoverGroup = ['hoverClosestGl2d']; } else if(hasPie) { hoverGroup = ['hoverClosestPie']; @@ -161,14 +161,14 @@ function getButtonGroups(gd) { hoverGroup = []; } - if((hasCartesian || hasGL2D) && !allAxesFixed) { + if((hasCartesian || hasHeatmapgl) && !allAxesFixed) { zoomGroup = ['zoomIn2d', 'zoomOut2d', 'autoScale2d']; if(resetGroup[0] !== 'resetViews') resetGroup = ['resetScale2d']; } if(hasGL3D) { dragModeGroup = ['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation']; - } else if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) { + } else if(((hasCartesian || hasHeatmapgl) && !allAxesFixed) || hasTernary) { dragModeGroup = ['zoom2d', 'pan2d']; } else if(hasMapbox || hasGeo) { dragModeGroup = ['pan2d']; diff --git a/src/plot_api/plot_schema.js b/src/plot_api/plot_schema.js index a67c8909f28..1fa14250aaa 100644 --- a/src/plot_api/plot_schema.js +++ b/src/plot_api/plot_schema.js @@ -332,7 +332,7 @@ function layoutHeadAttr(fullLayout, head) { _module = basePlotModules[i]; if(_module.attrRegex && _module.attrRegex.test(head)) { // if a module defines overrides, these take precedence - // initially this is to allow gl2d different editTypes from svg cartesian + // initially this was to allow heatmapgl different editTypes from svg cartesian if(_module.layoutAttrOverrides) return _module.layoutAttrOverrides; // otherwise take the first attributes we find @@ -340,7 +340,7 @@ function layoutHeadAttr(fullLayout, head) { } // a module can also override the behavior of base (and component) module layout attrs - // again see gl2d for initial use case + // again see heatmapgl for initial use case var baseOverrides = _module.baseLayoutAttrOverrides; if(baseOverrides && head in baseOverrides) return baseOverrides[head]; } diff --git a/src/plot_api/subroutines.js b/src/plot_api/subroutines.js index 334815d0595..d0b0fe6ee6e 100644 --- a/src/plot_api/subroutines.js +++ b/src/plot_api/subroutines.js @@ -68,7 +68,7 @@ function lsInner(gd) { exports.drawMainTitle(gd); ModeBar.manage(gd); - // _has('cartesian') means SVG specifically, not GL2D - but GL2D + // _has('cartesian') means SVG specifically, not heatmapgl - but heatmapgl // can still get here because it makes some of the SVG structure // for shared features like selections. if(!fullLayout._has('cartesian')) { diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index bd53e4364ff..0f7da3b3716 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -102,7 +102,7 @@ axes.coerceRef = function(containerIn, containerOut, gd, attr, dflt, extraOption if(!extraOption) extraOption = dflt; axlist = axlist.concat(axlist.map(function(x) { return x + ' domain'; })); - // data-ref annotations are not supported in gl2d yet + // data-ref annotations are not supported in heatmapgl yet attrDef[refAttr] = { valType: 'enumerated', diff --git a/src/plots/cartesian/include_components.js b/src/plots/cartesian/include_components.js index c699716b5ff..2ca206406ac 100644 --- a/src/plots/cartesian/include_components.js +++ b/src/plots/cartesian/include_components.js @@ -35,7 +35,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { var xaList = subplots.xaxis; var yaList = subplots.yaxis; var cartesianList = subplots.cartesian; - var hasCartesianOrGL2D = layoutOut._has('cartesian') || layoutOut._has('gl2d'); + var hasCartesianOrHeatmapgl = layoutOut._has('cartesian') || layoutOut._has('gl2d'); for(var i = 0; i < array.length; i++) { var itemi = array[i]; @@ -49,7 +49,7 @@ module.exports = function makeIncludeComponents(containerArrayName) { var hasXref = idRegex.x.test(xref); var hasYref = idRegex.y.test(yref); if(hasXref || hasYref) { - if(!hasCartesianOrGL2D) Lib.pushUnique(layoutOut._basePlotModules, Cartesian); + if(!hasCartesianOrHeatmapgl) Lib.pushUnique(layoutOut._basePlotModules, Cartesian); var newAxis = false; if(hasXref && xaList.indexOf(xref) === -1) { diff --git a/src/plots/plots.js b/src/plots/plots.js index e0ec0575abd..09d241a0d13 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -476,12 +476,12 @@ plots.supplyDefaults = function(gd, opts) { // clean subplots and other artifacts from previous plot calls plots.cleanPlot(newFullData, newFullLayout, oldFullData, oldFullLayout); - var hadGL2D = !!(oldFullLayout._has && oldFullLayout._has('gl2d')); - var hasGL2D = !!(newFullLayout._has && newFullLayout._has('gl2d')); + var hadHeatmapgl = !!(oldFullLayout._has && oldFullLayout._has('gl2d')); + var hasHeatmapgl = !!(newFullLayout._has && newFullLayout._has('gl2d')); var hadCartesian = !!(oldFullLayout._has && oldFullLayout._has('cartesian')); var hasCartesian = !!(newFullLayout._has && newFullLayout._has('cartesian')); - var hadBgLayer = hadCartesian || hadGL2D; - var hasBgLayer = hasCartesian || hasGL2D; + var hadBgLayer = hadCartesian || hadHeatmapgl; + var hasBgLayer = hasCartesian || hasHeatmapgl; if(hadBgLayer && !hasBgLayer) { // remove bgLayer oldFullLayout._bgLayer.remove(); diff --git a/src/traces/contourgl/convert.js b/src/traces/contourgl/convert.js deleted file mode 100644 index d6f830d0f49..00000000000 --- a/src/traces/contourgl/convert.js +++ /dev/null @@ -1,187 +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 createContour2D = require('gl-contour2d'); -var createHeatmap2D = require('gl-heatmap2d'); - -var Axes = require('../../plots/cartesian/axes'); -var makeColorMap = require('../contour/make_color_map'); -var str2RGBArray = require('../../lib/str2rgbarray'); - - -function Contour(scene, uid) { - this.scene = scene; - this.uid = uid; - this.type = 'contourgl'; - - this.name = ''; - this.hoverinfo = 'all'; - - this.xData = []; - this.yData = []; - this.zData = []; - this.textLabels = []; - - this.idToIndex = []; - this.bounds = [0, 0, 0, 0]; - - this.contourOptions = { - z: new Float32Array(0), - x: [], - y: [], - shape: [0, 0], - levels: [0], - levelColors: [0, 0, 0, 1], - lineWidth: 1 - }; - this.contour = createContour2D(scene.glplot, this.contourOptions); - this.contour._trace = this; - - this.heatmapOptions = { - z: new Float32Array(0), - x: [], - y: [], - shape: [0, 0], - colorLevels: [0], - colorValues: [0, 0, 0, 0] - }; - this.heatmap = createHeatmap2D(scene.glplot, this.heatmapOptions); - this.heatmap._trace = this; -} - -var proto = Contour.prototype; - -proto.handlePick = function(pickResult) { - var options = this.heatmapOptions; - var shape = options.shape; - var index = pickResult.pointId; - var xIndex = index % shape[0]; - var yIndex = Math.floor(index / shape[0]); - var zIndex = index; - - return { - trace: this, - dataCoord: pickResult.dataCoord, - traceCoord: [ - options.x[xIndex], - options.y[yIndex], - options.z[zIndex] - ], - textLabel: this.textLabels[index], - name: this.name, - pointIndex: [yIndex, xIndex], - hoverinfo: this.hoverinfo - }; -}; - -proto.update = function(fullTrace, calcTrace) { - var calcPt = calcTrace[0]; - - this.index = fullTrace.index; - this.name = fullTrace.name; - this.hoverinfo = fullTrace.hoverinfo; - - // convert z from 2D -> 1D - var z = calcPt.z; - var rowLen = z[0].length; - var colLen = z.length; - var colorOptions; - - this.contourOptions.z = flattenZ(z, rowLen, colLen); - this.heatmapOptions.z = [].concat.apply([], z); - - this.contourOptions.shape = this.heatmapOptions.shape = [rowLen, colLen]; - - this.contourOptions.x = this.heatmapOptions.x = calcPt.x; - this.contourOptions.y = this.heatmapOptions.y = calcPt.y; - - // pass on fill information - if(fullTrace.contours.coloring === 'fill') { - colorOptions = convertColorScale(fullTrace, {fill: true}); - this.contourOptions.levels = colorOptions.levels.slice(1); - // though gl-contour2d automatically defaults to a transparent layer for the last - // band color, it's set manually here in case the gl-contour2 API changes - this.contourOptions.fillColors = colorOptions.levelColors; - this.contourOptions.levelColors = [].concat.apply([], this.contourOptions.levels.map(function() { - return [0.25, 0.25, 0.25, 1.0]; - })); - } else { - colorOptions = convertColorScale(fullTrace, {fill: false}); - this.contourOptions.levels = colorOptions.levels; - this.contourOptions.levelColors = colorOptions.levelColors; - } - - // convert text from 2D -> 1D - this.textLabels = [].concat.apply([], fullTrace.text); - - this.contour.update(this.contourOptions); - this.heatmap.update(this.heatmapOptions); - - var xa = this.scene.xaxis; - var ya = this.scene.yaxis; - fullTrace._extremes[xa._id] = Axes.findExtremes(xa, calcPt.x); - fullTrace._extremes[ya._id] = Axes.findExtremes(ya, calcPt.y); -}; - -proto.dispose = function() { - this.contour.dispose(); - this.heatmap.dispose(); -}; - -function flattenZ(zIn, rowLen, colLen) { - var zOut = new Float32Array(rowLen * colLen); - var pt = 0; - - for(var i = 0; i < rowLen; i++) { - for(var j = 0; j < colLen; j++) { - zOut[pt++] = zIn[j][i]; - } - } - - return zOut; -} - -function convertColorScale(fullTrace, options) { - var contours = fullTrace.contours; - var start = contours.start; - var end = contours.end; - var cs = contours.size || 1; - var fill = options.fill; - - var colorMap = makeColorMap(fullTrace); - - var N = Math.floor((end - start) / cs) + (fill ? 2 : 1); // for K thresholds (contour linees) there are K+1 areas - var levels = new Array(N); - var levelColors = new Array(4 * N); - - for(var i = 0; i < N; i++) { - var level = levels[i] = start + cs * (i) - (fill ? cs / 2 : 0); // in case of fill, use band midpoint - var color = str2RGBArray(colorMap(level)); - - for(var j = 0; j < 4; j++) { - levelColors[(4 * i) + j] = color[j]; - } - } - - return { - levels: levels, - levelColors: levelColors - }; -} - -function createContour(scene, fullTrace, calcTrace) { - var plot = new Contour(scene, fullTrace.uid); - plot.update(fullTrace, calcTrace); - - return plot; -} - -module.exports = createContour; diff --git a/src/traces/contourgl/index.js b/src/traces/contourgl/index.js deleted file mode 100644 index faef6353ab5..00000000000 --- a/src/traces/contourgl/index.js +++ /dev/null @@ -1,30 +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 overrideAll = require('../../plot_api/edit_types').overrideAll; - -module.exports = { - attributes: overrideAll(require('../contour/attributes'), 'calc', 'nested'), - supplyDefaults: require('../contour/defaults'), - colorbar: require('../contour/colorbar'), - - calc: require('../contour/calc'), - plot: require('./convert'), - - moduleType: 'trace', - name: 'contourgl', - basePlotModule: require('../../plots/gl2d'), - categories: ['gl', 'gl2d', '2dMap'], - meta: { - description: [ - 'WebGL contour (beta)' - ].join(' ') - } -}; diff --git a/src/traces/heatmap/make_bound_array.js b/src/traces/heatmap/make_bound_array.js index aad299e565d..4356e8c9d80 100644 --- a/src/traces/heatmap/make_bound_array.js +++ b/src/traces/heatmap/make_bound_array.js @@ -15,7 +15,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, var arrayOut = []; var isContour = Registry.traceIs(trace, 'contour'); var isHist = Registry.traceIs(trace, 'histogram'); - var isGL2D = Registry.traceIs(trace, 'gl2d'); + var isHeatmapgl = Registry.traceIs(trace, 'gl2d'); var v0; var dv; var i; @@ -30,7 +30,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, // and extend it linearly based on the last two points if(len <= numbricks) { // contour plots only want the centers - if(isContour || isGL2D) arrayOut = arrayIn.slice(0, numbricks); + if(isContour || isHeatmapgl) arrayOut = arrayIn.slice(0, numbricks); else if(numbricks === 1) { arrayOut = [arrayIn[0] - 0.5, arrayIn[0] + 0.5]; } else { @@ -77,7 +77,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, dv = dvIn || 1; - for(i = (isContour || isGL2D) ? 0 : -0.5; i < numbricks; i++) { + for(i = (isContour || isHeatmapgl) ? 0 : -0.5; i < numbricks; i++) { arrayOut.push(v0 + dv * i); } } diff --git a/src/traces/heatmap/xyz_defaults.js b/src/traces/heatmap/xyz_defaults.js index 66ea1874e28..1ee9e49c05c 100644 --- a/src/traces/heatmap/xyz_defaults.js +++ b/src/traces/heatmap/xyz_defaults.js @@ -44,10 +44,7 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x traceOut._length = null; } - if( - traceIn.type === 'heatmapgl' || - traceIn.type === 'contourgl' - ) return true; // skip calendars until we handle them in those traces + if(traceIn.type === 'heatmapgl') return true; // skip calendars until we handle them in those traces var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, [xName, yName], layout); diff --git a/src/traces/pointcloud/attributes.js b/src/traces/pointcloud/attributes.js deleted file mode 100644 index 88cc8e81452..00000000000 --- a/src/traces/pointcloud/attributes.js +++ /dev/null @@ -1,146 +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 scatterglAttrs = require('../scatter/attributes'); - -module.exports = { - x: scatterglAttrs.x, - y: scatterglAttrs.y, - xy: { - valType: 'data_array', - editType: 'calc', - description: [ - 'Faster alternative to specifying `x` and `y` separately.', - 'If supplied, it must be a typed `Float32Array` array that', - 'represents points such that `xy[i * 2] = x[i]` and `xy[i * 2 + 1] = y[i]`' - ].join(' ') - }, - indices: { - valType: 'data_array', - editType: 'calc', - description: [ - 'A sequential value, 0..n, supply it to avoid creating this array inside plotting.', - 'If specified, it must be a typed `Int32Array` array.', - 'Its length must be equal to or greater than the number of points.', - 'For the best performance and memory use, create one large `indices` typed array', - 'that is guaranteed to be at least as long as the largest number of points during', - 'use, and reuse it on each `Plotly.restyle()` call.' - ].join(' ') - }, - xbounds: { - valType: 'data_array', - editType: 'calc', - description: [ - 'Specify `xbounds` in the shape of `[xMin, xMax] to avoid looping through', - 'the `xy` typed array. Use it in conjunction with `xy` and `ybounds` for the performance benefits.' - ].join(' ') - }, - ybounds: { - valType: 'data_array', - editType: 'calc', - description: [ - 'Specify `ybounds` in the shape of `[yMin, yMax] to avoid looping through', - 'the `xy` typed array. Use it in conjunction with `xy` and `xbounds` for the performance benefits.' - ].join(' ') - }, - text: scatterglAttrs.text, - marker: { - color: { - valType: 'color', - arrayOk: false, - role: 'style', - editType: 'calc', - description: [ - 'Sets the marker fill color. It accepts a specific color.', - 'If the color is not fully opaque and there are hundreds of thousands', - 'of points, it may cause slower zooming and panning.' - ].join('') - }, - opacity: { - valType: 'number', - min: 0, - max: 1, - dflt: 1, - arrayOk: false, - role: 'style', - editType: 'calc', - description: [ - 'Sets the marker opacity. The default value is `1` (fully opaque).', - 'If the markers are not fully opaque and there are hundreds of thousands', - 'of points, it may cause slower zooming and panning.', - 'Opacity fades the color even if `blend` is left on `false` even if there', - 'is no translucency effect in that case.' - ].join(' ') - }, - blend: { - valType: 'boolean', - dflt: null, - role: 'style', - editType: 'calc', - description: [ - 'Determines if colors are blended together for a translucency effect', - 'in case `opacity` is specified as a value less then `1`.', - 'Setting `blend` to `true` reduces zoom/pan', - 'speed if used with large numbers of points.' - ].join(' ') - }, - sizemin: { - valType: 'number', - min: 0.1, - max: 2, - dflt: 0.5, - role: 'style', - editType: 'calc', - description: [ - 'Sets the minimum size (in px) of the rendered marker points, effective when', - 'the `pointcloud` shows a million or more points.' - ].join(' ') - }, - sizemax: { - valType: 'number', - min: 0.1, - dflt: 20, - role: 'style', - editType: 'calc', - description: [ - 'Sets the maximum size (in px) of the rendered marker points.', - 'Effective when the `pointcloud` shows only few points.' - ].join(' ') - }, - border: { - color: { - valType: 'color', - arrayOk: false, - role: 'style', - editType: 'calc', - description: [ - 'Sets the stroke color. It accepts a specific color.', - 'If the color is not fully opaque and there are hundreds of thousands', - 'of points, it may cause slower zooming and panning.' - ].join(' ') - }, - arearatio: { - valType: 'number', - min: 0, - max: 1, - dflt: 0, - role: 'style', - editType: 'calc', - description: [ - 'Specifies what fraction of the marker area is covered with the', - 'border.' - ].join(' ') - }, - editType: 'calc' - }, - editType: 'calc' - }, - transforms: undefined -}; diff --git a/src/traces/pointcloud/convert.js b/src/traces/pointcloud/convert.js deleted file mode 100644 index 9735071ba54..00000000000 --- a/src/traces/pointcloud/convert.js +++ /dev/null @@ -1,200 +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 createPointCloudRenderer = require('gl-pointcloud2d'); - -var str2RGBArray = require('../../lib/str2rgbarray'); -var findExtremes = require('../../plots/cartesian/autorange').findExtremes; -var getTraceColor = require('../scatter/get_trace_color'); - -function Pointcloud(scene, uid) { - this.scene = scene; - this.uid = uid; - this.type = 'pointcloud'; - - this.pickXData = []; - this.pickYData = []; - this.xData = []; - this.yData = []; - this.textLabels = []; - this.color = 'rgb(0, 0, 0)'; - this.name = ''; - this.hoverinfo = 'all'; - - this.idToIndex = new Int32Array(0); - this.bounds = [0, 0, 0, 0]; - - this.pointcloudOptions = { - positions: new Float32Array(0), - idToIndex: this.idToIndex, - sizemin: 0.5, - sizemax: 12, - color: [0, 0, 0, 1], - areaRatio: 1, - borderColor: [0, 0, 0, 1] - }; - this.pointcloud = createPointCloudRenderer(scene.glplot, this.pointcloudOptions); - this.pointcloud._trace = this; // scene2d requires this prop -} - -var proto = Pointcloud.prototype; - -proto.handlePick = function(pickResult) { - var index = this.idToIndex[pickResult.pointId]; - - // prefer the readout from XY, if present - return { - trace: this, - dataCoord: pickResult.dataCoord, - traceCoord: this.pickXYData ? - [this.pickXYData[index * 2], this.pickXYData[index * 2 + 1]] : - [this.pickXData[index], this.pickYData[index]], - textLabel: Array.isArray(this.textLabels) ? - this.textLabels[index] : - this.textLabels, - color: this.color, - name: this.name, - pointIndex: index, - hoverinfo: this.hoverinfo - }; -}; - -proto.update = function(options) { - this.index = options.index; - this.textLabels = options.text; - this.name = options.name; - this.hoverinfo = options.hoverinfo; - this.bounds = [Infinity, Infinity, -Infinity, -Infinity]; - - this.updateFast(options); - - this.color = getTraceColor(options, {}); -}; - -proto.updateFast = function(options) { - var x = this.xData = this.pickXData = options.x; - var y = this.yData = this.pickYData = options.y; - var xy = this.pickXYData = options.xy; - - var userBounds = options.xbounds && options.ybounds; - var index = options.indices; - - var len; - var idToIndex; - var positions; - var bounds = this.bounds; - - var xx, yy, i; - - if(xy) { - positions = xy; - - // dividing xy.length by 2 and truncating to integer if xy.length was not even - len = xy.length >>> 1; - - if(userBounds) { - bounds[0] = options.xbounds[0]; - bounds[2] = options.xbounds[1]; - bounds[1] = options.ybounds[0]; - bounds[3] = options.ybounds[1]; - } else { - for(i = 0; i < len; i++) { - xx = positions[i * 2]; - yy = positions[i * 2 + 1]; - - if(xx < bounds[0]) bounds[0] = xx; - if(xx > bounds[2]) bounds[2] = xx; - if(yy < bounds[1]) bounds[1] = yy; - if(yy > bounds[3]) bounds[3] = yy; - } - } - - if(index) { - idToIndex = index; - } else { - idToIndex = new Int32Array(len); - - for(i = 0; i < len; i++) { - idToIndex[i] = i; - } - } - } else { - len = x.length; - - positions = new Float32Array(2 * len); - idToIndex = new Int32Array(len); - - for(i = 0; i < len; i++) { - xx = x[i]; - yy = y[i]; - - idToIndex[i] = i; - - positions[i * 2] = xx; - positions[i * 2 + 1] = yy; - - if(xx < bounds[0]) bounds[0] = xx; - if(xx > bounds[2]) bounds[2] = xx; - if(yy < bounds[1]) bounds[1] = yy; - if(yy > bounds[3]) bounds[3] = yy; - } - } - - this.idToIndex = idToIndex; - this.pointcloudOptions.idToIndex = idToIndex; - - this.pointcloudOptions.positions = positions; - - var markerColor = str2RGBArray(options.marker.color); - var borderColor = str2RGBArray(options.marker.border.color); - var opacity = options.opacity * options.marker.opacity; - - markerColor[3] *= opacity; - this.pointcloudOptions.color = markerColor; - - // detect blending from the number of points, if undefined - // because large data with blending hits performance - var blend = options.marker.blend; - if(blend === null) { - var maxPoints = 100; - blend = x.length < maxPoints || y.length < maxPoints; - } - this.pointcloudOptions.blend = blend; - - borderColor[3] *= opacity; - this.pointcloudOptions.borderColor = borderColor; - - var markerSizeMin = options.marker.sizemin; - var markerSizeMax = Math.max(options.marker.sizemax, options.marker.sizemin); - this.pointcloudOptions.sizeMin = markerSizeMin; - this.pointcloudOptions.sizeMax = markerSizeMax; - this.pointcloudOptions.areaRatio = options.marker.border.arearatio; - - this.pointcloud.update(this.pointcloudOptions); - - // add item for autorange routine - var xa = this.scene.xaxis; - var ya = this.scene.yaxis; - var pad = markerSizeMax / 2 || 0.5; - options._extremes[xa._id] = findExtremes(xa, [bounds[0], bounds[2]], {ppad: pad}); - options._extremes[ya._id] = findExtremes(ya, [bounds[1], bounds[3]], {ppad: pad}); -}; - -proto.dispose = function() { - this.pointcloud.dispose(); -}; - -function createPointcloud(scene, data) { - var plot = new Pointcloud(scene, data.uid); - plot.update(data); - return plot; -} - -module.exports = createPointcloud; diff --git a/src/traces/pointcloud/defaults.js b/src/traces/pointcloud/defaults.js deleted file mode 100644 index 0aedf577504..00000000000 --- a/src/traces/pointcloud/defaults.js +++ /dev/null @@ -1,46 +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 Lib = require('../../lib'); - -var attributes = require('./attributes'); - -module.exports = function supplyDefaults(traceIn, traceOut, defaultColor) { - function coerce(attr, dflt) { - return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); - } - - coerce('x'); - coerce('y'); - - coerce('xbounds'); - coerce('ybounds'); - - if(traceIn.xy && traceIn.xy instanceof Float32Array) { - traceOut.xy = traceIn.xy; - } - - if(traceIn.indices && traceIn.indices instanceof Int32Array) { - traceOut.indices = traceIn.indices; - } - - coerce('text'); - coerce('marker.color', defaultColor); - coerce('marker.opacity'); - coerce('marker.blend'); - coerce('marker.sizemin'); - coerce('marker.sizemax'); - coerce('marker.border.color', defaultColor); - coerce('marker.border.arearatio'); - - // disable 1D transforms - that would defeat the purpose of this trace type, performance! - traceOut._length = null; -}; diff --git a/src/traces/pointcloud/index.js b/src/traces/pointcloud/index.js deleted file mode 100644 index 868e1cce512..00000000000 --- a/src/traces/pointcloud/index.js +++ /dev/null @@ -1,29 +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'; - -module.exports = { - attributes: require('./attributes'), - supplyDefaults: require('./defaults'), - - // reuse the Scatter3D 'dummy' calc step so that legends know what to do - calc: require('../scatter3d/calc'), - plot: require('./convert'), - - moduleType: 'trace', - name: 'pointcloud', - basePlotModule: require('../../plots/gl2d'), - categories: ['gl', 'gl2d', 'showLegend'], - meta: { - description: [ - 'The data visualized as a point cloud set in `x` and `y`', - 'using the WebGl plotting engine.' - ].join(' ') - } -}; diff --git a/test/image/baselines/gl2d_pointcloud-basic.png b/test/image/baselines/gl2d_pointcloud-basic.png deleted file mode 100644 index 13e73650e51..00000000000 Binary files a/test/image/baselines/gl2d_pointcloud-basic.png and /dev/null differ diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index 9ec29d774ae..46361b59818 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -121,7 +121,7 @@ if(argv['skip-flaky']) { }); } -/* gl2d pointcloud and other non-regl gl2d mock(s) +/* non-regl mock(s) i.e. heatmapgl * must be tested first on in order to work; * sort them here. * @@ -136,8 +136,8 @@ if(argv['skip-flaky']) { * More info here: * https://github.com/plotly/plotly.js/pull/1037 */ -function sortGl2dMockList(mockList) { - var mockNames = ['gl2d_pointcloud-basic', 'gl2d_heatmapgl']; +function sortHeatmapglMockList(mockList) { + var mockNames = ['gl2d_heatmapgl']; var pos = 0; mockNames.forEach(function(m) { @@ -283,7 +283,7 @@ function comparePixels(mockName, cb) { .on('close', checkImage); } -sortGl2dMockList(allMockList); +sortHeatmapglMockList(allMockList); console.log(''); // main diff --git a/test/image/mocks/gl2d_pointcloud-basic.json b/test/image/mocks/gl2d_pointcloud-basic.json deleted file mode 100644 index bdab3ae5510..00000000000 --- a/test/image/mocks/gl2d_pointcloud-basic.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "data": [ - { - "type": "pointcloud", - "mode": "markers", - "marker": { - "sizemin": 0.5, - "sizemax": 100, - "arearatio": 0, - "color": "rgba(255, 0, 0, 0.6)" - }, - "x": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - "y": [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] - }, - { - "type": "pointcloud", - "mode": "markers", - "marker": { - "sizemin": 0.5, - "sizemax": 100, - "arearatio": 0, - "color": "rgba(0, 0, 255, 0.9)", - "opacity": 0.8, - "blend": true - }, - "opacity": 0.7, - "x": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - "y": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - }, - { - "type": "pointcloud", - "mode": "markers", - "marker": { - "sizemin": 0.5, - "sizemax": 100, - "border": { - "color": "rgb(0, 0, 0)", - "arearatio": 0.7071 - }, - "color": "green", - "opacity": 0.8, - "blend": true - }, - "opacity": 0.7, - "x": [3, 4.5, 6], - "y": [9, 9, 9] - } - ], - "layout": { - "title": {"text": "Point Cloud - basic"}, - "xaxis": { - "type": "linear", - "range": [ - -2.501411175139456, - 43.340777299865266 - ], - "autorange": true - }, - "yaxis": { - "type": "linear", - "range": [ - 4, - 6 - ], - "autorange": true - }, - "height": 598, - "width": 1080, - "autosize": true, - "showlegend": false - } -} diff --git a/test/jasmine/assets/mock_lists.js b/test/jasmine/assets/mock_lists.js index 59af1a73109..221ae703166 100644 --- a/test/jasmine/assets/mock_lists.js +++ b/test/jasmine/assets/mock_lists.js @@ -58,7 +58,6 @@ var glMockList = [ ['gl2d_heatmapgl', require('@mocks/gl2d_heatmapgl.json')], ['gl2d_line_dash', require('@mocks/gl2d_line_dash.json')], ['gl2d_parcoords_2', require('@mocks/gl2d_parcoords_2.json')], - ['gl2d_pointcloud-basic', require('@mocks/gl2d_pointcloud-basic.json')], ['gl3d_annotations', require('@mocks/gl3d_annotations.json')], ['gl3d_set-ranges', require('@mocks/gl3d_set-ranges.json')], ['gl3d_world-cals', require('@mocks/gl3d_world-cals.json')], diff --git a/test/jasmine/bundle_tests/no_webgl_test.js b/test/jasmine/bundle_tests/no_webgl_test.js index 10a22e858c5..7d33d980c43 100644 --- a/test/jasmine/bundle_tests/no_webgl_test.js +++ b/test/jasmine/bundle_tests/no_webgl_test.js @@ -37,8 +37,8 @@ describe('Plotly w/o WebGL support:', function() { .then(done, done.fail); }); - it('gl2d subplots', function(done) { - Plotly.react(gd, require('@mocks/gl2d_pointcloud-basic.json')) + it('heatmapgl subplots', function(done) { + Plotly.react(gd, require('@mocks/gl2d_heatmapgl.json')) .then(function() { checkNoWebGLMsg(true); return Plotly.react(gd, require('@mocks/10.json')); diff --git a/test/jasmine/tests/contourgl_test.js b/test/jasmine/tests/contourgl_test.js deleted file mode 100644 index 580c834a7a5..00000000000 --- a/test/jasmine/tests/contourgl_test.js +++ /dev/null @@ -1,288 +0,0 @@ -var Plotly = require('@lib/index'); -var Lib = require('@src/lib'); -var d3Range = require('../../strict-d3').range; -var supplyDefaults = require('@src/traces/heatmapgl').supplyDefaults; -var Plots = require('@src/plots/plots'); - -// contourgl is not part of the dist plotly.js bundle initially -Plotly.register([ - require('@lib/contourgl') -]); - -var schema = Plotly.PlotSchema.get(); -var attributeList = Object.getOwnPropertyNames(schema.traces.heatmapgl.attributes); - -// Test utilities -var createGraphDiv = require('../assets/create_graph_div'); -var destroyGraphDiv = require('../assets/destroy_graph_div'); - - -var plotData = { - 'data': [ - { - 'type': 'contourgl', - 'z': [ - [ - 10, - 10.625, - 12.5, - 15.625, - 20 - ], - [ - 5.625, - 6.25, - 8.125, - 11.25, - 15.625 - ], - [ - 2.5, - 3.125, - 5, - 8.125, - 12.5 - ], - [ - 0.625, - 1.25, - 3.125, - 6.25, - 10.625 - ], - [ - 0, - 0.625, - 2.5, - 5.625, - 10 - ] - ], - 'colorscale': 'Jet', - 'contours': { - 'start': 2, - 'end': 10, - 'size': 1 - }, - 'uid': 'ad5624', - 'zmin': 0, - 'zmax': 20 - } - ], - 'layout': { - 'xaxis': { - 'range': [ - 0, - 4 - ], - 'autorange': true - }, - 'yaxis': { - 'range': [ - 0, - 4 - ], - 'autorange': true - }, - 'height': 450, - 'width': 1000, - 'autosize': true - } -}; - -function transpose(a) { - return a[0].map(function(ignore, columnIndex) {return a.map(function(row) {return row[columnIndex];});}); -} - -Lib.seedPseudoRandom(); - -function jitter(maxJitterRatio, n) { - return n * (1 + maxJitterRatio * (2 * Lib.pseudoRandom() - 1)); -} - -function rotate(rad, point) { - return { - x: point.x * Math.cos(rad) - point.y * Math.sin(rad), - y: point.x * Math.sin(rad) + point.y * Math.cos(rad) - }; -} - -function generate(maxJitter) { - var x = d3Range(-1, 1.5, 0.5); // left closed, right open interval - var y = d3Range(-1, 1.5, 0.5); // left closed, right open interval - var z = new Array(x.length); - var i, j, p; - - for(i = 0; i < x.length; i++) { - z[i] = new Array(y.length); - for(j = 0; j < y.length; j++) { - p = rotate(Math.PI / 4, {x: x[i], y: -y[j]}); - z[i][j] = jitter(maxJitter, Math.pow(p.x, 2) + Math.pow(p.y, 2)); - } - } - return {x: x, y: y, z: z}; // looking forward to the ES2015 return {x, y, z} -} - -// equivalent to the new example case in gl-contour2d -var plotDataElliptical = function(maxJitter) { - var model = generate(maxJitter); - return { - 'data': [ - { - 'type': 'contourgl', - 'x': model.x, - 'y': model.y, - 'z': transpose(model.z), // gl-vis is column-major order while ploly is row-major order - 'colorscale': 'Jet', - 'contours': { - 'start': 0, - 'end': 2, - 'size': 0.1, - 'coloring': 'fill' - }, - 'uid': 'ad5624', - 'zmin': 0, - 'zmax': 2 - } - ], - 'layout': { - 'xaxis': { - 'range': [ - -10, - 10 - ], - 'autorange': true - }, - 'yaxis': { - 'range': [ - -10, - 10 - ], - 'autorange': true - }, - 'height': 600, - 'width': 600, - 'autosize': true - } - }; -}; - - -function makePlot(gd, mock, done) { - return Plotly.newPlot(gd, mock.data, mock.layout) - .then(done, done.fail); -} - -describe('contourgl plots', function() { - var gd; - - beforeEach(function() { - gd = createGraphDiv(); - }); - - afterEach(function() { - Plotly.purge(gd); - destroyGraphDiv(); - }); - - // this first dataset is a special case, very forgiving to the contour renderer, as it's convex, - // contains no inflexion points etc. - it('@gl render without raising an error', function(done) { - makePlot(gd, plotData, done); - }); - - it('@gl render without raising an error', function(done) { - var mock = require('@mocks/simple_contour.json'); - var mockCopy = Lib.extendDeep({}, mock); - - mockCopy.data[0].type = 'contourgl'; - mockCopy.data[0].contours = { coloring: 'fill' }; - - makePlot(gd, mockCopy, done); - }); - - it('@gl render without raising an error (coloring: "lines")', function(done) { - var mock = Lib.extendDeep({}, plotDataElliptical(0)); - mock.data[0].contours.coloring = 'lines'; // 'fill' is the default - makePlot(gd, mock, done); - }); - - it('@gl render smooth, regular ellipses without raising an error (coloring: "fill")', function(done) { - var mock = plotDataElliptical(0); - makePlot(gd, mock, done); - }); - - it('@gl render ellipses with added noise without raising an error (coloring: "fill")', function(done) { - var mock = plotDataElliptical(0.5); - mock.data[0].contours.coloring = 'fill'; // 'fill' is the default - mock.data[0].line = {smoothing: 0}; - makePlot(gd, mock, done); - }); - - it('@gl should update properly', function(done) { - var mock = plotDataElliptical(0); - var scene2d; - - Plotly.newPlot(gd, mock.data, mock.layout).then(function() { - scene2d = gd._fullLayout._plots.xy._scene2d; - - expect(scene2d.traces[mock.data[0].uid].type).toEqual('contourgl'); - expect(scene2d.xaxis.range).toEqual([-1, 1]); - - return Plotly.relayout(gd, 'xaxis.range', [0, -10]); - }).then(function() { - expect(scene2d.xaxis.range).toEqual([0, -10]); - - return Plotly.relayout(gd, 'xaxis.autorange', true); - }).then(function() { - expect(scene2d.xaxis.range).toEqual([1, -1]); // autorange keeps its reversal - - return Plotly.restyle(gd, 'type', 'heatmapgl'); - }).then(function() { - expect(scene2d.traces[mock.data[0].uid].type).toEqual('heatmapgl'); - expect(scene2d.xaxis.range).toEqual([1, -1]); - - return Plotly.relayout(gd, 'xaxis.range', [0, -10]); - }).then(function() { - expect(scene2d.xaxis.range).toEqual([0, -10]); - - return Plotly.relayout(gd, 'xaxis.autorange', true); - }).then(function() { - expect(scene2d.xaxis.range).toEqual([1, -1]); - }) - .then(done, done.fail); - }); -}); - -describe('heatmapgl supplyDefaults', function() { - 'use strict'; - - var traceIn; - var traceOut; - - var defaultColor = '#444'; - var layout = { - font: Plots.layoutAttributes.font, - _dfltTitle: {colorbar: 'cb'}, - _subplots: {cartesian: ['xy'], xaxis: ['x'], yaxis: ['y']} - }; - - beforeEach(function() { - traceOut = {}; - }); - - it('should only coerce attributes that are part of scheme', function() { - traceIn = { - type: 'contourgl', - z: [[0, 1], [1, 0]] - }; - - supplyDefaults(traceIn, traceOut, defaultColor, layout); - var allKeys = Object.getOwnPropertyNames(traceOut); - allKeys.forEach(function(key) { - if(key[0] !== '_') { - expect(attributeList.indexOf(key)).not.toBe(-1, key); - } - }); - }); -}); diff --git a/test/jasmine/tests/gl2d_click_test.js b/test/jasmine/tests/gl2d_click_test.js index 14c61c0db42..69fb784fec7 100644 --- a/test/jasmine/tests/gl2d_click_test.js +++ b/test/jasmine/tests/gl2d_click_test.js @@ -18,34 +18,10 @@ var hover = require('../assets/hover'); var delay = require('../assets/delay'); var mouseEvent = require('../assets/mouse_event'); -// contourgl is not part of the dist plotly.js bundle initially -Plotly.register([ - require('@lib/contourgl') -]); - var mock0 = require('@mocks/gl2d_scatter-continuous-clustering.json'); var mock1 = require('@mocks/gl2d_14.json'); -var mock2 = require('@mocks/gl2d_pointcloud-basic.json'); - -var mock3 = { - data: [{ - type: 'contourgl', - z: [ - [10, 10.625, 12.5, 15.625, 20], - [5.625, 6.25, 8.125, 11.25, 15.625], - [2.5, 3.125, 5, 8.125, 12.5], - [0.625, 1.25, 3.125, 20, 10.625], - [0, 0.625, 2.5, 5.625, 10] - ], - colorscale: 'Jet', - // contours: { start: 2, end: 10, size: 1 }, - zmin: 0, - zmax: 20 - }], - layout: {} -}; -var mock4 = { +var mock2 = { data: [{ x: [1, 2, 3, 4], y: [12, 3, 14, 4], @@ -411,34 +387,7 @@ describe('Test hover and click interactions', function() { .then(done, done.fail); }); - it('@gl should output correct event data for pointcloud', function(done) { - var _mock = Lib.extendDeep({}, mock2); - - _mock.layout.hoverlabel = { font: {size: 8} }; - _mock.data[2].hoverlabel = { - bgcolor: ['red', 'green', 'blue'] - }; - - var run = makeRunner([540, 150], { - x: 4.5, - y: 9, - curveNumber: 2, - pointNumber: 1, - bgcolor: 'rgb(0, 128, 0)', - bordercolor: 'rgb(255, 255, 255)', - fontSize: 8, - fontFamily: 'Arial', - fontColor: 'rgb(255, 255, 255)' - }, { - msg: 'pointcloud' - }); - - Plotly.newPlot(gd, _mock) - .then(run) - .then(done, done.fail); - }); - - it('@gl scatter3d should propagate marker colors to hover labels', function(done) { + it('@gl scattergl should propagate marker colors to hover labels', function(done) { var _mock = Lib.extendDeep({}, mock0); _mock.layout.width = 800; _mock.layout.height = 600; @@ -454,7 +403,7 @@ describe('Test hover and click interactions', function() { fontFamily: 'Arial', fontColor: 'rgb(68, 68, 68)' }, { - msg: 'pointcloud' + msg: 'scattergl marker colors' }); Plotly.newPlot(gd, _mock) @@ -463,15 +412,31 @@ describe('Test hover and click interactions', function() { }); it('@gl should output correct event data for heatmapgl', function(done) { - var _mock = Lib.extendDeep({}, mock3); - _mock.data[0].type = 'heatmapgl'; - - _mock.data[0].hoverlabel = { - font: { size: _mock.data[0].z } - }; + var z = [ + [10, 10.625, 12.5, 15.625, 20], + [5.625, 6.25, 8.125, 11.25, 15.625], + [2.5, 3.125, 5, 8.125, 12.5], + [0.625, 1.25, 3.125, 20, 10.625], + [0, 0.625, 2.5, 5.625, 10] + ]; - _mock.layout.hoverlabel = { - font: { family: 'Roboto' } + var _mock = { + data: [{ + type: 'heatmapgl', + z: z, + hoverlabel: { + font: { size: z } + }, + colorscale: 'Jet', + // contours: { start: 2, end: 10, size: 1 }, + zmin: 0, + zmax: 20 + }], + layout: { + hoverlabel: { + font: { family: 'Roboto' } + } + } }; var run = makeRunner([540, 150], { @@ -527,7 +492,7 @@ describe('Test hover and click interactions', function() { }); it('@gl should output correct event data for scattergl after visibility restyle', function(done) { - var _mock = Lib.extendDeep({}, mock4); + var _mock = Lib.extendDeep({}, mock2); var run = makeRunner([435, 216], { x: 8, @@ -568,7 +533,7 @@ describe('Test hover and click interactions', function() { }); it('@gl should output correct event data for scattergl-fancy', function(done) { - var _mock = Lib.extendDeep({}, mock4); + var _mock = Lib.extendDeep({}, mock2); _mock.data[0].mode = 'markers+lines'; _mock.data[1].mode = 'markers+lines'; _mock.data[2].mode = 'markers+lines'; @@ -613,33 +578,6 @@ describe('Test hover and click interactions', function() { .then(run2) .then(done, done.fail); }); - - it('@gl should output correct event data contourgl', function(done) { - var _mock = Lib.extendDeep({}, mock3); - - _mock.data[0].hoverlabel = { - font: { size: _mock.data[0].z } - }; - - var run = makeRunner([540, 150], { - x: 3, - y: 3, - curveNumber: 0, - pointNumber: [3, 3], - bgcolor: 'rgb(68, 68, 68)', - bordercolor: 'rgb(255, 255, 255)', - fontSize: 20, - fontFamily: 'Arial', - fontColor: 'rgb(255, 255, 255)' - }, { - noUnHover: true, - msg: 'contourgl' - }); - - Plotly.newPlot(gd, _mock) - .then(run) - .then(done, done.fail); - }); }); describe('hover with (x|y)period positioning', function() { diff --git a/test/jasmine/tests/mock_test.js b/test/jasmine/tests/mock_test.js index 44811150551..cf9b0ac63ee 100644 --- a/test/jasmine/tests/mock_test.js +++ b/test/jasmine/tests/mock_test.js @@ -426,7 +426,6 @@ var list = [ 'gl2d_parcoords_tick_format', 'gl2d_period_positioning', 'gl2d_point-selection', - 'gl2d_pointcloud-basic', 'gl2d_rgb_dont_accept_alpha_scattergl', 'gl2d_scatter_fill_self_next', 'gl2d_scatter_fill_self_next_vs_nogl', @@ -1514,7 +1513,6 @@ figs['gl2d_parcoords_style_labels'] = require('@mocks/gl2d_parcoords_style_label figs['gl2d_parcoords_tick_format'] = require('@mocks/gl2d_parcoords_tick_format'); figs['gl2d_period_positioning'] = require('@mocks/gl2d_period_positioning'); figs['gl2d_point-selection'] = require('@mocks/gl2d_point-selection'); -// figs['gl2d_pointcloud-basic'] = require('@mocks/gl2d_pointcloud-basic'); // figs['gl2d_rgb_dont_accept_alpha_scattergl'] = require('@mocks/gl2d_rgb_dont_accept_alpha_scattergl'); figs['gl2d_scatter_fill_self_next'] = require('@mocks/gl2d_scatter_fill_self_next'); figs['gl2d_scatter_fill_self_next_vs_nogl'] = require('@mocks/gl2d_scatter_fill_self_next_vs_nogl'); diff --git a/test/jasmine/tests/modebar_test.js b/test/jasmine/tests/modebar_test.js index a6b52bd45b1..83b89734e08 100644 --- a/test/jasmine/tests/modebar_test.js +++ b/test/jasmine/tests/modebar_test.js @@ -521,7 +521,7 @@ describe('ModeBar', function() { checkButtons(modeBar, buttons, 1); }); - it('creates mode bar (gl2d version)', function() { + it('creates mode bar (heatmapgl version)', function() { var buttons = getButtons([ ['toImage'], ['zoom2d', 'pan2d'], diff --git a/test/jasmine/tests/plot_api_react_test.js b/test/jasmine/tests/plot_api_react_test.js index 51bc4f07a35..4338cbd6097 100644 --- a/test/jasmine/tests/plot_api_react_test.js +++ b/test/jasmine/tests/plot_api_react_test.js @@ -761,10 +761,6 @@ describe('@noCIdep Plotly.react', function() { for(itemType in Registry.modules) { typesTested[itemType] = 0; } for(itemType in Registry.transformsRegistry) { typesTested[itemType] = 0; } - // Not really being supported... This isn't part of the main bundle, and it's pretty broken, - // but it gets registered and used by a couple of the gl2d tests. - delete typesTested.contourgl; - function _runReactMock(mockSpec, done) { var mock = mockSpec[1]; var initialJson; diff --git a/test/jasmine/tests/pointcloud_test.js b/test/jasmine/tests/pointcloud_test.js deleted file mode 100644 index 3fba5e52381..00000000000 --- a/test/jasmine/tests/pointcloud_test.js +++ /dev/null @@ -1,255 +0,0 @@ -'use strict'; - -var Plotly = require('@lib/index'); -var Lib = require('@src/lib'); -var d3Select = require('../../strict-d3').select; - -// Test utilities -var createGraphDiv = require('../assets/create_graph_div'); -var destroyGraphDiv = require('../assets/destroy_graph_div'); - -var delay = require('../assets/delay'); -var mouseEvent = require('../assets/mouse_event'); -var readPixel = require('../assets/read_pixel'); - -var multipleScatter2dMock = require('@mocks/gl2d_scatter2d-multiple-colors.json'); - -var plotData = { - 'data': [ - { - 'type': 'pointcloud', - 'mode': 'markers', - 'marker': { - 'sizemin': 0.5, - 'sizemax': 100, - 'arearatio': 0, - 'color': 'rgba(255, 0, 0, 0.6)' - }, - 'x': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - 'y': [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] - }, - { - 'type': 'pointcloud', - 'mode': 'markers', - 'marker': { - 'sizemin': 0.5, - 'sizemax': 100, - 'arearatio': 0, - 'color': 'rgba(0, 0, 255, 0.9)', - 'opacity': 0.8, - 'blend': true - }, - 'opacity': 0.7, - 'x': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - 'y': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - }, - { - 'type': 'pointcloud', - 'mode': 'markers', - 'marker': { - 'sizemin': 0.5, - 'sizemax': 100, - 'border': { - 'color': 'rgb(0, 0, 0)', - 'arearatio': 0.7071 - }, - 'color': 'green', - 'opacity': 0.8, - 'blend': true - }, - 'opacity': 0.7, - 'x': [3, 4.5, 6], - 'y': [9, 9, 9] - }, - { - 'type': 'pointcloud', - 'mode': 'markers', - 'marker': { - 'sizemin': 0.5, - 'sizemax': 100, - 'color': 'yellow', - 'opacity': 0.8, - 'blend': true - }, - 'opacity': 0.7, - 'xy': new Float32Array([1, 3, 9, 3]), - 'indices': new Int32Array([0, 1]), - 'xbounds': [1, 9], - 'ybounds': [3, 3] - }, - { - 'type': 'pointcloud', - 'mode': 'markers', - 'marker': { - 'sizemin': 0.5, - 'sizemax': 100, - 'color': 'orange', - 'opacity': 0.8, - 'blend': true - }, - 'opacity': 0.7, - 'xy': new Float32Array([1, 4, 9, 4]), - 'indices': new Int32Array([0, 1]) - }, - { - 'type': 'pointcloud', - 'mode': 'markers', - 'marker': { - 'sizemin': 0.5, - 'sizemax': 100, - 'color': 'darkorange', - 'opacity': 0.8, - 'blend': true - }, - 'opacity': 0.7, - 'xy': new Float32Array([1, 5, 9, 5]), - 'xbounds': [1, 9], - 'ybounds': [5, 5] - }, - { - 'type': 'pointcloud', - 'mode': 'markers', - 'marker': { - 'sizemin': 0.5, - 'sizemax': 100, - 'color': 'red', - 'opacity': 0.8, - 'blend': true - }, - 'opacity': 0.7, - 'xy': new Float32Array([1, 6, 9, 6]) - } - ], - 'layout': { - 'title': 'Point Cloud - basic', - 'xaxis': { - 'type': 'linear', - 'range': [ - -2.501411175139456, - 43.340777299865266 - ], - 'autorange': true - }, - 'yaxis': { - 'type': 'linear', - 'range': [ - 4, - 6 - ], - 'autorange': true - }, - 'height': 598, - 'width': 1080, - 'autosize': true, - 'showlegend': false - } -}; - -describe('pointcloud traces', function() { - var gd; - - beforeEach(function() { - gd = createGraphDiv(); - }); - - afterEach(function() { - Plotly.purge(gd); - destroyGraphDiv(); - }); - - it('@gl renders without raising an error', function(done) { - Plotly.newPlot(gd, Lib.extendDeep({}, plotData)) - .then(done, done.fail); - }); - - it('@gl should update properly', function(done) { - var scene2d; - - Plotly.newPlot(gd, Lib.extendDeep({}, plotData)) - .then(function() { - scene2d = gd._fullLayout._plots.xy._scene2d; - expect(scene2d.traces[gd._fullData[0].uid].type).toBe('pointcloud'); - - return Plotly.relayout(gd, 'xaxis.range', [3, 6]); - }).then(function() { - expect(scene2d.xaxis.range).toEqual([3, 6]); - expect(scene2d.yaxis.range).toBeCloseToArray([-1.415, 10.415], 2); - return Plotly.relayout(gd, 'xaxis.autorange', true); - }).then(function() { - expect(scene2d.xaxis.range).toBeCloseToArray([-0.548, 9.548], 2); - expect(scene2d.yaxis.range).toBeCloseToArray([-1.415, 10.415], 2); - return Plotly.relayout(gd, 'yaxis.range', [8, 20]); - }).then(function() { - expect(scene2d.xaxis.range).toBeCloseToArray([-0.548, 9.548], 2); - expect(scene2d.yaxis.range).toEqual([8, 20]); - return Plotly.relayout(gd, 'yaxis.autorange', true); - }).then(function() { - expect(scene2d.xaxis.range).toBeCloseToArray([-0.548, 9.548], 2); - expect(scene2d.yaxis.range).toBeCloseToArray([-1.415, 10.415], 2); - }) - .then(done, done.fail); - }); - - it('@gl should not change other traces colors', function(done) { - var _mock = Lib.extendDeep({}, multipleScatter2dMock); - Plotly.newPlot(gd, _mock) - .then(delay(20)) - .then(function() { - var canvas = d3Select('.gl-canvas-context').node(); - - var RGBA = readPixel(canvas, canvas.width / 2 - 1, canvas.height / 2 - 1, 1, 1); - - expect(RGBA[0] === 255).toBe(true, 'be red'); - expect(RGBA[1] === 0).toBe(true, 'no green'); - expect(RGBA[2] === 0).toBe(true, 'no blue'); - expect(RGBA[3] === 255).toBe(true, 'no transparent'); - }) - .then(done, done.fail); - }); - - it('@gl should respond to drag', function(done) { - function _drag(p0, p1) { - mouseEvent('mousemove', p0[0], p0[1], {buttons: 1}); - mouseEvent('mousedown', p0[0], p0[1], {buttons: 1}); - mouseEvent('mousemove', (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2, {buttons: 1}); - mouseEvent('mousemove', p1[0], p1[1], {buttons: 0}); - mouseEvent('mouseup', p1[0], p1[1], {buttons: 0}); - } - - function _assertRange(msg, xrng, yrng) { - expect(gd._fullLayout.xaxis.range).toBeCloseToArray(xrng, 2, msg); - expect(gd._fullLayout.yaxis.range).toBeCloseToArray(yrng, 2, msg); - } - - Plotly.newPlot(gd, Lib.extendDeep({}, plotData)) - .then(delay(20)) - .then(function() { - _assertRange('base', [-0.548, 9.548], [-1.415, 10.415]); - }) - .then(delay(20)) - .then(function() { _drag([200, 200], [350, 350]); }) - .then(delay(20)) - .then(function() { - _assertRange('after zoombox drag', [0.768, 1.591], [5.462, 7.584]); - }) - .then(function() { - return Plotly.relayout(gd, { - 'xaxis.autorange': true, - 'yaxis.autorange': true - }); - }) - .then(function() { - _assertRange('back to base', [-0.548, 9.548], [-1.415, 10.415]); - }) - .then(function() { - return Plotly.relayout(gd, 'dragmode', 'pan'); - }) - .then(delay(20)) - .then(function() { _drag([200, 200], [350, 350]); }) - .then(delay(20)) - .then(function() { - _assertRange('after pan drag', [0.2743, 10.3719], [-3.537, 8.292]); - }) - .then(done, done.fail); - }); -}); diff --git a/test/jasmine/tests/transition_test.js b/test/jasmine/tests/transition_test.js index a5c5f24d9fe..c106aa952c7 100644 --- a/test/jasmine/tests/transition_test.js +++ b/test/jasmine/tests/transition_test.js @@ -1196,25 +1196,21 @@ describe('Plotly.react transitions:', function() { gd.layout.xaxis.range = ['2018-06-01', '2019-06-01']; gd.layout.xaxis2.range = [0.5, 1.5]; - var promise = Plotly.react(gd, gd.data, gd.layout); - setTimeout(function() { - var fullLayout = gd._fullLayout; + return Plotly.react(gd, gd.data, gd.layout); + }).then(function() { + var fullLayout = gd._fullLayout; - var xa = fullLayout.xaxis; - var xr = xa.range.slice(); - expect(xa.r2l(xr[0])).toBeGreaterThan(xa.r2l('2018-01-01')); - expect(xa.r2l(xr[1])).toBeLessThan(xa.r2l('2020-01-01')); + var xa = fullLayout.xaxis; + var xr = xa.range.slice(); + expect(xa.r2l(xr[0])).toBeGreaterThan(xa.r2l('2018-01-01')); + expect(xa.r2l(xr[1])).toBeLessThan(xa.r2l('2020-01-01')); - var xa2 = fullLayout.xaxis2; - var xr2 = xa2.range.slice(); - expect(xr2[0]).toBeGreaterThan(0); - expect(xr2[1]).toBeLessThan(2); - }, 15); + var xa2 = fullLayout.xaxis2; + var xr2 = xa2.range.slice(); + expect(xr2[0]).toBeGreaterThan(0); + expect(xr2[1]).toBeLessThan(2); - return promise; - }) - .then(function() { expect(gd._fullLayout.xaxis.range).toEqual(['2018-06-01', '2019-06-01']); expect(gd._fullLayout.xaxis2.range).toEqual([0.5, 1.5]); })