Skip to content

Fix bargap 0 bug #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/traces/bar/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ var extendFlat = require('../../lib/extend').extendFlat;
var scatterMarkerAttrs = scatterAttrs.marker;
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;

var markerLineWidth = extendFlat({},
scatterMarkerLineAttrs.width, { dflt: 0 });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it is!


var markerLine = extendFlat({}, {
width: markerLineWidth
}, colorAttributes('marker.line'));

var marker = extendFlat({}, {
showscale: scatterMarkerAttrs.showscale,
line: markerLine
}, colorAttributes('marker'));


module.exports = {
x: scatterAttrs.x,
x0: scatterAttrs.x0,
Expand All @@ -23,6 +36,7 @@ module.exports = {
y0: scatterAttrs.y0,
dy: scatterAttrs.dy,
text: scatterAttrs.text,

orientation: {
valType: 'enumerated',
role: 'info',
Expand All @@ -33,14 +47,8 @@ module.exports = {
'along the vertical (horizontal).'
].join(' ')
},
marker: extendFlat({}, {
showscale: scatterMarkerAttrs.showscale,
line: extendFlat({},
{width: scatterMarkerLineAttrs.width},
colorAttributes('marker.line')
)},
colorAttributes('marker')
),

marker: marker,

r: scatterAttrs.r,
t: scatterAttrs.t,
Expand Down
14 changes: 1 addition & 13 deletions src/traces/histogram/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
'use strict';

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

var extendFlat = require('../../lib/extend').extendDeep;

var barMarkerAttrs = barAttrs.marker;
var barMarkerLineAttrs = barMarkerAttrs.line;

module.exports = {
x: {
Expand Down Expand Up @@ -124,14 +119,7 @@ module.exports = {
},
ybins: makeBinsAttr('y'),

marker: extendFlat({}, {
showscale: barMarkerAttrs.showscale,
line: extendFlat({},
{width: extendFlat({}, barMarkerLineAttrs.width, {dflt: 0})},
colorAttributes('marker.line'))
},
colorAttributes('marker')
),
marker: barAttrs.marker,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaner, right?


_nestedModules: {
'error_y': 'ErrorBars',
Expand Down
Binary file added test/image/baselines/bar_bargap0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 23 additions & 5 deletions test/image/compare_pixels_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ function comparePixels(mockName, cb) {
saveImageStream = fs.createWriteStream(imagePaths.test);

function checkImage() {
var gmOpts = {
file: imagePaths.diff,
highlightColor: 'purple',
tolerance: TOLERANCE
};

// baseline image must be generated first
if(!doesFileExist(imagePaths.baseline)) {
var err = new Error('baseline image not found');
return onEqualityCheck(err, false);
}

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

var gmOpts = {
file: imagePaths.diff,
highlightColor: 'purple',
tolerance: TOLERANCE
};

gm.compare(
imagePaths.test,
imagePaths.baseline,
Expand All @@ -194,6 +201,17 @@ function comparePixels(mockName, cb) {
.on('close', checkImage);
}

function doesFileExist(filePath) {
try {
if(fs.statSync(filePath).isFile()) return true;
}
catch(e) {
return false;
}

return false;
}

function touch(filePath) {
fs.closeSync(fs.openSync(filePath, 'w'));
}
40 changes: 40 additions & 0 deletions test/image/mocks/bar_bargap0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"data": [
{
"x": [
"giraffes",
"orangutans",
"monkeys"
],
"y": [
20,
14,
23
],
"name": "SF Zoo",
"type": "bar"
}
],
"layout": {
"bargap": 0,
"xaxis": {
"type": "category",
"range": [
-0.5,
2.5
],
"autorange": true
},
"yaxis": {
"type": "linear",
"range": [
0,
24.210526315789473
],
"autorange": true
},
"height": 450,
"width": 1100,
"autosize": false
}
}