Skip to content

Commit

Permalink
[FE-17393] Add queryoverride propery (#664)
Browse files Browse the repository at this point in the history
* Add queryoverride propery

* Rebuild dist

---------

Co-authored-by: Joseph O'Hallaron <joe.ohallaron@heavy.ai>
  • Loading branch information
cmatzenbach and johallar authored Jan 10, 2024
1 parent 033fd37 commit be60779
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 54 deletions.
40 changes: 23 additions & 17 deletions dist/charting.js
Original file line number Diff line number Diff line change
Expand Up @@ -32565,6 +32565,11 @@ function rasterLayerPointMixin(_layer) {
var state = null;
_layer.colorDomain = Object(__WEBPACK_IMPORTED_MODULE_1__utils_utils_vega__["c" /* createRasterLayerGetterSetter */])(_layer, null);
_layer.sizeDomain = Object(__WEBPACK_IMPORTED_MODULE_1__utils_utils_vega__["c" /* createRasterLayerGetterSetter */])(_layer, null);

/**
* If provided, this query will be used in the vega spec instead of being generated from
*/
_layer.queryOverride = Object(__WEBPACK_IMPORTED_MODULE_1__utils_utils_vega__["c" /* createRasterLayerGetterSetter */])(_layer, null);
_layer.setState = function (setter) {
if (typeof setter === "function") {
state = setter(state);
Expand Down Expand Up @@ -32812,7 +32817,8 @@ function rasterLayerPointMixin(_layer) {
lastFilteredSize = _ref2.lastFilteredSize,
globalFilter = _ref2.globalFilter,
pixelRatio = _ref2.pixelRatio,
layerName = _ref2.layerName;
layerName = _ref2.layerName,
queryOverride = _ref2.queryOverride;
var autocolors = usesAutoColors();
var autosize = usesAutoSize();
var getStatsLayerName = function getStatsLayerName() {
Expand All @@ -32823,36 +32829,35 @@ function rasterLayerPointMixin(_layer) {
var data = [];
if (state.encoding.color.prioritizedColor && state.encoding.color.prioritizedColor.length > 0 && layerName !== "backendScatter") {
for (var i = 0; i < state.encoding.color.prioritizedColor.length; i++) {
var transform = _layer.getTransforms(table, filter + " AND ".concat(state.encoding.color.field, " = '").concat(state.encoding.color.prioritizedColor[i].value, "'"), globalFilter, state, lastFilteredSize);
var sql = __WEBPACK_IMPORTED_MODULE_2__utils_utils__["i" /* parser */].writeSQL({
type: "root",
source: table,
transform: transform
});
if (layerName.includes("_z".concat(i * 2))) {
data = [{
name: layerName,
sql: __WEBPACK_IMPORTED_MODULE_2__utils_utils__["i" /* parser */].writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(table, filter + " AND ".concat(state.encoding.color.field, " != '").concat(state.encoding.color.prioritizedColor[i].value, "'"), globalFilter, state, lastFilteredSize)
}),
sql: queryOverride || sql,
enableHitTesting: state.enableHitTesting
}];
} else if (layerName.includes("_z".concat(i * 2 + 1))) {
data = [{
name: layerName,
sql: __WEBPACK_IMPORTED_MODULE_2__utils_utils__["i" /* parser */].writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(table, filter + " AND ".concat(state.encoding.color.field, " = '").concat(state.encoding.color.prioritizedColor[i].value, "'"), globalFilter, state, lastFilteredSize)
}),
sql: queryOverride || sql,
enableHitTesting: state.enableHitTesting
}];
}
}
} else {
var _sql = __WEBPACK_IMPORTED_MODULE_2__utils_utils__["i" /* parser */].writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(table, filter, globalFilter, state, lastFilteredSize)
});
data = [{
name: layerName,
sql: __WEBPACK_IMPORTED_MODULE_2__utils_utils__["i" /* parser */].writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(table, filter, globalFilter, state, lastFilteredSize)
}),
sql: queryOverride || _sql,
enableHitTesting: state.enableHitTesting
}];
}
Expand Down Expand Up @@ -32980,7 +32985,8 @@ function rasterLayerPointMixin(_layer) {
filter: _layer.crossfilter().getFilterString(realLayerName),
globalFilter: _layer.crossfilter().getGlobalFilterString(),
lastFilteredSize: Object(__WEBPACK_IMPORTED_MODULE_0__core_core_async__["g" /* lastFilteredSize */])(_layer.crossfilter().getId()),
pixelRatio: chart._getPixelRatio()
pixelRatio: chart._getPixelRatio(),
queryOverride: _layer.queryOverride()
});
return _vega;
};
Expand Down
73 changes: 36 additions & 37 deletions src/mixins/raster-layer-point-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ export default function rasterLayerPointMixin(_layer) {
_layer.colorDomain = createRasterLayerGetterSetter(_layer, null)
_layer.sizeDomain = createRasterLayerGetterSetter(_layer, null)

/**
* If provided, this query will be used in the vega spec instead of being generated from
*/
_layer.queryOverride = createRasterLayerGetterSetter(_layer, null)

_layer.setState = function(setter) {
if (typeof setter === "function") {
state = setter(state)
Expand Down Expand Up @@ -461,7 +466,8 @@ export default function rasterLayerPointMixin(_layer) {
lastFilteredSize,
globalFilter,
pixelRatio,
layerName
layerName,
queryOverride
}) {
const autocolors = usesAutoColors()
const autosize = usesAutoSize()
Expand All @@ -486,61 +492,53 @@ export default function rasterLayerPointMixin(_layer) {
layerName !== "backendScatter"
) {
for (let i = 0; i < state.encoding.color.prioritizedColor.length; i++) {
const transform = _layer.getTransforms(
table,
filter +
` AND ${state.encoding.color.field} = '${state.encoding.color.prioritizedColor[i].value}'`,
globalFilter,
state,
lastFilteredSize
)
const sql = parser.writeSQL({
type: "root",
source: table,
transform
})
if (layerName.includes(`_z${i * 2}`)) {
data = [
{
name: layerName,
sql: parser.writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(
table,
filter +
` AND ${state.encoding.color.field} != '${state.encoding.color.prioritizedColor[i].value}'`,
globalFilter,
state,
lastFilteredSize
)
}),
sql: queryOverride || sql,
enableHitTesting: state.enableHitTesting
}
]
} else if (layerName.includes(`_z${i * 2 + 1}`)) {
data = [
{
name: layerName,
sql: parser.writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(
table,
filter +
` AND ${state.encoding.color.field} = '${state.encoding.color.prioritizedColor[i].value}'`,
globalFilter,
state,
lastFilteredSize
)
}),
sql: queryOverride || sql,
enableHitTesting: state.enableHitTesting
}
]
}
}
} else {
const sql = parser.writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(
table,
filter,
globalFilter,
state,
lastFilteredSize
)
})
data = [
{
name: layerName,
sql: parser.writeSQL({
type: "root",
source: table,
transform: _layer.getTransforms(
table,
filter,
globalFilter,
state,
lastFilteredSize
)
}),
sql: queryOverride || sql,
enableHitTesting: state.enableHitTesting
}
]
Expand Down Expand Up @@ -709,7 +707,8 @@ export default function rasterLayerPointMixin(_layer) {
filter: _layer.crossfilter().getFilterString(realLayerName),
globalFilter: _layer.crossfilter().getGlobalFilterString(),
lastFilteredSize: lastFilteredSize(_layer.crossfilter().getId()),
pixelRatio: chart._getPixelRatio()
pixelRatio: chart._getPixelRatio(),
queryOverride: _layer.queryOverride()
})

return _vega
Expand Down

0 comments on commit be60779

Please sign in to comment.