Skip to content

Commit

Permalink
Merge pull request #896 from plotly/toself-trace-opacity
Browse files Browse the repository at this point in the history
Add support for trace opacity in `toself` fills
  • Loading branch information
etpinard committed Sep 7, 2016
2 parents 7916bb3 + d51a41e commit 76f1c57
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/traces/scatter/clean_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@
'use strict';


// remove opacity for any trace that has a fill or is filled to
module.exports = function cleanData(fullData) {
var i,
tracei,
filli,
j,
tracej;

// remove opacity for any trace that has a fill or is filled to
for(i = 0; i < fullData.length; i++) {
tracei = fullData[i];
filli = tracei.fill;
if((filli === 'none') || (tracei.type !== 'scatter')) continue;
for(var i = 0; i < fullData.length; i++) {
var tracei = fullData[i];
if(tracei.type !== 'scatter') continue;

var filli = tracei.fill;
if(filli === 'none' || filli === 'toself') continue;

tracei.opacity = undefined;

if(filli === 'tonexty' || filli === 'tonextx') {
for(j = i - 1; j >= 0; j--) {
tracej = fullData[j];
for(var j = i - 1; j >= 0; j--) {
var tracej = fullData[j];

if((tracej.type === 'scatter') &&
(tracej.xaxis === tracei.xaxis) &&
(tracej.yaxis === tracei.yaxis)) {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions test/image/mocks/scatter_fill_self_opacity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"data": [
{
"x": [
6,
7,
8
],
"y": [
5,
6,
5
],
"fill": "toself",
"opacity": 0.3
}
],
"layout": {
"title": "toself fill with opacity"
}
}

0 comments on commit 76f1c57

Please sign in to comment.