Biden - Trump polling map - using visualping.io

Hi all. This 'map' is based on the '2020 Electoral Map Based on Polls' (270towin.com). Since I have no dynamic data feed, I use a very usefull tool: visualping.io Visualping monitors webpages of your choice and reports changes via mail (changes in text or visual compare). You can even select parts of the page (in this case the map) to be monitored. So I can update my infographic whenever I receive a respective mail. May be, this tool is interesting for you, too.

http://d30slvg82xq0j0.cloudfront.net/customers/client/aws/my/html/setup.html?numGraphic=101401

image

4 Likes

Thanks for sharing this, glad to know we have the interest of other democracies and individuals in this historic election!

3 Likes

I can tell you - we are more than excited...

'https://www.270towin.com/polls/php/get-early-polls.php?election_year=2020&candidate_name_rep=Trump&candidate_name_dem=Biden&sort_by=date'

if this is the data i'd guess you can use php curl to retrieve it via a js fetch ...

<?php

$csvUrl = $_POST['csvFile'];


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $csvUrl);

$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_VERBOSE, true);

curl_setopt($ch, CURLOPT_USERAGENT, $agent);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); //time out of 15 seconds

$data = curl_exec($ch);


curl_close($ch);

?>

Thanks Hans! Unfortunately I don´t know php... but I have colleagues how do :slight_smile: I´ll ask them for assistance.

Here is an example using HypeDataMagic:

UPDATE: Old example download removed as the source has evolved

While putting, it together I first used fetchData to have live data but I realized that still needs some work done. I might even take it out and leave it to the user to manage remote data. This now uses hard-coded data as a JSON datastring but that could be updated from time to time using the PHP approach.

3 Likes

Thanks Max for this. Please help me: What actually is the advantage of using HypeDataMagic? Is there a description/documentation available of what it does in detail? In my map I do the coloring via HTML-attributes - so does HypeDataMagic. So - if I had set up a json-feed it would need just a few lines of code to do this.

The main advantage is that the coloring is connected directly to the JSON you parse and set. About the documentation: There is currently non as I was refactoring code but then had some client work. In general I will simplify it as much as possible and remove some things to really have the core version be as sleek as possible.

Basic concept is that you can use the data-magic-key to define the connected data point. So, first you set some data and then you directly link it. The benefit being it is updated immediately when you change the data. And if you use handler like in this example you even get a live preview in the Hype IDE.

1 Like

Thanks Max, this helps!