{"id":15907,"date":"2022-11-16T08:58:24","date_gmt":"2022-11-16T08:58:24","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=15907"},"modified":"2022-11-17T23:49:22","modified_gmt":"2022-11-17T23:49:22","slug":"bubble-maps-js","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/","title":{"rendered":"How to Make Bubble Maps in JavaScript"},"content":{"rendered":"<p><a href=\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\"><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png\" alt=\"Bubble Maps in JavaScript HTML5\" width=\"100%\" class=\"alignnone size-full wp-image-15915\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png 1200w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-300x169.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-768x432.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-1024x576.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a>Map charts are a great way to put data in a geographical context. And they are not difficult to create! I am eager to demonstrate that by walking you through the creation of a <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/bubble-map\/\">bubble map<\/a>, one of the most popular types <a href=\"https:\/\/www.anychart.com\/chartopedia\/usage-type\/chart-to-show-location\/\">data maps<\/a>, with the help of JavaScript.<\/p>\n<p>A bubble map is a combination of a <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/bubble-chart\/\">bubble chart<\/a> and a geographical map. It uses circles of different sizes (and sometimes colors) to indicate numeric values relating to locations or territories.<\/p>\n<p>In this tutorial, I will be visualizing the data on gasoline prices across the United States. They saw record highs this summer after a surge fueled by the outbreak of the Russia\u2013Ukraine conflict. The first, basic bubble map will display the gas prices in July by state. The final one will add the magnitude of the change since February 23, one day before Russia launched an attack on Ukraine.<\/p>\n<p>Follow along and you\u2019ll learn to build beautiful interactive maps in JS with ease and no problem!<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2>Final JS Bubble Map Preview<\/h2>\n<p>Check out the final result of the JavaScript-based bubble mapping in this tutorial:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-javascript.png\" alt=\"Custom bubble map built along this guide\" width=\"100%\" class=\"alignnone size-full wp-image-15917\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-javascript.png 1200w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-javascript-300x173.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-javascript-768x442.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-javascript-1024x589.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<h2>Basic JavaScript Bubble Map in 4 Steps<\/h2>\n<p>Creating interactive JS bubble maps from scratch might seem daunting and tedious. But I will show you how to do it with ease and fun.<\/p>\n<p>Generally speaking, there are four fundamental steps to build a basic bubble map, just like any other chart: prepare a web page, add JavaScript files, load data, and write some charting code. Let\u2019s do that!<\/p>\n<h3>1. Prepare a web page<\/h3>\n<p>First things first. I create a blank web page. Then I add a block-level HTML element (<code>div<\/code>) as the placeholder for the bubble map; I also give it a unique id (<code>container<\/code>) and set some styling.<\/p>\n<p>Here is how my HTML page looks now:<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Bubble Map&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;style type=\"text\/css\"&gt;      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0html, body, #container { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0width: 100%; height: 100%; margin: 0; padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0&lt;\/style&gt;\r\n\u00a0\u00a0&lt;\/head&gt;\r\n\u00a0\u00a0&lt;body&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\u00a0\u00a0&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>I want the visualization to be displayed over the entire screen. So I\u2019ve set the width and height of the placeholder <code>div<\/code> element as 100%. Feel free to change that as you see fit in your situation.<\/p>\n<h3>2. Add JavaScript files<\/h3>\n<p>Second, all the JS files that will be used to make a bubble map must be added to the web page. That is done by adding the corresponding links wrapped in the <code>script<\/code> tags to the <code>head<\/code> section.<\/p>\n<p>To make it all quick and straightforward, I will use the JavaScript charting library called <a href=\"https:\/\/www.anychart.com\">AnyChart<\/a>, precisely the <a href=\"https:\/\/www.anychart.com\/products\/anymap\/\">AnyMap<\/a> solution. So, I include the two modules needed to build bubble maps, \u201ccore\u201d and \u201cgeo maps\u201d, as well as the geodata file for the United States.<\/p>\n<p>Then I prepare a place for the future JS mapping code itself by adding the <code>script<\/code> tag to the <code>body<\/code> section (basically, this tag can be put anywhere across the page).<\/p>\n<p>See what my HTML page looks like now:<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Bubble Map&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-map.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/geodata\/countries\/united_states_of_america\/united_states_of_america.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;style type=\"text\/css\"&gt;      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0html, body, #container { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0width: 100%; height: 100%; margin: 0; padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0&lt;\/style&gt;\r\n\u00a0\u00a0&lt;\/head&gt;\r\n\u00a0\u00a0&lt;body&gt;  \r\n\u00a0\u00a0\u00a0\u00a0&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ The place for the JavaScript bubble mapping code.\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/script&gt;\r\n\u00a0\u00a0&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>3. Load data<\/h3>\n<p>Third, I add my data.<\/p>\n<p>There are multiple <a href=\"https:\/\/docs.anychart.com\/Working_with_Data\" target=\"_blank\" rel=\"nofollow\">data formats<\/a> that can be used. I decided to go with JSON and created a data file with the <a href=\"https:\/\/gasprices.aaa.com\/state-gas-price-averages\/\" target=\"_blank\" rel=\"nofollow\">prices<\/a> of regular gasoline across the U.S., by state, which you can take a look at <a href=\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/eead370d79e0f20df5148b79b6887393\/raw\/fba29e3dcf1806cab770e845546a136a924cf1d5\/dataBubbleMap2.json\" target=\"_blank\" rel=\"nofollow\">here<\/a>.<\/p>\n<p>I will need two more JS files for using the data. One is the <a href=\"https:\/\/docs.anychart.com\/Working_with_Data\/Data_Adapter\" target=\"_blank\" rel=\"nofollow\">Data Adapter<\/a> for loading the JSON data file itself. And the other is <a href=\"https:\/\/docs.anychart.com\/Maps\/Map_Projections#using_proj4.js\" target=\"_blank\" rel=\"nofollow\">Proj4js<\/a> for transforming the coordinates to plot bubbles over the respective geographical states. I reference them in the <code>head<\/code> section together with the other scripts.<\/p>\n<pre><code class=\"html\">&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-data-adapter.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/proj4js\/2.3.15\/proj4.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>Then I use the <code>anychart.data.loadJsonFile()<\/code> function to load the JSON file, within the <code>script<\/code> tag previously placed in the <code>body<\/code> section.<\/p>\n<pre><code class=\"javascript\">anychart.data.loadJsonFile( 'https:\/\/gist.githubusercontent.com\/shacheeswadia\/eead370d79e0f20df5148b79b6887393\/raw\/fba29e3dcf1806cab770e845546a136a924cf1d5\/dataBubbleMap2.json', function (data) {})<\/code><\/pre>\n<h3>4. Write some charting code<\/h3>\n<p>The fourth step is for populating the <code>script<\/code> tag in the <code>body<\/code> section of the web page with the code to visualize the JS-based bubble map. Actually, just a few quick lines will be enough!<\/p>\n<p>All the code is to be wrapped into the <code>anychart.onDocumentReady()<\/code> function so that the page is fully loaded before anything else is executed.<\/p>\n<p>Inside it, to begin with, I load the data as shown in the 3rd step. Then I create a map chart instance using the built-in function and add the geodata for the United States.<\/p>\n<pre><code class=\"html\">&lt;script&gt;\r\n\r\n  anychart.onDocumentReady(function() {\r\n    \r\n    \/\/ load the data\r\n    anychart.data.loadJsonFile( 'https:\/\/gist.githubusercontent.com\/shacheeswadia\/eead370d79e0f20df5148b79b6887393\/raw\/fba29e3dcf1806cab770e845546a136a924cf1d5\/dataBubbleMap2.json',\r\n    function (data) {\r\n      \r\n      \/\/ create a map chart\r\n      let map = anychart.map();\r\n\r\n      \/\/ add the u.s. geodata\r\n      map.geoData(\"anychart.maps.united_states_of_america\");\r\n\r\n    });\r\n\r\n  });\r\n&lt;\/script&gt;<\/code><\/pre>\n<p>Since I want to denote the gas prices with bubbles, I create a bubble series and map those values as the size of the bubbles all over the map:<\/p>\n<pre><code class=\"javascript\">let series = map.bubble(\r\n  anychart.data.set(data).mapAs({\r\n    size: \"Petrol\"\r\n  })\r\n);<\/code><\/pre>\n<p><a href=\"https:\/\/www.anychart.com\/blog\/2017\/04\/05\/chart-captions-title-graph-tips\/\">Captions<\/a> are important for better legibility. So I enable the series labels to display the names of the states and add a title.<\/p>\n<pre><code class=\"javascript\">\/\/ enable the series labels\r\nseries\r\n  .labels()\r\n  .enabled(true);\r\n      \r\n\/\/ set the map's title\r\nmap.title(\"Gasoline Prices in the United States in July 2022\");<\/code><\/pre>\n<p>Finally, I reference the HTML block-level element as the container for the map and draw the resulting visualization.<\/p>\n<pre><code class=\"javascript\">\/\/ set the container id\r\nmap.container(\"container\");\r\n\r\n\/\/ initiate the map drawing\r\nmap.draw();<\/code><\/pre>\n<p>There you go! A lovely interactive bubble map is created using JavaScript just like that! You can clearly understand which U.S. states saw the highest gas prices in July 2022.<\/p>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-9266aZgG\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/9266aZgG\/iframe\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-9266aZgG{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>I have kept the code for this basic JS bubble map in the <a href=\"https:\/\/playground.anychart.com\/9266aZgG\/\" target=\"_blank\" rel=\"nofollow\">Playground<\/a> online code editor so you can take a closer look at it, add your own data, and so on. I am also putting it here below.<\/p>\n<p>But don\u2019t leave yet and do keep reading as I have much more to show you!<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n\u00a0\u00a0&lt;head&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;title&gt;JavaScript Bubble Map&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-map.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/geodata\/countries\/united_states_of_america\/united_states_of_america.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-data-adapter.min.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/proj4js\/2.3.15\/proj4.js\"&gt;&lt;\/script&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;style type=\"text\/css\"&gt;      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0html, body, #container { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0width: 100%; height: 100%; margin: 0; padding: 0; \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} \r\n\u00a0\u00a0\u00a0\u00a0&lt;\/style&gt;\r\n\u00a0\u00a0&lt;\/head&gt;\r\n\u00a0\u00a0&lt;body&gt;  \r\n\u00a0\u00a0\u00a0\u00a0&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0anychart.onDocumentReady(function () {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0anychart.data.loadJsonFile(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/eead370d79e0f20df5148b79b6887393\/raw\/fba29e3dcf1806cab770e845546a136a924cf1d5\/dataBubbleMap2.json\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0function (data) {\r\n      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ create a map chart\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0let map = anychart.map();\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ add the u.s. geodata\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0map.geoData(\"anychart.maps.united_states_of_america\");\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ create a bubble series\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0let series = map.bubble(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0  anychart.data.set(data).mapAs({\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0    size: \"Petrol\"\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0  })\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0);\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ enable the series labels\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0series\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0  .labels()\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0  .enabled(true);\r\n      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ set the map's title\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0map.title(\"Gasoline Prices in the United States in July 2022\");\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ set the container id\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0map.container(\"container\");\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ initiate the map drawing\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0map.draw();\r\n      \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/script&gt;\r\n\u00a0\u00a0&lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>Custom JS Bubble Map<\/h2>\n<p>There are umpteen possibilities to customize JavaScript bubble maps. Right now, I will explain and demonstrate some of them. To start with, I will color the bubbles to reflect how greatly the gas price in each state increased between February and July 2022. Then I will enhance the label placement, tooltips, coloring in the hovered state, and map title.<\/p>\n<h3>1. Use colors to display the change<\/h3>\n<p>In bubble maps, like bubble charts, you can use color to visualize an extra dimension in data. I want to take this opportunity to represent the difference between the gas prices in February and in July in each state. The data file has these two values, &#8220;PetrolFeb&#8221; and &#8220;Petrol&#8221;, respectively. So, before anything else, I iterate through each data point and find the difference. From this value, I calculate the percentage of the rise and limit the number of decimal places to two.<\/p>\n<pre><code class=\"javascript\">data.forEach(function (d) {\r\n  let diff = d.Petrol - d.PetrolFeb;\r\n  d.percentRise = ((diff * 100) \/ d.PetrolFeb).toFixed(2);\r\n});<\/code><\/pre>\n<p>Now I will color the bubbles based on this percentage. For this, I need a scale that will accept the values and return the corresponding color. AnyChart provides color scale options, but to make this tutorial even more educative, here I want to show you how you can use another library to power some features in combination with the main one. I decided to demonstrate the creation of a linear color scale using <a href=\"https:\/\/d3js.org\/\" target=\"_blank\" rel=\"nofollow\">D3.js<\/a>, an open-source JavaScript charting library.<\/p>\n<p>Firstly, I include the D3.js script in the <code>head<\/code> section of the HTML page.<\/p>\n<pre><code class=\"html\">&lt;script src=\"https:\/\/d3js.org\/d3.v7.min.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>Secondly, I create a D3 quantile scale that accepts a range of values and returns colors. I keep the domain to accept values from 20 to 50, because the percent rise values fall between those numbers, and add five color values in the range.<\/p>\n<pre><code class=\"javascript\">let fillColor = d3\r\n  .scaleQuantile()\r\n  .domain([20, 50])\r\n  .range([\"#1b8366\", \"#77dd79\", \"#f7e975\", \"#fea43e\", \"#cf0011\"]);<\/code><\/pre>\n<p>Lastly, I set the fill value of each data point based on the percentage rise value using the D3.js scale I\u2019ve just created.<\/p>\n<pre><code class=\"javascript\">data.forEach(function (d) {\r\n  let diff = d.Petrol - d.PetrolFeb;\r\n  d.percentRise = ((diff * 100) \/ d.PetrolFeb).toFixed(2);\r\n  d.fill = fillColor(d.percentRise);\r\n});<\/code><\/pre>\n<p>Don\u2019t worry if this sounds a bit complicated. I just wanted to show you the power of customization where the alternatives are abundant.<\/p>\n<h3>2. Improve the label placement<\/h3>\n<p>By default, the labels are placed in the center of the bubbles. I want to shift them a bit to the side. Along the way, I\u2019ll also customize the font size and color of the labels for better readability and aesthetics.<\/p>\n<pre><code class=\"javascript\">series\r\n  .labels()\r\n  .enabled(true)\r\n  .anchor(\"left-center\")\r\n  .position(\"right\")\r\n  .fontColor(\"#353535\")\r\n  .fontSize(11)\r\n  .offsetX(5);<\/code><\/pre>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-VTFesAw7\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/VTFesAw7\/iframe\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-VTFesAw7{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>Glancing at this interactive bubble map (it\u2019s available on <a href=\"https:\/\/playground.anychart.com\/VTFesAw7\" target=\"_blank\" rel=\"nofollow\">Playground<\/a>), it\u2019s easy to notice that compared to the rest of the country, the gas prices in California were the highest in February but grew not much, while Utah and Idaho saw the steepest rise.<\/p>\n<h3>3. Enhance the tooltip<\/h3>\n<p>The default tooltip shows the latitude and longitude, which is useless in this situation. It is always a good idea to display more meaningful information in the tooltip. And that can be easily implemented.<\/p>\n<p>I choose to show the following in the tooltip: the names of the states, the gas prices for July and February, and the change percentage. For a better presentation, I use HTML.<\/p>\n<pre><code class=\"javascript\">series\r\n\u00a0\u00a0.tooltip()\r\n\u00a0\u00a0.useHtml(true)\r\n\u00a0\u00a0.format(\"&lt;h6 style='font-size:14px; font-weight:400; margin: 0.2rem 0;'&gt;Price in July: &lt;b&gt;{%Petrol}&lt;\/b&gt;&lt;\/h6&gt;&lt;h6 style='font-size:14px; font-weight:400; margin: 0.2rem 0;'&gt;Price in February: &lt;b&gt;{%PetrolFeb}&lt;\/b&gt;&lt;\/h6&gt;&lt;h6 style='font-size:14px; font-weight:400; margin: 0.2rem 0;'&gt;Change: &lt;b&gt;{%percentRise}%&lt;\/b&gt;&lt;\/h6&gt;\");<\/code><\/pre>\n<h3>4. Change the bubble color in the hovered state<\/h3>\n<p>Since I have enhanced the tooltip, which shows up when the bubbles are hovered over with a mouse, I also want to tweak the way the bubbles are colored in the hovered state. For example, let me make it a darker shade of whatever the base color is.<\/p>\n<pre><code class=\"javascript\">series\r\n  .hovered()\r\n  .fill(function (d) {\r\n    return anychart.color.darken(d.sourceColor, 0.2);\r\n  })\r\n  .stroke(0);<\/code><\/pre>\n<h3>5. Customize the title<\/h3>\n<p>Finally, I make the title better explain what the bubble map is representing. I simply enable HTML for the title and add a bit more information and formatting to the title.<\/p>\n<pre><code class=\"javascript\">map\r\n\u00a0\u00a0.title()\r\n\u00a0\u00a0.enabled(true)\r\n\u00a0\u00a0.useHtml(true)\r\n\u00a0\u00a0.text(\r\n\u00a0\u00a0\u00a0\u00a0'&lt;span style = \"color: #7c868e; font-size:18px;\"&gt;Gasoline Prices in the United States in July 2022&lt;\/span&gt;' +\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'&lt;br\/&gt;&lt;span style=\"font-size: 15px;\"&gt;Color shows change from February 2022&lt;\/span&gt;'\r\n\u00a0\u00a0);<\/code><\/pre>\n<p>And that\u2019s it, an absolutely beautiful and informative bubble map is ready! Check it out:<\/p>\n<p><iframe sandbox=\"allow-scripts allow-pointer-lock allow-same-origin\n                 allow-popups allow-modals allow-forms\" frameBorder=\"0\" class=\"anychart-embed anychart-embed-SpCcz2KJ\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/SpCcz2KJ\/iframe\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-SpCcz2KJ{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>This interactive JavaScript bubble map is available on <a href=\"https:\/\/playground.anychart.com\/SpCcz2KJ\/\" target=\"_blank\" rel=\"nofollow\">Playground<\/a> where you are more than welcome to continue playing with its code.<\/p>\n<h2>Conclusion<\/h2>\n<p>Now you know how to make bubble maps using JavaScript (HTML5)! As the next step, see the <a href=\"https:\/\/docs.anychart.com\/Maps\/Proportional_Symbol_Map\" target=\"_blank\" rel=\"nofollow\">documentation<\/a> and just keep on practicing. Visualization greatly helps make sense of data. With a robust JavaScript library, and when you know what you\u2019re doing, creating charts and maps can be very easy.<\/p>\n<p>Let me know if you have any questions or suggestions for the next type of data visualization that you would like to learn. Till then don\u2019t let the high petrol prices get you down \u2014 experiment with the bubble map or any other visual because doing that requires no fuel!<\/p>\n<hr \/>\n<p><strong><em>Many thanks to Shachee Swadia for this stunning <strong>Bubble Map<\/strong> tutorial!<\/p>\n<p>Make sure to not miss other <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a> on our blog!<\/p>\n<p>Got an idea for a not less amazing guest post? <a href=\"https:\/\/www.anychart.com\/support\/\">Let us know<\/a> and we will be glad to discuss your suggestion!<\/em><\/strong><\/p>\n<hr \/>\n<p><!-- SyntaxHighlighter --><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/default.min.css\"><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/atom-one-light.min.css\"><script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/highlight.min.js\"><\/script><script>hljs.initHighlightingOnLoad();<\/script><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Map charts are a great way to put data in a geographical context. And they are not difficult to create! I am eager to demonstrate that by walking you through the creation of a bubble map, one of the most popular types data maps, with the help of JavaScript. A bubble map is a combination [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,66,263,23,13,279,4],"tags":[843,619,618,53,3173,260,2000,847,561,63,2730,235,1740,3149,284,258,471,266,620,1292,880,806,1759,3352,509,1293,2906,2907,2220,2838,54,1389,1760,2757,256,3377,1111,842,744,844,165,313,1370,774,3369,810,805,3007,3484,3483,3485,2652,1528,2050,236,3142,91,1762,2013,2014,32,55,150,1335,144,2979,167,146,433,152,2949,809,151,247,36,907,141,249,3111,81,57,1238,142,96,99,2904,58,65,56,101,1937,2335,1938,2396,1728,2870,3172,340,2654,237,3486,3487,234,601,3260,2986,834,459,1226,30,848,846,172,3351,309,807,808,832,954,1939,108,1339,2015,2816,1763,804,2657,3406,3407],"class_list":["post-15907","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-anymap","category-big-data","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-advanced-data-visualization","tag-analysis","tag-analytics","tag-anychart","tag-app-development","tag-best-data-visualization-examples","tag-best-data-visualization-tool","tag-best-data-visualization-tools","tag-best-data-visualizations","tag-bubble-chart","tag-bubble-diagram","tag-bubble-map","tag-bubble-maps","tag-chart-development","tag-chart-examples","tag-charts","tag-data-analysis","tag-data-analytics","tag-data-analytics-examples","tag-data-chart","tag-data-charting","tag-data-charts","tag-data-design","tag-data-graphic","tag-data-graphics","tag-data-map","tag-data-mapping","tag-data-maps","tag-data-visual","tag-data-visualisation","tag-data-visualization","tag-data-visualization-best-pracices","tag-data-visualization-design","tag-data-visualization-development","tag-data-visualization-examples","tag-data-visualization-guide","tag-data-visualization-practice","tag-data-visualization-task","tag-data-visualization-techniques","tag-data-visualization-tutorial","tag-data-visualizations","tag-data-visuals","tag-data-viz-examples","tag-dataviz-examples","tag-developers","tag-dot-maps","tag-front-end-development","tag-gas-crisis","tag-gas-prices","tag-gasoline","tag-gasoline-prices","tag-geodata","tag-geography","tag-geospatial-analysis","tag-geovisualization","tag-graphic","tag-graphics","tag-guest-post","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-html5-maps","tag-infographic","tag-infographics","tag-information-graphics","tag-interactive-charts","tag-interactive-data-visualization","tag-interactive-graphics","tag-interactive-infographic","tag-interactive-infographics","tag-interactive-maps","tag-interactive-visualizations","tag-interactivity","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-features","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-graph","tag-javascript-graphics","tag-javascript-graphics-library","tag-javascript-library","tag-javascript-map-tutorial","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-graphics","tag-json","tag-json-charts","tag-json-data-visualization","tag-json-map","tag-map","tag-map-design","tag-map-development","tag-map-visualizations","tag-mapping","tag-maps","tag-petrol","tag-petrol-prices","tag-point-map","tag-russia","tag-statistic","tag-statistic-visualization","tag-statistical-analysis","tag-statistics","tag-statistics-visualization","tag-tips-and-tricks","tag-top-data-visualization-software","tag-top-data-visualization-tools","tag-tutorial","tag-ukraine","tag-united-states","tag-visual-analysis","tag-visual-analytics","tag-visual-data","tag-visual-data-analytics","tag-visualizing-json-data","tag-web-analytics","tag-web-analytics-data-visualization","tag-web-charts","tag-web-design","tag-web-developers","tag-web-development","tag-web-maps","tag-website","tag-website-development","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Bubble Maps: How to Make Them with JavaScript<\/title>\n<meta name=\"description\" content=\"A bubble map is a combination of a bubble chart &amp; a geo map. Take a closer look at this map chart &amp; learn how to build bubble maps in JavaScript (HTML5).\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Make Bubble Maps in JavaScript\" \/>\n<meta property=\"og:description\" content=\"A bubble map is a combination of a bubble chart &amp; a geo map. Learn how to build bubble maps in JS\/HTML5.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\" \/>\n<meta property=\"og:site_name\" content=\"AnyChart News\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AnyCharts\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-16T08:58:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-17T23:49:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-social.png\" \/>\n<meta name=\"author\" content=\"Shachee Swadia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Make Bubble Maps in JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"A bubble map is a combination of a bubble chart &amp; a geo map. Learn how to build bubble maps in JS\/HTML5.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-social.png\" \/>\n<meta name=\"twitter:creator\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:site\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shachee Swadia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\"},\"author\":{\"name\":\"Shachee Swadia\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"headline\":\"How to Make Bubble Maps in JavaScript\",\"datePublished\":\"2022-11-16T08:58:24+00:00\",\"dateModified\":\"2022-11-17T23:49:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\"},\"wordCount\":1601,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png\",\"keywords\":[\"advanced data visualization\",\"analysis\",\"analytics\",\"AnyChart\",\"app development\",\"best data visualization examples\",\"best data visualization tool\",\"best data visualization tools\",\"best data visualizations\",\"bubble chart\",\"bubble diagram\",\"bubble map\",\"bubble maps\",\"chart development\",\"chart examples\",\"charts\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"data chart\",\"data charting\",\"data charts\",\"data design\",\"data graphic\",\"data graphics\",\"data map\",\"data mapping\",\"data maps\",\"data visual\",\"data visualisation\",\"Data Visualization\",\"data visualization best practices\",\"data visualization design\",\"data visualization development\",\"data visualization examples\",\"data visualization guide\",\"data visualization practice\",\"data visualization task\",\"data visualization techniques\",\"data visualization tutorial\",\"data visualizations\",\"data visuals\",\"data viz examples\",\"dataviz examples\",\"developers\",\"dot maps\",\"front-end development\",\"gas crisis\",\"gas prices\",\"gasoline\",\"gasoline prices\",\"geodata\",\"geography\",\"geospatial analysis\",\"geovisualization\",\"graphic\",\"graphics\",\"guest post\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"html5 maps\",\"infographic\",\"infographics\",\"information graphics\",\"interactive charts\",\"interactive data visualization\",\"interactive graphics\",\"interactive infographic\",\"interactive infographics\",\"interactive maps\",\"interactive visualizations\",\"interactivity\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting features\",\"JavaScript charting library\",\"javascript charts\",\"javascript graph\",\"javascript graphics\",\"JavaScript graphics library\",\"JavaScript library\",\"javascript map tutorial\",\"js chart\",\"js charting\",\"js charts\",\"JS graphics\",\"JSON\",\"JSON charts\",\"JSON data visualization\",\"JSON map\",\"map\",\"map design\",\"map development\",\"map visualizations\",\"mapping\",\"maps\",\"petrol\",\"petrol prices\",\"point map\",\"Russia\",\"statistic\",\"statistic visualization\",\"statistical analysis\",\"statistics\",\"statistics visualization\",\"Tips and tricks\",\"top data visualization software\",\"top data visualization tools\",\"tutorial\",\"Ukraine\",\"united states\",\"visual analysis\",\"visual analytics\",\"visual data\",\"visual data analytics\",\"visualizing JSON data\",\"web analytics\",\"web analytics data visualization\",\"web charts\",\"web design\",\"web developers\",\"web development\",\"web maps\",\"website\",\"website development\"],\"articleSection\":[\"AnyChart Charting Component\",\"AnyMap\",\"Big Data\",\"HTML5\",\"JavaScript\",\"JavaScript Chart Tutorials\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\",\"name\":\"Bubble Maps: How to Make Them with JavaScript\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png\",\"datePublished\":\"2022-11-16T08:58:24+00:00\",\"dateModified\":\"2022-11-17T23:49:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"description\":\"A bubble map is a combination of a bubble chart & a geo map. Take a closer look at this map chart & learn how to build bubble maps in JavaScript (HTML5).\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png\",\"width\":1200,\"height\":675},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Make Bubble Maps in JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\",\"url\":\"https:\/\/www.anychart.com\/blog\/\",\"name\":\"AnyChart News\",\"description\":\"AnyChart JS Charts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.anychart.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\",\"name\":\"Shachee Swadia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"caption\":\"Shachee Swadia\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bubble Maps: How to Make Them with JavaScript","description":"A bubble map is a combination of a bubble chart & a geo map. Take a closer look at this map chart & learn how to build bubble maps in JavaScript (HTML5).","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/","og_locale":"en_US","og_type":"article","og_title":"How to Make Bubble Maps in JavaScript","og_description":"A bubble map is a combination of a bubble chart & a geo map. Learn how to build bubble maps in JS\/HTML5.","og_url":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2022-11-16T08:58:24+00:00","article_modified_time":"2022-11-17T23:49:22+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-social.png","type":"","width":"","height":""}],"author":"Shachee Swadia","twitter_card":"summary_large_image","twitter_title":"How to Make Bubble Maps in JavaScript","twitter_description":"A bubble map is a combination of a bubble chart & a geo map. Learn how to build bubble maps in JS\/HTML5.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map-social.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Shachee Swadia","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/"},"author":{"name":"Shachee Swadia","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"headline":"How to Make Bubble Maps in JavaScript","datePublished":"2022-11-16T08:58:24+00:00","dateModified":"2022-11-17T23:49:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/"},"wordCount":1601,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png","keywords":["advanced data visualization","analysis","analytics","AnyChart","app development","best data visualization examples","best data visualization tool","best data visualization tools","best data visualizations","bubble chart","bubble diagram","bubble map","bubble maps","chart development","chart examples","charts","data analysis","data analytics","data analytics examples","data chart","data charting","data charts","data design","data graphic","data graphics","data map","data mapping","data maps","data visual","data visualisation","Data Visualization","data visualization best practices","data visualization design","data visualization development","data visualization examples","data visualization guide","data visualization practice","data visualization task","data visualization techniques","data visualization tutorial","data visualizations","data visuals","data viz examples","dataviz examples","developers","dot maps","front-end development","gas crisis","gas prices","gasoline","gasoline prices","geodata","geography","geospatial analysis","geovisualization","graphic","graphics","guest post","HTML","HTML charts","HTML5","html5 charts","html5 maps","infographic","infographics","information graphics","interactive charts","interactive data visualization","interactive graphics","interactive infographic","interactive infographics","interactive maps","interactive visualizations","interactivity","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting features","JavaScript charting library","javascript charts","javascript graph","javascript graphics","JavaScript graphics library","JavaScript library","javascript map tutorial","js chart","js charting","js charts","JS graphics","JSON","JSON charts","JSON data visualization","JSON map","map","map design","map development","map visualizations","mapping","maps","petrol","petrol prices","point map","Russia","statistic","statistic visualization","statistical analysis","statistics","statistics visualization","Tips and tricks","top data visualization software","top data visualization tools","tutorial","Ukraine","united states","visual analysis","visual analytics","visual data","visual data analytics","visualizing JSON data","web analytics","web analytics data visualization","web charts","web design","web developers","web development","web maps","website","website development"],"articleSection":["AnyChart Charting Component","AnyMap","Big Data","HTML5","JavaScript","JavaScript Chart Tutorials","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/","url":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/","name":"Bubble Maps: How to Make Them with JavaScript","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png","datePublished":"2022-11-16T08:58:24+00:00","dateModified":"2022-11-17T23:49:22+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"description":"A bubble map is a combination of a bubble chart & a geo map. Take a closer look at this map chart & learn how to build bubble maps in JavaScript (HTML5).","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/11\/bubble-map.png","width":1200,"height":675},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2022\/11\/16\/bubble-maps-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Make Bubble Maps in JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.anychart.com\/blog\/#website","url":"https:\/\/www.anychart.com\/blog\/","name":"AnyChart News","description":"AnyChart JS Charts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.anychart.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51","name":"Shachee Swadia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","caption":"Shachee Swadia"},"url":"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=15907"}],"version-history":[{"count":20,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15907\/revisions"}],"predecessor-version":[{"id":15941,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15907\/revisions\/15941"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=15907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=15907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=15907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}