plotly.js
Version:
The open source javascript graphing library that powers plotly
50 lines (37 loc) • 1.38 kB
JavaScript
/**
* Copyright 2012-2020, 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.
*/
;
var Lib = require('../../lib');
var colorscaleDefaults = require('../../components/colorscale/defaults');
var attributes = require('./attributes');
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
var locations = coerce('locations');
var z = coerce('z');
var geojson = coerce('geojson');
if(!Lib.isArrayOrTypedArray(locations) || !locations.length ||
!Lib.isArrayOrTypedArray(z) || !z.length ||
!((typeof geojson === 'string' && geojson !== '') || Lib.isPlainObject(geojson))
) {
traceOut.visible = false;
return;
}
coerce('featureidkey');
traceOut._length = Math.min(locations.length, z.length);
coerce('below');
coerce('text');
coerce('hovertext');
coerce('hovertemplate');
var mlw = coerce('marker.line.width');
if(mlw) coerce('marker.line.color');
coerce('marker.opacity');
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'});
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
};