CartoDB/carto-react

FormulaWidget issue with mode global disabled

menusal opened this issue · 14 comments

FormulaWidget does not show values in different projects.

This strange behavior also happens in Builder with long datasets.

In this case, we use a dataset with 1.4M of rows.

We are trying to use the C4R FormulaWidget with the following source and trying different combinations:

const POS_SOURCE_ID = 'posSource'

const source = {
  id: POS_SOURCE_ID,
  type: MAP_TYPES.TABLE,
  connection: 'xxxxx',
  data: 'xxxxxxxxxxxx.shared.usa_pos',
}
export default source

View component:

import posSource from '@/data/sources/posSource'
...

<FormulaWidget
    id='mechants'
    title='Formula TEST C4R'
    dataSource={posSource.id}
    column='geoid'
    operation={AggregationTypes.COUNT}
    wrapperProps={{
        disabled:false,
    }}
    global={false}
    onError={console.error}
/>

When reducing the zoom levels to show data, the FormulaWidget stays with the infinite loader, gives no error on the console, and does not display any data even when the zoom level is 20.

Steps we have tried:

  • Change the source to type QUERY and limit to 100.
  • Create a new source of type TILESET with a tileset demo carto-demo-data.demo_tilesets.covid19_vaccinated_usa_tileset.
  • Navigate through different zoom levels.

In none of the scenarios does it works with none of these versions:

  • C4R: 1.2.1
  • C4R: 1.3.0
  • C4R: 1.4.0-alpha.4

@menusal can you create a map in builder and share it (with password if you want)? It sounds like a problem with data

Checking the map I can say that the widget doesn't show data because of dropping features. @VictorVelarde we should fix the infinite loading on C4R side.

It'll be fixed with this https://github.com/CartoDB/cloud-native/pull/8919 where we're removing the aggregation of points.

The current behavior for layers using dynamic tiles is that if two points have the same coordinates will always be aggregated so the widget says that you should zoom in because some data is missing in the calculation.

Dynamic tiling is used for tables larger than 30MB or queries. So that's why it also happens with a limit 1000.

Using your query you can see how you already have duplicated points:

select st_x(geom), st_y(geom), count(*) as n from carto-dw-ac-glcwr7d.shared.usa_pos
group by st_x(geom), st_y(geom)
order by n desc

image

Of course it's wrong and will be fixed with this https://github.com/CartoDB/cloud-native/pull/8919. Can you try to use that dedicated and verify it's solved there? I would like to deploy it today or tomorrow.

cc: @moimart

@alasarr, we don't have enough knowledge to test with a dedicated server, we need support.

So if you've tried it, merge it when you can.

@alasarr, we don't have enough knowledge to test with a dedicated server, we need support.

So if you've tried it, merge it when you can.

@aaranadev if you open the PR that @alasarr comment (https://github.com/CartoDB/cloud-native/pull/8919) you will see in the comments something like this:
Captura de pantalla 2022-09-06 a las 13 23 52

https://app-12.dev.carto.com/ is the link of the dedicated, you only need to sing up in this dedicated with your carto account and you will have access to the cloud-native version deployed in this dedicated

Ohh great! Thank you @padawannn

Hey guys we've been trying to create a simple FormulaWidget from a tileset (carto-dw-ac-g1ktp5ij.shared.acs_sociodemogr_de06bf47) in located in https://app-12.dev.carto.com/ ded with no luck. Please @padawannn @alasarr could you take a look? I'm not sure what's happening:

<FormulaWidget
  id='total-population-widget'
  title='Total population'
  dataSource={DEMOGRAPHICS_SOURCE_ID}
  column='total_pop'
  operation={AggregationTypes.COUNT}
/>

cc @aaranadev @menusal

Hey guys we've been trying to create a simple FormulaWidget from a tileset (carto-dw-ac-g1ktp5ij.shared.acs_sociodemogr_de06bf47) in located in https://app-12.dev.carto.com/ ded with no luck. Please @padawannn @alasarr could you take a look? I'm not sure what's happening:

<FormulaWidget
  id='total-population-widget'
  title='Total population'
  dataSource={DEMOGRAPHICS_SOURCE_ID}
  column='total_pop'
  operation={AggregationTypes.COUNT}
/>

cc @aaranadev @menusal

@AdriSolid can you publish the map and send us the link? If data are private you can publish it under a password

Sorry for the noise guys, we just found the problem, if using onDataLoad prop we must call that method from useCartoLayerProps response, i.e:

onDataLoad: (data: TileJson) => {
  const targetAttribute = data.tilestats.layers[0].attributes.find(
    (attribute: TileJsonAttribute) => {
      return attribute.attribute === STYLE_PROP
    },
  )
  targetAttribute && setTilestat(targetAttribute)

  cartoLayerProps?.onDataLoad?.(data) // NOTICE THIS
},

cc @aaranadev @menusal

Sorry for the noise guys, we just found the problem, if using onDataLoad prop we must call that method from useCartoLayerProps response, i.e:

onDataLoad: (data: TileJson) => {
  const targetAttribute = data.tilestats.layers[0].attributes.find(
    (attribute: TileJsonAttribute) => {
      return attribute.attribute === STYLE_PROP
    },
  )
  targetAttribute && setTilestat(targetAttribute)

  cartoLayerProps?.onDataLoad?.(data) // NOTICE THIS
},

cc @aaranadev @menusal

So I understand that everything works with the dedicated, right?

From my side using that tileset it's okey

Please confirm, so we can close the issue once ded code lands prod

From my side using table source with the dedicated, it's ok.