src/components/heatmap/utils.js
/**
 * Called before a layer is drawn to determine whether it should be rendered.
 * Reference: https://deck.gl/docs/api-reference/core/deck#layerfilter
 * @param {object} params A viewport, layer pair.
 * @param {object} params.layer The layer to check.
 * @param {object} params.viewport The viewport to check.
 * @returns {boolean} Should this layer be rendered in this viewport?
 */
Called before a layer is drawn to determine whether it should be rendered.
Called before a layer is drawn to determine whether it should be rendered .
function layerFilter({ layer, viewport }) {
  if (viewport.id === 'axisLeft') {
    return layer.id.startsWith('axisLeft');
  }
  if (viewport.id === 'axisTop') {
    return layer.id.startsWith('axisTop');
  }
  if (viewport.id.startsWith('cellColorLabel')) {
    const matches = viewport.id.match(/-(\d)/);
    if (matches) return layer.id.startsWith(`cellColorLabelLayer-${matches[1]}`);
  }
  if (viewport.id === 'heatmap') {
    return layer.id.startsWith('heatmap');
  }
  if (viewport.id.startsWith('colorsLeft')) {
    const matches = viewport.id.match(/-(\d)/);
    if (matches) return layer.id.startsWith(`colorsLeftLayer-${matches[1]}`);
  }
  if (viewport.id.startsWith('colorsTop')) {
    const matches = viewport.id.match(/-(\d)/);
    if (matches) return layer.id.startsWith(`colorsTopLayer-${matches[1]}`);
  }
  return false;
}
function layerFilter ( { layer , viewport } ) { if ( viewport . id === 'axisLeft' ) { return layer . id . startsWith ( 'axisLeft' ) ; } if ( viewport . id === 'axisTop' ) { return layer . id . startsWith ( 'axisTop' ) ; } if ( viewport . id . startsWith ( 'cellColorLabel' ) ) { const matches = viewport . id . match ( / -(\d) / ) ; if ( matches ) return layer . id . startsWith ( ` ${ matches [ 1 ] } ` ) ; } if ( viewport . id === 'heatmap' ) { return layer . id . startsWith ( 'heatmap' ) ; } if ( viewport . id . startsWith ( 'colorsLeft' ) ) { const matches = viewport . id . match ( / -(\d) / ) ; if ( matches ) return layer . id . startsWith ( ` ${ matches [ 1 ] } ` ) ; } if ( viewport . id . startsWith ( 'colorsTop' ) ) { const matches = viewport . id . match ( / -(\d) / ) ; if ( matches ) return layer . id . startsWith ( ` ${ matches [ 1 ] } ` ) ; } return false ; }
Called before a layer is drawn to determine whether it should be rendered.
Called before a layer is drawn to determine whether it should be rendered .