{"id":15120,"date":"2022-06-17T18:19:22","date_gmt":"2022-06-17T18:19:22","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=15120"},"modified":"2022-08-13T11:12:10","modified_gmt":"2022-08-13T11:12:10","slug":"scatter-chart-js","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/","title":{"rendered":"Building Scatter Chart in JavaScript"},"content":{"rendered":"<p><a href=\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/\"><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png\" alt=\"A Scatter Chart Built in JavaScript Using AnyChart JS Charts\" width=\"100%\" class=\"alignnone size-full wp-image-15124\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png 1800w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot-300x167.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot-768x427.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot-1024x569.png 1024w\" sizes=\"(max-width: 1800px) 100vw, 1800px\" \/><\/a>With data everywhere around us, it is imperative to know how to quickly create visualizations that help reveal trends and patterns in it. Today, let\u2019s learn how to build a scatter chart in just a few lines of simple JavaScript code!<\/p>\n<p>Scatter charts, or scatter plots, are designed to identify a correlation between typically two variables. In such graphics, the data is visualized as a set of points usually displayed as markers. The position of each marker indicates the values of the variables along the horizontal and vertical axes.<\/p>\n<p>In this tutorial, we will be visualizing international and domestic sales of the 1000 highest-grossing Hollywood movies as of January 2022. So, get your popcorn and start watching the JS scatter chart development!<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2>Creating Scatter Chart with JavaScript<\/h2>\n<p>Building interactive scatter charts from scratch can be difficult and time-consuming. But it is not a problem at all if you use JavaScript the right way.<\/p>\n<p>Generally speaking, there are four basic steps you need to take to get a JS-based scatter chart up and running. Here they are.<\/p>\n<h3>1. Create a basic HTML page with a container<\/h3>\n<p>First of all, we need a web page with a container where our future scatter chart will be displayed.<\/p>\n<p>Create an HTML file (or feel free to open an existing one of your own). Include a block-level element, provide it with a unique <code>id<\/code> that will be referenced later, and set its <code>width<\/code> and <code>height<\/code>. Here\u2019s a basic example of how all this can look:<\/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 Scatter Chart&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>As you see, we\u2019ve got a very basic HTML page with a <code>&lt;div&gt;<\/code> element whose <code>id<\/code> is set as \u201ccontainer\u201d and both <code>width<\/code> and <code>height<\/code> are 100% so that the JavaScript scatter chart is displayed over the entire screen (these values can be specified as per preference and requirement).<\/p>\n<h3>2. Include the necessary scripts<\/h3>\n<p>Second, include all the scripts needed for creating the plot in the <code>&lt;head&gt;<\/code> section of the HTML page.<\/p>\n<p>To build this scatter chart, let\u2019s use <a href=\"https:\/\/www.anychart.com\">AnyChart JS Charts<\/a>. It is a very flexible JavaScript charting library with extensive <a href=\"https:\/\/docs.anychart.com\" target=\"_blank\" rel=\"nofollow\">documentation<\/a>, a lot of readymade <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/\">JS chart examples<\/a>, and <a href=\"https:\/\/www.anychart.com\/technical-integrations\/\">integration templates<\/a> for many popular tech stacks.<\/p>\n<p>The AnyChart JS charting library is <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules\" target=\"_blank\" rel=\"nofollow\">modular<\/a>, and its <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Modules#base\" target=\"_blank\" rel=\"nofollow\">Base<\/a> module will be more than enough in this case. The data we will visualize are stored in a JSON file, and the <a href=\"https:\/\/docs.anychart.com\/Working_with_Data\/Data_Adapter\/Overview\" target=\"_blank\" rel=\"nofollow\">Data Adapter<\/a> script will let us load it from there in a straightforward manner.<\/p>\n<p>So, we only need to reference these two JS files.<\/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 Scatter Chart&lt;\/title&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.0\/js\/anychart-base.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-data-adapter.min.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\/\/ This is the place for the entire JS scatter chart 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. Connect the data<\/h3>\n<p>Third, load the data you want to represent.<\/p>\n<p>In this tutorial, we will use the scatter charting technique to visualize data from the <a href=\"https:\/\/www.kaggle.com\/datasets\/sanjeetsinghnaik\/top-1000-highest-grossing-movies\" target=\"_blank\" rel=\"nofollow\">Top 1000 Highest Grossing Movies<\/a> dataset on Kaggle. I took the sales figures along with the titles of the movies and put them all in a <a href=\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/dceaadd5fb4ea27cd9975ff39e9f98f4\/raw\/6baac571527d9b13e397cfb3d982d7942246dcc0\/scatterPlotData.json\" target=\"_blank\" rel=\"nofollow\">JSON file<\/a>.<\/p>\n<p>AnyChart supports multiple ways to <a href=\"https:\/\/docs.anychart.com\/Working_with_Data\" target=\"_blank\" rel=\"nofollow\">load data<\/a> to charts. When it comes to data in a JSON file, for example, it is easy to add it using the <code>loadJsonFile()<\/code> method:<\/p>\n<pre><code class=\"javascript\">anychart.data.loadJsonFile(\r\n&nbsp;&nbsp;\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/dceaadd5fb4ea27cd9975ff39e9f98f4\/raw\/6baac571527d9b13e397cfb3d982d7942246dcc0\/scatterPlotData.json\",\r\n&nbsp;&nbsp;function(data) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;\/\/ The main scatter plot visualization code will be here.\r\n&nbsp;&nbsp;}\r\n);<\/code><\/pre>\n<h3>4. Write the visualization code<\/h3>\n<p>Now, let\u2019s get to the main part of having an interactive JS scatter chart appear on our web page. Actually, it will only take a few lines of straightforward code.<\/p>\n<p>Add the <code>anychart.onDocumentReady()<\/code> function that will enclose all the scatter plotting JavaScript code, making sure that the page is fully loaded before the visualization is executed. Then load the data the way described in the previous step.<\/p>\n<pre><code class=\"javascript\">anychart.onDocumentReady(function () {\r\n&nbsp;&nbsp;anychart.data.loadJsonFile(\r\n&nbsp;&nbsp;&nbsp;&nbsp;\"https:\/\/gist.githubusercontent.com\/shacheeswadia\/dceaadd5fb4ea27cd9975ff39e9f98f4\/raw\/6baac571527d9b13e397cfb3d982d7942246dcc0\/scatterPlotData.json\",\r\n    function (data) {\r\n      \/\/ The following JS code comes here.\r\n    }\r\n  );\r\n});<\/code><\/pre>\n<p>Next, create a scatter chart instance (using the built-in <code>scatter()<\/code> function) and define markers (there are various options for the marker type, but let\u2019s adhere to the classic circle shape).<\/p>\n<pre><code class=\"javascript\">let chart = anychart.scatter();\r\n\r\nlet marker = chart.marker(data);\r\nmarker.type(\"circle\").size(2);<\/code><\/pre>\n<p>It is important to specify what kind of values are plotted along each axis. So, let\u2019s set the titles for both:<\/p>\n<pre><code class=\"javascript\">chart.yAxis().title(\"International sales ($ in millions)\");\r\nchart.xAxis().title(\"Domestic sales ($ in millions)\");<\/code><\/pre>\n<p>Similarly, let\u2019s also title the entire data visualization:<\/p>\n<pre><code class=\"javascript\">chart.title(\"Top 1000 Highest Grossing Hollywood Movies: Domestic vs. International Sales\");<\/code><\/pre>\n<p>Now, simply reference the container\u2019s <code>id<\/code> and command to draw the chart.<\/p>\n<pre><code class=\"javascript\">chart.container(\"container\");\r\nchart.draw();<\/code><\/pre>\n<p>That\u2019s it! A beautiful, fully functional, interactive scatter chart is created with just these few lines of JavaScript code and can be embedded as is into any web page or app!<\/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-ytirdLFe\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/WJsbbXQi\/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-ytirdLFe{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>The initial version is available on <a href=\"https:\/\/playground.anychart.com\/WJsbbXQi\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>. We can see that there is a definite correlation between domestic and international sales, but there are some outliers as well.<\/p>\n<h2>JS Scatter Chart Customization<\/h2>\n<p>A basic scatter chart is ready. Now, let\u2019s see how we can make it more informative and aesthetically better.<\/p>\n<h3>A. Improve the tooltip<\/h3>\n<p>Each dot represents a movie, and the current scatter plot looks good enough to illuminate the general trend. But what if we want to dive deeper and see which movie is represented with one individual point or another?<\/p>\n<p>Let\u2019s add the movie titles to the tooltip so we could see them when the dots are hovered over with the mouse.<\/p>\n<pre><code class=\"javascript\">marker.tooltip().titleFormat(function () {\r\n  return this.getData(\"title\");\r\n});<\/code><\/pre>\n<p>It is also a good idea to clarify what the displayed values mean.<\/p>\n<pre><code class=\"javascript\">marker\r\n.tooltip()\r\n.format(function () {\r\n  return (\r\n    \"\\nTOTAL SALES: \" +\r\n    \"$\" +\r\n    this.getData(\"totalSales\") +\r\n    \"M\" +\r\n    \"\\nDomestic sales: \" +\r\n    \"$\" +\r\n    this.x +\r\n    \"M\" +\r\n    \"\\nInternational sales: \" +\r\n    \"$\" +\r\n    this.value +\r\n    \"M\"\r\n  );\r\n});<\/code><\/pre>\n<h3>B. Modify the scale<\/h3>\n<p>By default, the maximum and minimum values on the axes are automatically calculated based on the values in the data. Right now, 2400 is the maximum on the Y-axis, while the maximum on the X-axis is only 1200. Let\u2019s make both maximums the same (2200) and also increase the number of ticks along the axes by setting the interval between them to 200.<\/p>\n<pre><code class=\"javascript\">chart.xScale().minimum(0).maximum(2200).ticks({ interval: 200 });\r\nchart.yScale().minimum(0).maximum(2200).ticks({ interval: 200 });<\/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-qQnxe3j4\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/w1foHv5a\/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-qQnxe3j4{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>The entire code for this version of our JS scatter chart can be found on <a href=\"https:\/\/playground.anychart.com\/w1foHv5a\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>.<\/p>\n<p>For the next steps, let\u2019s keep these more frequent ticks but revert to the automatic calculation of the maximum scale values as it apparently provides a better view of the data points.<\/p>\n<h3>C. Add grid lines<\/h3>\n<p>The scatter chart is representing quantitative data, and adding a grid should make it easier to understand the values. Let\u2019s enable grid lines for both axes and style the stroke appearance.<\/p>\n<pre><code class=\"javascript\">\/\/ enable the grid lines\r\nchart.yGrid(true);\r\nchart.xGrid(true);\r\n      \r\n\/\/ customize the grid stroke\r\nchart.yGrid().stroke({ color: \"#071d58\", dash: \"4 5\" });\r\nchart.xGrid().stroke({ color: \"#071d58\", dash: \"4 5\" });<\/code><\/pre>\n<h3>D. Aesthetic changes<\/h3>\n<p>Finally, it\u2019s time to make some simple, yet effective modifications to enhance the look of the scatter chart. Let\u2019s set a custom background color:<\/p>\n<pre><code class=\"javascript\">chart.background().fill(\"#0d468f\");<\/code><\/pre>\n<p>To increase the visual contrast, it will be good to customize the markers by editing the initial marker configuration line in the code:<\/p>\n<pre><code class=\"javascript\">marker.type(\"circle\").size(4).fill(\"#c6e3f9\").stroke(\"#3e5ca6\");<\/code><\/pre>\n<p>Since the background is darker now, let\u2019s also modify the colors of the scatter chart and axis titles using HTML.<\/p>\n<pre><code class=\"javascript\">\/\/ set the chart title\r\nchart\r\n  .title()\r\n   .enabled(true)\r\n  .useHtml(true)\r\n  .text(\r\n    '&lt;span style = \"color: #c6e3f9; font-size:18px;\"&gt;Top 1000 Highest Grossing Hollywood Movies: Domestic vs. International Sales&lt;\/span&gt;'\r\n  );\r\n\r\n\/\/ set the titles of the axes\r\nchart\r\n  .yAxis()\r\n  .title()\r\n  .enabled(true)\r\n  .useHtml(true)\r\n  .text(\r\n    '&lt;span style = \"color: #b3b3b3;\"&gt;International sales ($ in millions)&lt;\/span&gt;'\r\n  );\r\nchart\r\n  .xAxis()\r\n  .title()\r\n  .enabled(true)\r\n  .useHtml(true)\r\n  .text(\r\n    '&lt;span style = \"color: #b3b3b3;\"&gt;Domestic sales ($ in millions)&lt;\/span&gt;'\r\n  );<\/code><\/pre>\n<p>Voil\u00e0! We now have a lovely, insightful, JavaScript-based scatter chart to make our data speak!<\/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-Mv1iS0Ii\"\n        allowtransparency=\"true\" allowfullscreen=\"true\"\n        src=\"https:\/\/playground.anychart.com\/Mv1iS0Ii\/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-Mv1iS0Ii{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>Take a look at how enthralling the scatter chart visualization looks now! Check it out on <a href=\"https:\/\/playground.anychart.com\/Mv1iS0Ii\" target=\"_blank\" rel=\"nofollow\">AnyChart Playground<\/a>.<\/p>\n<h2>Conclusion<\/h2>\n<p>Now you see it is easy \u2014 and fun \u2014 to create scatter charts with JavaScript (HTML5). Look at the <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Scatter_Plot\/Overview\" target=\"_blank\" rel=\"nofollow\">scatter documentation<\/a> to continue learning.<\/p>\n<p>There are tons of different other <a href=\"https:\/\/docs.anychart.com\/Quick_Start\/Supported_Charts_Types\" target=\"_blank\" rel=\"nofollow\">chart types<\/a> available. So, try out a scatter plot, and then don\u2019t miss out on other options for your data visualization. Please ask any questions and feel free to suggest another chart type for the next tutorial.<\/p>\n<hr \/>\n<p><strong><em>AnyChart is thankful to Shachee Swadia, a freelance data visualization developer, for producing this wonderful guest post.<\/p>\n<p>Don&#8217;t miss out on another great <a href=\"https:\/\/www.anychart.com\/blog\/2020\/05\/27\/scatter-plot-js-tutorial\/\">scatter plot tutorial<\/a> on our blog, where data analyst Wayde Herman visualizes the popularity of cats vs. dogs in the U.S. by state.<\/p>\n<p>Check out more <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a> on our blog.<\/p>\n<p>Would you like to create some cool guest post for us? <a href=\"https:\/\/www.anychart.com\/support\/\">Let us know!<\/a><\/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>With data everywhere around us, it is imperative to know how to quickly create visualizations that help reveal trends and patterns in it. Today, let\u2019s learn how to build a scatter chart in just a few lines of simple JavaScript code! Scatter charts, or scatter plots, are designed to identify a correlation between typically two [&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,263,23,13,279,4],"tags":[619,618,53,289,3173,260,3088,3089,254,1758,3149,284,127,166,258,471,266,620,1292,880,806,1759,3352,509,54,1389,1760,2757,256,1111,350,844,165,313,1370,774,775,179,3369,210,1246,1245,1498,3080,805,3142,91,95,259,786,2013,2014,32,55,1335,144,2979,2016,167,146,433,152,2949,151,247,36,907,141,249,81,57,1238,142,96,99,134,58,65,56,101,1937,2335,1938,3158,3386,3387,3388,1228,670,669,588,209,1761,834,459,3099,30,3385,172,309,807,808,954,3100,293,899,1939,2816,1763,804],"class_list":["post-15120","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-big-data","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-analysis","tag-analytics","tag-anychart","tag-api","tag-app-development","tag-best-data-visualization-examples","tag-box-office","tag-box-office-revenues","tag-chart","tag-chart-design","tag-chart-development","tag-chart-examples","tag-chart-types","tag-charting","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-visualization","tag-data-visualization-best-pracices","tag-data-visualization-design","tag-data-visualization-development","tag-data-visualization-examples","tag-data-visualization-practice","tag-data-visualization-projects","tag-data-visualization-tutorial","tag-data-visualizations","tag-data-visuals","tag-data-viz-examples","tag-dataviz-examples","tag-dataviz-projects","tag-design","tag-developers","tag-dot-chart","tag-dot-plot","tag-dot-plots","tag-example","tag-films","tag-front-end-development","tag-graphic","tag-graphics","tag-graphics-library","tag-graphs","tag-hollywood","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-infographic","tag-infographics","tag-information-graphics","tag-information-visualization","tag-interactive-charts","tag-interactive-data-visualization","tag-interactive-graphics","tag-interactive-infographic","tag-interactive-infographics","tag-interactive-visualizations","tag-interactivity","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-graph","tag-javascript-graphics","tag-javascript-graphics-library","tag-javascript-library","tag-javascript-technologies","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-graphics","tag-json","tag-json-charts","tag-json-data-visualization","tag-kaggle","tag-marker-chart","tag-marker-plot","tag-marker-plots","tag-movie-data","tag-movie-franchises","tag-movies","tag-sales-data","tag-scatter-chart","tag-scatter-plot","tag-statistical-analysis","tag-statistics","tag-storytelling-examples","tag-tips-and-tricks","tag-top-grossing-movies","tag-tutorial","tag-united-states","tag-visual-analysis","tag-visual-analytics","tag-visual-data-analytics","tag-visual-storytelling-examples","tag-visualization","tag-visualizations","tag-visualizing-json-data","tag-web-design","tag-web-developers","tag-web-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>Scatter Chart in JavaScript | JS Charting Tutorials | AnyChart JS Charts<\/title>\n<meta name=\"description\" content=\"Learn how to build a scatter chart in a few lines of JavaScript code! In this tutorial, we visualize sales data for the 1000 top grossing Hollywood movies.\" \/>\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\/06\/17\/scatter-chart-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scatter Chart in JavaScript\" \/>\n<meta property=\"og:description\" content=\"Learn how to build a scatter chart in just a few lines of JavaScript code &amp; explore sales of the 1000 highest-grossing Hollywood movies.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-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-06-17T18:19:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-13T11:12:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot-social.png\" \/>\n<meta name=\"author\" content=\"Shachee Swadia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Scatter Chart in JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"Learn how to build a scatter chart in just a few lines of JavaScript code &amp; explore sales of the 1000 highest-grossing Hollywood movies.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot-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=\"8 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\/06\/17\/scatter-chart-js\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/\"},\"author\":{\"name\":\"Shachee Swadia\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"headline\":\"Building Scatter Chart in JavaScript\",\"datePublished\":\"2022-06-17T18:19:22+00:00\",\"dateModified\":\"2022-08-13T11:12:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/\"},\"wordCount\":1194,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png\",\"keywords\":[\"analysis\",\"analytics\",\"AnyChart\",\"api\",\"app development\",\"best data visualization examples\",\"box office\",\"box office revenues\",\"chart\",\"chart design\",\"chart development\",\"chart examples\",\"chart types\",\"charting\",\"charts\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"data chart\",\"data charting\",\"data charts\",\"data design\",\"data graphic\",\"data graphics\",\"Data Visualization\",\"data visualization best practices\",\"data visualization design\",\"data visualization development\",\"data visualization examples\",\"data visualization practice\",\"data visualization projects\",\"data visualization tutorial\",\"data visualizations\",\"data visuals\",\"data viz examples\",\"dataviz examples\",\"dataviz projects\",\"design\",\"developers\",\"dot chart\",\"dot plot\",\"dot plots\",\"example\",\"films\",\"front-end development\",\"graphic\",\"graphics\",\"graphics library\",\"graphs\",\"Hollywood\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"infographic\",\"infographics\",\"information graphics\",\"information visualization\",\"interactive charts\",\"interactive data visualization\",\"interactive graphics\",\"interactive infographic\",\"interactive infographics\",\"interactive visualizations\",\"interactivity\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting library\",\"javascript charts\",\"javascript graph\",\"javascript graphics\",\"JavaScript graphics library\",\"JavaScript library\",\"javascript technologies\",\"js chart\",\"js charting\",\"js charts\",\"JS graphics\",\"JSON\",\"JSON charts\",\"JSON data visualization\",\"Kaggle\",\"marker chart\",\"marker plot\",\"marker plots\",\"movie data\",\"movie franchises\",\"movies\",\"sales data\",\"scatter chart\",\"scatter plot\",\"statistical analysis\",\"statistics\",\"storytelling examples\",\"Tips and tricks\",\"top grossing movies\",\"tutorial\",\"united states\",\"visual analysis\",\"visual analytics\",\"visual data analytics\",\"visual storytelling examples\",\"visualization\",\"visualizations\",\"visualizing JSON data\",\"web design\",\"web developers\",\"web development\"],\"articleSection\":[\"AnyChart Charting Component\",\"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\/06\/17\/scatter-chart-js\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/\",\"name\":\"Scatter Chart in JavaScript | JS Charting Tutorials | AnyChart JS Charts\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png\",\"datePublished\":\"2022-06-17T18:19:22+00:00\",\"dateModified\":\"2022-08-13T11:12:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"description\":\"Learn how to build a scatter chart in a few lines of JavaScript code! In this tutorial, we visualize sales data for the 1000 top grossing Hollywood movies.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png\",\"width\":1800,\"height\":1000},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building Scatter Chart 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":"Scatter Chart in JavaScript | JS Charting Tutorials | AnyChart JS Charts","description":"Learn how to build a scatter chart in a few lines of JavaScript code! In this tutorial, we visualize sales data for the 1000 top grossing Hollywood movies.","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\/06\/17\/scatter-chart-js\/","og_locale":"en_US","og_type":"article","og_title":"Scatter Chart in JavaScript","og_description":"Learn how to build a scatter chart in just a few lines of JavaScript code & explore sales of the 1000 highest-grossing Hollywood movies.","og_url":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2022-06-17T18:19:22+00:00","article_modified_time":"2022-08-13T11:12:10+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot-social.png","type":"","width":"","height":""}],"author":"Shachee Swadia","twitter_card":"summary_large_image","twitter_title":"Scatter Chart in JavaScript","twitter_description":"Learn how to build a scatter chart in just a few lines of JavaScript code & explore sales of the 1000 highest-grossing Hollywood movies.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot-social.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Shachee Swadia","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/"},"author":{"name":"Shachee Swadia","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"headline":"Building Scatter Chart in JavaScript","datePublished":"2022-06-17T18:19:22+00:00","dateModified":"2022-08-13T11:12:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/"},"wordCount":1194,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png","keywords":["analysis","analytics","AnyChart","api","app development","best data visualization examples","box office","box office revenues","chart","chart design","chart development","chart examples","chart types","charting","charts","data analysis","data analytics","data analytics examples","data chart","data charting","data charts","data design","data graphic","data graphics","Data Visualization","data visualization best practices","data visualization design","data visualization development","data visualization examples","data visualization practice","data visualization projects","data visualization tutorial","data visualizations","data visuals","data viz examples","dataviz examples","dataviz projects","design","developers","dot chart","dot plot","dot plots","example","films","front-end development","graphic","graphics","graphics library","graphs","Hollywood","HTML","HTML charts","HTML5","html5 charts","infographic","infographics","information graphics","information visualization","interactive charts","interactive data visualization","interactive graphics","interactive infographic","interactive infographics","interactive visualizations","interactivity","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting library","javascript charts","javascript graph","javascript graphics","JavaScript graphics library","JavaScript library","javascript technologies","js chart","js charting","js charts","JS graphics","JSON","JSON charts","JSON data visualization","Kaggle","marker chart","marker plot","marker plots","movie data","movie franchises","movies","sales data","scatter chart","scatter plot","statistical analysis","statistics","storytelling examples","Tips and tricks","top grossing movies","tutorial","united states","visual analysis","visual analytics","visual data analytics","visual storytelling examples","visualization","visualizations","visualizing JSON data","web design","web developers","web development"],"articleSection":["AnyChart Charting Component","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\/06\/17\/scatter-chart-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/","url":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/","name":"Scatter Chart in JavaScript | JS Charting Tutorials | AnyChart JS Charts","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png","datePublished":"2022-06-17T18:19:22+00:00","dateModified":"2022-08-13T11:12:10+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"description":"Learn how to build a scatter chart in a few lines of JavaScript code! In this tutorial, we visualize sales data for the 1000 top grossing Hollywood movies.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2022\/06\/scatter-plot.png","width":1800,"height":1000},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2022\/06\/17\/scatter-chart-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Building Scatter Chart 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\/15120","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=15120"}],"version-history":[{"count":17,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15120\/revisions"}],"predecessor-version":[{"id":15531,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/15120\/revisions\/15531"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=15120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=15120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=15120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}