{"id":1431,"date":"2018-08-11T13:00:47","date_gmt":"2018-08-11T12:00:47","guid":{"rendered":"http:\/\/chewett.co.uk\/blog\/?p=1431"},"modified":"2018-08-12T19:51:24","modified_gmt":"2018-08-12T18:51:24","slug":"simple-d3-js-version-5-data-binding-and-updating-example-and-code","status":"publish","type":"post","link":"https:\/\/chewett.co.uk\/blog\/1431\/simple-d3-js-version-5-data-binding-and-updating-example-and-code\/","title":{"rendered":"Simple D3.js version 5 data binding and updating example and code"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1437\" data-permalink=\"https:\/\/chewett.co.uk\/blog\/1431\/simple-d3-js-version-5-data-binding-and-updating-example-and-code\/d3_data_binding\/\" data-orig-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?fit=800%2C300&amp;ssl=1\" data-orig-size=\"800,300\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"d3_data_binding\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?fit=300%2C113&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?fit=678%2C254&amp;ssl=1\" class=\"aligncenter size-full wp-image-1437\" src=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?resize=678%2C254\" alt=\"\" width=\"678\" height=\"254\" srcset=\"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?resize=300%2C113&amp;ssl=1 300w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?resize=768%2C288&amp;ssl=1 768w, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_data_binding.jpg?resize=50%2C19&amp;ssl=1 50w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/p>\n<p>This post goes through the process of binding data to elements and creating a simple updatable SVG graphic using D3.js version 5.<\/p>\n<p><!--more--><\/p>\n<h2>Data binding and updating in D3.js version 5<\/h2>\n<p>In D3.js version 4 there was quite a big update to how data is bound to elements and updated. This means there is a lot of code which currently will subtly fail to update visualisations created.<\/p>\n<p>Today I am using the current latest version of D3.js (version 5) to show a simple example binding and updating data. This will demonstrate the new system of having an updatable visualisation based on the data.<\/p>\n<h2>Creating the SVG and page buttons<\/h2>\n<p>The body of the page will only contain a SVG to draw onto and two buttons. These buttons will let the user increment the number of times that the button has been pressed. Below is the code to add these three elements to the page.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;p&gt;\r\n    &lt;button onclick=&quot;buttonPress(1)&quot;&gt;Button 1&lt;\/button&gt;\r\n    &lt;button onclick=&quot;buttonPress(2)&quot;&gt;Button 2&lt;\/button&gt;\r\n&lt;\/p&gt;\r\n&lt;p&gt;\r\n    &lt;svg id=&quot;mainSvg&quot; height=&quot;100&quot; width=&quot;300&quot;&gt;&lt;\/svg&gt;\r\n&lt;\/p&gt;<\/pre>\n<p>The onclick\u00a0functions on the buttons will be explained in the next step. These functions are called whenever the button is pressed.<\/p>\n<p>I have given the SVG an ID so that it may be referred to, and a width and height appropriate to the content we are going to add. In more advanced graphs you may resize the SVG depending on the content.<\/p>\n<h2>Creating the data structure and update buttons<\/h2>\n<p>To illustrate data binding I am going to create a simple data structure to hold information about the number of times a button has been pressed. Below is the data structure that will hold this data.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var data = &#x5B;\r\n    {&quot;title&quot;: &quot;Button One&quot;, &quot;timesPressed&quot;: 0},\r\n    {&quot;title&quot;: &quot;Button Two&quot;, &quot;timesPressed&quot;: 0}\r\n];<\/pre>\n<p>Each time the button is pressed I will add one to the count.\u00a0 The following function will be triggered when the buttons are pressed to increment the count.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function buttonPress(buttonNumber) {\r\n    data&#x5B;buttonNumber - 1].timesPressed++;\r\n    update();\r\n}<\/pre>\n<p>The variable <code>buttonNumber<\/code>\u00a0has one taken off it since arrays are 0 indexed. Once the <code>timesPressed<\/code> key is incremented the <code>update()<\/code> function is called. This will be our primary function to create and update the visualisation.<\/p>\n<h2>Selecting the SVG<\/h2>\n<p>First we need to select the SVG we are going to be drawing, this can be done by the following code.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var s = d3.select(&quot;#mainSvg&quot;);<\/pre>\n<p>This saves the SVG reference to the <code>s<\/code> variable to access it.<\/p>\n<h2>Entering, Updating and Exiting<\/h2>\n<p>When creating and updating the SVG there are three major ways to operate on a selection.<\/p>\n<ul>\n<li>Update &#8211; Is used for all elements which already have data bound to it<\/li>\n<li>Enter &#8211; Is used for when the data you are binding has no element already bound to it<\/li>\n<li>Exit &#8211; Is used when there was previously data bound but there is no longer<\/li>\n<\/ul>\n<p>D3 splits up divides all operations on elements to these three groups and allow you to customize how each is dealt with.<\/p>\n<p>Here I will show and explain what I will be doing in each part and then show the full context of the update function.<\/p>\n<h3>Update &#8211; Selecting all elements that are currently bound to data<\/h3>\n<p>The first part of generating SVG&#8217;s from data is selecting the elements currently on the page bound to data. Each element generated by D3 is bound to a specific piece of data.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var titleTextSelection = s.selectAll(&quot;.buttonTitles&quot;).data(data);<\/pre>\n<p>Here I select every element under the main SVG\u00a0element with the class <code>buttonTitles<\/code>. Using <code>data()<\/code>\u00a0I pass in my current data set which selects elements currently bound to data.<\/p>\n<p>Any operations on this selection will be performed on these elements already on the page, whose data elements are still in the values passed to the <code>data()<\/code> call.<\/p>\n<p>This selection is saved into a variable as this selection also allows us to operate on elements that need to be created (added into the data set), and those that have been removed from it.<\/p>\n<p>At the moment I am not going to do anything currently to the elements existing on the page so I don&#8217;t use this selection currently.<\/p>\n<h3>Exit &#8211; Handling elements no longer bound to data<\/h3>\n<p>The next step is to handle elements that are no longer bound to the data. These would have been elements created by the <code>enter()<\/code> call previously but their data no longer exists in the value passed into <code>data()<\/code>.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">titleTextSelection.exit().remove();<\/pre>\n<p>Above I use the selection created before and call the .exit() method on it. Anything chained after the .exit() method will operate on the elements that no longer part of the data. Since I no longer want these elements to appear on the SVG I call <code>remove()<\/code>\u00a0to remove them from the SVG.<\/p>\n<h3>Enter &#8211; Creating new elements from data currently not bound<\/h3>\n<p>On the first call to our update function, the first two function calls will do nothing as there is no elements currently bound to data. This means there is nothing to select and nothing to remove. However <code>.enter()<\/code> will create the appropriate elements the first time around.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var titleTextEnter = titleTextSelection\r\n    .enter()\r\n    .append(&quot;text&quot;)\r\n    .attr(&quot;class&quot;, &quot;buttonTitles&quot;)\r\n    .attr(&quot;y&quot;,  function(d, index) { return 20 + (index * 50); })\r\n;<\/pre>\n<p>Here the selection is used again and this time <code>enter()<\/code> is called on it to operate on all data elements that are new. I first append a text element using <code>append(\"text\")<\/code> and set its class and position on the page.<\/p>\n<p>Each chained function can either take a specific value or a function. The first parameter to this function is the data representing the element and the second is the index. Above I am using the index to offset each piece of text in the y dimension.<\/p>\n<p>It is important to note that these function calls will only be made when elements are added to the page. If you want data to be updated you will want to add them to the update function calls.<\/p>\n<p>I save this to a variable which holds all the elements that have been created by the <code>enter()<\/code> function.<\/p>\n<h3>Enter and Update &#8211; Combining operations that need to run on both new and old elements<\/h3>\n<p>The final step in my update function is to set the value of the text element. This could be done by writing the same function in both the update and enter selections however there is an easier way in D3 version 5. We are able to use the <code>merge()<\/code> function to merge two selections and operate on both of them.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">titleTextSelection.merge(titleTextEnter)\r\n    .text(function(d) {\r\n        return d.title + &quot; has been pressed &quot; + d.timesPressed + &quot; times&quot;;\r\n    });<\/pre>\n<p>Here I use the selection of all elements on the page and merge in the selection of all created elements. This lets me apply any functions to both new and old elements reducing code duplication.<\/p>\n<p>In this case I set the text of the element to be the title and the number of times the button has been pressed.<\/p>\n<h2>Combining the update parts together<\/h2>\n<p>Now I can combine the above code to present my single update function.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function update() {\r\n    var titleTextSelection = s.selectAll(&quot;.buttonTitles&quot;)\r\n        .data(data);\r\n\r\n    titleTextSelection.exit().remove();\r\n\r\n    var titleTextEnter = titleTextSelection\r\n        .enter()\r\n        .append(&quot;text&quot;)\r\n        .attr(&quot;class&quot;, &quot;buttonTitles&quot;)\r\n        .attr(&quot;y&quot;,  function(d, index) { return 20 + (index * 50); })\r\n    ;\r\n\r\n    titleTextSelection.merge(titleTextEnter)\r\n        .text(function(d) {\r\n            return d.title + &quot; has been pressed &quot; + d.timesPressed + &quot; times&quot;;\r\n        });\r\n}<\/pre>\n<p>The full code above has the four major parts identified above:<\/p>\n<ol>\n<li>Creates the new selection with the new data using <code>data()<\/code><\/li>\n<li>Removes old elements no longer in the data using <code>exit()<\/code><\/li>\n<li>Creates new elements in the data using <code>enter()<\/code><\/li>\n<li>Operates on both new and current elements using <code>merge()<\/code><\/li>\n<\/ol>\n<p>Using these four functions you can create complex data visualisations focussing on the data rather than how you will display it.<\/p>\n<h2>Summary<\/h2>\n<p>Here I have explained the four important functions that can be used for data visualisations. Using a simple data structure the principle of creating, updating and removing elements as the data changes is demonstrated. A simple SVG and page is created to show how the functions work.<\/p>\n<p>In the future tutorials I will explain how you can use a more complex data structure by chaining enter, update and remove calls.<\/p>\n<p>The full code for this is available\u00a0<a href=\"https:\/\/chewett.co.uk\/d3\/d3_v5_data_binding\/\">on my website which includes a live example<\/a>.<\/p>\n<p>If you have any questions feel free to comment on the following blog post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post goes through the process of binding data to elements and creating a simple updatable SVG graphic using D3.js version 5.<\/p>\n","protected":false},"author":1,"featured_media":1441,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"This weekend I wrote about how to use D3.js Version 5 showing a simple data binding and updating example #d3js #javascript","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[98],"tags":[229,291,219,72],"class_list":["post-1431","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-d3-js","tag-d3-js-version-5","tag-data-visualisation","tag-javascript"],"wppr_data":{"cwp_meta_box_check":"No"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_simple_data_binding.jpg?fit=800%2C800&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p2toWX-n5","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1483,"url":"https:\/\/chewett.co.uk\/blog\/1483\/d3-js-version-5-scatterplot-with-shapes\/","url_meta":{"origin":1431,"position":0},"title":"D3.js version 5 Scatterplot with shapes","author":"Chewett","date":"September 15, 2018","format":false,"excerpt":"Today I write about\u00a0how you can create a scatter plot with different shapes in D3.js version 5. Aim of this tutorial This blog builds on Mike Bostocks\u00a0Scatterplot with shapes example and reworks it for D3.js version 5. This tutorial will focus on the changes needed to convert the original diagram\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_scatterplot_with_shapes-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_scatterplot_with_shapes-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_scatterplot_with_shapes-1.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_scatterplot_with_shapes-1.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1485,"url":"https:\/\/chewett.co.uk\/blog\/1485\/drawing-shapes-in-d3-js-version-5\/","url_meta":{"origin":1431,"position":1},"title":"Drawing shapes in D3.js Version 5","author":"Chewett","date":"September 5, 2018","format":false,"excerpt":"This post goes over the various D3.js symbols typically used for scatter plots. D3.js built-in symbols D3.js has a number of built-in symbols which can be used for any data visualisation needs. The most common use of these are\u00a0for points on scatter plots and similar graphs. It is important to\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_drawing_shapes.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_drawing_shapes.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_drawing_shapes.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/08\/d3_v5_drawing_shapes.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1030,"url":"https:\/\/chewett.co.uk\/blog\/1030\/overlaying-geo-data-leaflet-version-1-3-d3-js-version-4\/","url_meta":{"origin":1431,"position":2},"title":"Overlaying geo data with Leaflet Version 1.3 and D3.js Version 4","author":"Chewett","date":"February 24, 2018","format":false,"excerpt":"In this post I describe how you can overlay Geo Data onto a leaflet map with D3.js. Combining Leaflet and D3 and objectives There are a number of tutorials online on how to overlay Geodata with D3.js. However, I couldn't find any of these that worked for the most recent\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/d3_leaftlet_intro.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/d3_leaftlet_intro.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/d3_leaftlet_intro.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/d3_leaftlet_intro.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2335,"url":"https:\/\/chewett.co.uk\/blog\/2335\/d3-js-version-5-lazily-loading-dom-elements\/","url_meta":{"origin":1431,"position":3},"title":"D3.js version 5 Lazily loading DOM elements","author":"Chewett","date":"August 24, 2019","format":false,"excerpt":"In this example I demonstrate how you can lazily load DOM elements as you scroll through a page using D3.js. The full code for this is available on my website. Why you might want to lazily load DOM elements As page size increases the browser will slow down rendering it.\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/08\/d3_lazily_loading_dom_elements.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/08\/d3_lazily_loading_dom_elements.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/08\/d3_lazily_loading_dom_elements.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/08\/d3_lazily_loading_dom_elements.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1994,"url":"https:\/\/chewett.co.uk\/blog\/1994\/d3-js-version-5-prediction-line-chart\/","url_meta":{"origin":1431,"position":4},"title":"D3.js version 5 Prediction Line Chart","author":"Chewett","date":"February 13, 2019","format":false,"excerpt":"Today I am writing about the Prediction Line Chart I have created in D3.js version 5. Here I provide the full code how to create it yourself and how it works. What is a Prediction Line Chart? A Prediction Line Chart is an extension of a basic line chart where\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/d3_v5_prediction_line.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/d3_v5_prediction_line.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/d3_v5_prediction_line.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2019\/02\/d3_v5_prediction_line.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1700,"url":"https:\/\/chewett.co.uk\/blog\/1700\/colour-scales-in-d3-version-5\/","url_meta":{"origin":1431,"position":5},"title":"Colour scales in D3 Version 5","author":"Chewett","date":"November 3, 2018","format":false,"excerpt":"Over the past versions in D3.js there have been a number of changes to how you can get a colour scale to use with your charting. This blog post explores what is available and how to use it. This blog post applies to D3.js version 5. Colour scales in D3.js\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/d3_colour_scales-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/d3_colour_scales-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/d3_colour_scales-1.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/11\/d3_colour_scales-1.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=1431"}],"version-history":[{"count":9,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1431\/revisions"}],"predecessor-version":[{"id":1444,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/1431\/revisions\/1444"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media\/1441"}],"wp:attachment":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=1431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=1431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=1431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}