1

We’re creating a new piece and we’re having some limitations using the Torque function. Could you answer these questions, please?

  1. Is it possible to insert multiple colors on this function?
  2. Is there any way to change the size of the bubbles on Torque (min-max)?

I have a programmer guy on my side and he’s trying to put these new features on the css code below

/** torque visualization */

Map {
-torque-frame-count:128;
-torque-animation-duration:30;
-torque-time-attribute:"n_de_participantes";
-torque-aggregation-function:"count(cartodb_id)";
-torque-resolution:2;
-torque-data-aggregation:"cumulative";
}

#testando_o_torque {
   marker-width: 12;
   marker-opacity: 0.9;
   marker-allow-overlap: true;
   marker-placement: point;
   marker-type: ellipse;
   marker-line-width: 2;
   marker-line-color: #ffffff;
   marker-line-opacity: 1;
}

#testando_o_torque[n_de_participantes=500] {
   marker-fill: #A6CEE3;
}
#testando_o_torque[n_de_participantes=150] {
   marker-fill: #1F78B4;
}
#testando_o_torque[n_de_participantes=20] {
   marker-fill: #B2DF8A;
}
#testando_o_torque[n_de_participantes=600] {
   marker-fill: #33A02C;
}
#testando_o_torque[n_de_participantes=70] {
   marker-fill: #FB9A99;
}
#testando_o_torque[n_de_participantes=60] {
   marker-fill: #E31A1C;
}
#testando_o_torque[n_de_participantes=200] {
   marker-fill: #FDBF6F;
}
#testando_o_torque[n_de_participantes=2000] {
   marker-fill: #FF7F00;
}
#testando_o_torque[n_de_participantes=300] {
   marker-fill: #CAB2D6;
}
#testando_o_torque[n_de_participantes=6] {
   marker-fill: #6A3D9A;
}
#testando_o_torque {
   marker-fill: #DDDDDD;
}
#testando_o_torque[frame-offset=1] {
   marker-width:12.5;
   marker-opacity:0.45; 
}
#testando_o_torque[frame-offset=2] {
   marker-width:14.5;
   marker-opacity:0.225; 
}
  • Best practice is one question per thread, could you open a second thread for, 'Is there any way to change the size of the bubbles on Torque (min-max)?' with a bit of description on what you are intending? – andrewxhill Jan 9 '14 at 19:13
  • I see the second question has been posted here, gis.stackexchange.com/questions/82498/… – andrewxhill Jan 9 '14 at 20:27
1

To answer the first question, yes it should be possible. The parameter you want to compare against isn't going to be the column name as you have it, 'n_de_participantes', instead in Torque it is always referred to as 'value'

So each component would look like this,

#testando_o_torque[value=500] {
   marker-fill: #A6CEE3;
}

In full, your style would be,

/** torque visualization */

Map {
-torque-frame-count:128;
-torque-animation-duration:30;
-torque-time-attribute:"n_de_participantes";
-torque-aggregation-function:"count(cartodb_id)";
-torque-resolution:2;
-torque-data-aggregation:"cumulative";
}

#testando_o_torque {
   marker-width: 12;
   marker-opacity: 0.9;
   marker-allow-overlap: true;
   marker-placement: point;
   marker-type: ellipse;
   marker-line-width: 2;
   marker-line-color: #ffffff;
   marker-line-opacity: 1;
}

#testando_o_torque[value=500] {
   marker-fill: #A6CEE3;
}
#testando_o_torque[value=150] {
   marker-fill: #1F78B4;
}
#testando_o_torque[value=20] {
   marker-fill: #B2DF8A;
}
#testando_o_torque[value=600] {
   marker-fill: #33A02C;
}
#testando_o_torque[value=70] {
   marker-fill: #FB9A99;
}
#testando_o_torque[value=60] {
   marker-fill: #E31A1C;
}
#testando_o_torque[value=200] {
   marker-fill: #FDBF6F;
}
#testando_o_torque[value=2000] {
   marker-fill: #FF7F00;
}
#testando_o_torque[value=300] {
   marker-fill: #CAB2D6;
}
#testando_o_torque[value=6] {
   marker-fill: #6A3D9A;
}
#testando_o_torque {
   marker-fill: #DDDDDD;
}
#testando_o_torque[frame-offset=1] {
   marker-width:12.5;
   marker-opacity:0.45; 
}
#testando_o_torque[frame-offset=2] {
   marker-width:14.5;
   marker-opacity:0.225; 
}
|improve this answer|||||
2

I saw a related example that might help people. Torque works a bit differently, see https://github.com/CartoDB/torque/wiki/How-spatial-aggregation-works

A user did 3 seagulls with different colors: http://cdb.io/1aaamG1

SQL for it:

SELECT *,
CASE 
WHEN bird_name='Jurgen' THEN 1
WHEN bird_name='Anne' THEN 3
WHEN bird_name='Eric' THEN 7
END as bird_number
FROM three_gulls

Note: he initially chose 5 for Eric, but that would mean that rasters with equal amount of Jurgen and Eric (1 + 5) would have an average of 3 and look like Anne.

CSS:

Map {
-torque-frame-count:512;
-torque-animation-duration:40;
-torque-time-attribute:"date_time";
-torque-aggregation-function:"avg(bird_number)";
-torque-resolution:1;
-torque-data-aggregation:"linear";
}

#three_gulls{
  marker-type: ellipse;
  marker-width: 3;
  marker-fill: red;
  marker-opacity: 0.9;
  marker-line-width: 0.5;
  marker-line-color: #cccccc;
  marker-line-opacity: 1;
  comp-op: "multiply";
  [value >= 3] { marker-fill: #FF9900; }
  [value >= 7] { marker-fill: #2167AB; }
}
#three_gulls[frame-offset=1] {
 marker-width:5;
 marker-opacity:0.45; 
}
#three_gulls[frame-offset=2] {
 marker-width:7;
 marker-opacity:0.225;
|improve this answer|||||
  • Hmm... I wonder how sound this is. Because they are spatially AND temporally binned, you could have a pixel that contained this, Eric one time (7) and Jurgen two times (1, 1), so (7 + 1 + 1) / 3 = Anne. But Anne was never there!!! I'd guess most of the time it would work fine. Instead, you could get clever with powers and primes, but I'd have to think for a minute about it – andrewxhill Feb 6 '14 at 17:14
1

answered by mail but for the record the solution is to use:

-torque-aggregation-function:"round(avg(type_number))";
|improve this answer|||||
0

Andrew, the value that always appears here is 1. We cant't have the value of the others IDs.

We are using this SQL to use 30 bubbles:

SELECT * FROM testando_o_torque WHERE (cartodb_id < 30)

|improve this answer|||||
  • sorry, 'value' refers to the number of points that fall in that pixel. torque aggregates data, so there is always a value. if you want to style by cartodb_id or other, torque isn't the way to go. in those cases, you might be better of with D3 or another client side rending tool. – andrewxhill Jan 10 '14 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.