question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make aggregated values available for labels

See original GitHub issue

Use case: We want to make a cluster map. We can use our clusterCount function for that, for example:

const viz = new carto.Viz(`
  @c_count: clusterCount()
  
  color: red
  width: @c_count
  resolution: 16
`);

It’s a common convention for cluster maps to be labeled with the number of features represented by the cluster marker:

screen shot 2019-01-24 at 6 52 59 pm

However we can’t use the clusterCount in a label.

Right now VL requires us to use an original dataset attribute for labels instead, like in this example: https://carto.com/developers/carto-vl/examples/#example-point-labels

const viz = new carto.Viz(`
  @c_count: clusterCount()
  @v_features: viewportFeatures($poi_name)
  
  color: red
  width: @c_count
  resolution: 16
`);

....
const features = viz.variables.v_features.value;
...
"label_field": `${f.properties['poi_name']}`,

Can we create a way to use aggregated values for labels, so something like this would work?

const viz = new carto.Viz(`
        color: fuchsia
        width: 6
        strokeColor: white
        strokeWidth: 2
        filter: $major == "YES"
        @cc: clusterCount()
        @v_features: viewportFeatures($poi_name, @cc)
      `);

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
elenatorrocommented, Feb 15, 2019

Merged in master ✨ We’ll have to document it properly and research how can we improve the labels visualization. Meanwhile, we’ve added a couple of examples 👍

1reaction
ramiroaznarcommented, Feb 14, 2019

Also, you can use Gencat data as I did in this example (not working because of the API Key)

https://bl.ocks.org/ramiroaznar/f856209982304290f1152828a7bf7f2b

Read more comments on GitHub >

github_iconTop Results From Across the Web

Aggregate values into related features—ArcGIS Pro
You can visualize features through aggregation by precomputing the values or by using query ... Run the Make Aggregation Query Layer geoprocessing tool....
Read more >
Labels by datapoint and aggregation on label for single serie?
QUESTION : Is aggregation on labels possible? I have a form which accepts 20 -25 inputs , now i have to get time...
Read more >
Data Aggregation in Tableau
When you add a measure to the view, Tableau automatically aggregates its values. Sum, average, and median are common aggregations; for a complete...
Read more >
How to aggregate rows with inverse labels? - sql
LGA-LAX and LAX-LGA are both one-ways on a single route, and so I want to combine them into a single row with aggregated...
Read more >
Aggregate data - IBM
Aggregate Data aggregates groups of cases into single cases and creates a new aggregated file, or creates new variables in the active dataset...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found