Wednesday 22 March 2017

carto - Using different colors on Torque CartoDB


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;
}

Answer



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;
}

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...