3

I am trying to show percentage data in the hover infowindow function.The percentages are being reflected as decimals since that is how the data was uploaded.

How can I tell CartoDB to multiply the values for this data column by 100 for when it is being shown in the infowindow without having to adjust the original data?

enter image description here

  • possible duplicate of How can I show numbers as percentages in CartoDB? – iriberri Aug 26 '15 at 14:21
  • Thanks iriberri. I reviewed the page you suggested but it is still unclear to me where I should add the suggested code. Could you review my response on that page and provide additional advice? Thanks. – Danny Aug 26 '15 at 14:51
  • @iriberri, he is asking how to do it in an info window without changing the original data, ie, no SQL query, so presumably using mustache template somehow? – John Powell Aug 26 '15 at 15:04
  • I just figured out a way to address my question. Please see the link to the previous thread provided by iriberri. – Danny Aug 26 '15 at 15:53
  • Fair point @JohnBarça – iriberri Sep 1 '15 at 10:17
3

If your information is already prepared in the way you're showing and you're just missing the percentage, there's a super straightforward trick for you.

You can edit the custom HTML of the infowindows, which means that besides selecting which columns and titles are going to be shown there, you can also play with them a bit.

The workaround is easy: you just need to write a '%' character after your column names in the custom HTML code of your infowindows. Notice that infowindows use Mustache templates, so if you see {{column_name}} this means that the information of that column for your specific point will be added there when clicked.

With this idea, you can just use "{{column_name}}%" in order to insert a percentage symbol at the end.

Let me add this visually for it to be more straightforward:

example

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.