diff --git a/src/traces/bar/attributes.js b/src/traces/bar/attributes.js index 21ac947047d..25b7568bd13 100644 --- a/src/traces/bar/attributes.js +++ b/src/traces/bar/attributes.js @@ -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 }); + +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, @@ -23,6 +36,7 @@ module.exports = { y0: scatterAttrs.y0, dy: scatterAttrs.dy, text: scatterAttrs.text, + orientation: { valType: 'enumerated', role: 'info', @@ -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, diff --git a/src/traces/histogram/attributes.js b/src/traces/histogram/attributes.js index 5c687871080..757c923c190 100644 --- a/src/traces/histogram/attributes.js +++ b/src/traces/histogram/attributes.js @@ -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: { @@ -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, _nestedModules: { 'error_y': 'ErrorBars', diff --git a/test/image/baselines/bar_bargap0.png b/test/image/baselines/bar_bargap0.png new file mode 100644 index 00000000000..dfd5e98821f Binary files /dev/null and b/test/image/baselines/bar_bargap0.png differ diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index 1335843011a..ac5f5cccf95 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -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 @@ -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, @@ -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')); } diff --git a/test/image/mocks/bar_bargap0.json b/test/image/mocks/bar_bargap0.json new file mode 100644 index 00000000000..14ff09ea6b7 --- /dev/null +++ b/test/image/mocks/bar_bargap0.json @@ -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 + } +}