var vlEncDef = require('../encdef');
var consts_1 = require('../consts');
function default_1(encoding, stats) {
return {
opacity: estimateOpacity(encoding, stats),
};
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
;
function estimateOpacity(encoding, stats) {
Iif (!stats) {
return 1;
}
var numPoints = 0;
if (encoding.isAggregate()) {
numPoints = 1;
encoding.forEach(function (encDef, encType) {
if (encType !== consts_1.Enctype.ROW && encType !== consts_1.Enctype.COL &&
!((encType === consts_1.Enctype.X || encType === consts_1.Enctype.Y) &&
vlEncDef.isOrdinalScale(encDef))) {
numPoints *= encoding.cardinality(encType, stats);
}
});
}
else {
if (!stats['*'])
return 1;
numPoints = stats['*'].max;
var numMultiples = 1;
Iif (encoding.has(consts_1.Enctype.ROW)) {
numMultiples *= encoding.cardinality(consts_1.Enctype.ROW, stats);
}
if (encoding.has(consts_1.Enctype.COL)) {
numMultiples *= encoding.cardinality(consts_1.Enctype.COL, stats);
}
numPoints /= numMultiples;
}
var opacity = 0;
if (numPoints <= 25) {
opacity = 1;
}
else if (numPoints < 200) {
opacity = 0.8;
}
else if (numPoints < 1000 || encoding.is('tick')) {
opacity = 0.7;
}
else {
opacity = 0.3;
}
return opacity;
}
//# sourceMappingURL=style.js.map |