Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0725ea4

Browse filesBrowse files
authored
Merge pull request plotly#709 from plotly/fix-bargap-0
Fix bargap 0 bug
2 parents e421c63 + f98334c commit 0725ea4
Copy full SHA for 0725ea4

File tree

5 files changed

+80
-26
lines changed
Filter options

5 files changed

+80
-26
lines changed

‎src/traces/bar/attributes.js

Copy file name to clipboardExpand all lines: src/traces/bar/attributes.js
+16-8Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ var extendFlat = require('../../lib/extend').extendFlat;
1515
var scatterMarkerAttrs = scatterAttrs.marker;
1616
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
1717

18+
var markerLineWidth = extendFlat({},
19+
scatterMarkerLineAttrs.width, { dflt: 0 });
20+
21+
var markerLine = extendFlat({}, {
22+
width: markerLineWidth
23+
}, colorAttributes('marker.line'));
24+
25+
var marker = extendFlat({}, {
26+
showscale: scatterMarkerAttrs.showscale,
27+
line: markerLine
28+
}, colorAttributes('marker'));
29+
30+
1831
module.exports = {
1932
x: scatterAttrs.x,
2033
x0: scatterAttrs.x0,
@@ -23,6 +36,7 @@ module.exports = {
2336
y0: scatterAttrs.y0,
2437
dy: scatterAttrs.dy,
2538
text: scatterAttrs.text,
39+
2640
orientation: {
2741
valType: 'enumerated',
2842
role: 'info',
@@ -33,14 +47,8 @@ module.exports = {
3347
'along the vertical (horizontal).'
3448
].join(' ')
3549
},
36-
marker: extendFlat({}, {
37-
showscale: scatterMarkerAttrs.showscale,
38-
line: extendFlat({},
39-
{width: scatterMarkerLineAttrs.width},
40-
colorAttributes('marker.line')
41-
)},
42-
colorAttributes('marker')
43-
),
50+
51+
marker: marker,
4452

4553
r: scatterAttrs.r,
4654
t: scatterAttrs.t,

‎src/traces/histogram/attributes.js

Copy file name to clipboardExpand all lines: src/traces/histogram/attributes.js
+1-13Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
'use strict';
1010

1111
var barAttrs = require('../bar/attributes');
12-
var colorAttributes = require('../../components/colorscale/color_attributes');
1312

14-
var extendFlat = require('../../lib/extend').extendDeep;
15-
16-
var barMarkerAttrs = barAttrs.marker;
17-
var barMarkerLineAttrs = barMarkerAttrs.line;
1813

1914
module.exports = {
2015
x: {
@@ -124,14 +119,7 @@ module.exports = {
124119
},
125120
ybins: makeBinsAttr('y'),
126121

127-
marker: extendFlat({}, {
128-
showscale: barMarkerAttrs.showscale,
129-
line: extendFlat({},
130-
{width: extendFlat({}, barMarkerLineAttrs.width, {dflt: 0})},
131-
colorAttributes('marker.line'))
132-
},
133-
colorAttributes('marker')
134-
),
122+
marker: barAttrs.marker,
135123

136124
_nestedModules: {
137125
'error_y': 'ErrorBars',

‎test/image/baselines/bar_bargap0.png

Copy file name to clipboard
16.2 KB
Loading

‎test/image/compare_pixels_test.js

Copy file name to clipboardExpand all lines: test/image/compare_pixels_test.js
+23-5Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ function comparePixels(mockName, cb) {
147147
saveImageStream = fs.createWriteStream(imagePaths.test);
148148

149149
function checkImage() {
150-
var gmOpts = {
151-
file: imagePaths.diff,
152-
highlightColor: 'purple',
153-
tolerance: TOLERANCE
154-
};
150+
151+
// baseline image must be generated first
152+
if(!doesFileExist(imagePaths.baseline)) {
153+
var err = new Error('baseline image not found');
154+
return onEqualityCheck(err, false);
155+
}
155156

156157
/*
157158
* N.B. The non-zero tolerance was added in
@@ -169,6 +170,12 @@ function comparePixels(mockName, cb) {
169170
* Further investigation is needed.
170171
*/
171172

173+
var gmOpts = {
174+
file: imagePaths.diff,
175+
highlightColor: 'purple',
176+
tolerance: TOLERANCE
177+
};
178+
172179
gm.compare(
173180
imagePaths.test,
174181
imagePaths.baseline,
@@ -194,6 +201,17 @@ function comparePixels(mockName, cb) {
194201
.on('close', checkImage);
195202
}
196203

204+
function doesFileExist(filePath) {
205+
try {
206+
if(fs.statSync(filePath).isFile()) return true;
207+
}
208+
catch(e) {
209+
return false;
210+
}
211+
212+
return false;
213+
}
214+
197215
function touch(filePath) {
198216
fs.closeSync(fs.openSync(filePath, 'w'));
199217
}

‎test/image/mocks/bar_bargap0.json

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"data": [
3+
{
4+
"x": [
5+
"giraffes",
6+
"orangutans",
7+
"monkeys"
8+
],
9+
"y": [
10+
20,
11+
14,
12+
23
13+
],
14+
"name": "SF Zoo",
15+
"type": "bar"
16+
}
17+
],
18+
"layout": {
19+
"bargap": 0,
20+
"xaxis": {
21+
"type": "category",
22+
"range": [
23+
-0.5,
24+
2.5
25+
],
26+
"autorange": true
27+
},
28+
"yaxis": {
29+
"type": "linear",
30+
"range": [
31+
0,
32+
24.210526315789473
33+
],
34+
"autorange": true
35+
},
36+
"height": 450,
37+
"width": 1100,
38+
"autosize": false
39+
}
40+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.