{"id":699,"date":"2013-04-19T19:40:25","date_gmt":"2013-04-19T19:40:25","guid":{"rendered":"http:\/\/psyphi.net\/blog\/?p=699"},"modified":"2013-04-19T19:48:53","modified_gmt":"2013-04-19T19:48:53","slug":"charts-from-tables-with-d3js-and-jquery","status":"publish","type":"post","link":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/","title":{"rendered":"Charts from Tables with D3js and jQuery"},"content":{"rendered":"<p>I&#8217;ve been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than building bitmap images and serving them base64 encoded inline with &lt;img alt=&#8221;&#8221; src=&#8221;data:&#8230;&#8221; \/&gt;.<\/p>\n<p>Using jQuery (or similar) to extract data from an already-present HTML table means there&#8217;s almost no code required whenever you want to add and plot a new column that someone might want to report on. Pushing all the work to the client should also mean slightly lighter server loads, though granted it&#8217;s already done the heavy lifting during the query to generate the table.<\/p>\n<p>I&#8217;ve used examples from a number of sources, mostly from over on the <a title=\"D3js\" href=\"http:\/\/d3js.org\/\" target=\"_blank\">d3js.org<\/a> website itself and Mike Bostock&#8217;s inspiring <a title=\"D3js Example Gallery\" href=\"https:\/\/github.com\/mbostock\/d3\/wiki\/Gallery\" target=\"_blank\">example gallery<\/a>. Plus the ever useful <a title=\"jQuery\" href=\"http:\/\/jquery.com\" target=\"_blank\">jQuery<\/a> and <a title=\"jQueryUI\" href=\"http:\/\/jqueryui.com\" target=\"_blank\">jQueryUI<\/a> libraries.<\/p>\n<p>The result is a tabbed (with a jqueryui-themed unordered list) report based on a data table below. Clicking on either a tab or a table heading (all except the date) will animate and redraw the chart above. The data are collected using a jQuery selector on column classes in each.<\/p>\n<p><iframe src=\"\/d3js\/charts-from-tables.html\" style=\"width:800px;height:800px;\"><\/iframe><\/p>\n<p>Feel free to take and reuse it &#8211; just pinch the frame source.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than &hellip; <a href=\"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Charts from Tables with D3js and jQuery&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[11,9],"tags":[892,744,292,331,84],"class_list":["post-699","post","type-post","status-publish","format-standard","hentry","category-programming","category-webdev","tag-d3js","tag-html","tag-javascript","tag-jquery","tag-visualisation"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"I&#039;ve been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Roger Pettett\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"psyphi.net blog - Another collection of braingunk and technolint\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Charts from Tables with D3js and jQuery - psyphi.net blog\" \/>\n\t\t<meta property=\"og:description\" content=\"I&#039;ve been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2013-04-19T19:40:25+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2013-04-19T19:48:53+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Charts from Tables with D3js and jQuery - psyphi.net blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I&#039;ve been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#blogposting\",\"name\":\"Charts from Tables with D3js and jQuery - psyphi.net blog\",\"headline\":\"Charts from Tables with D3js and jQuery\",\"author\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#organization\"},\"datePublished\":\"2013-04-19T19:40:25+00:00\",\"dateModified\":\"2013-04-19T19:48:53+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#webpage\"},\"articleSection\":\"programming, webdev, d3js, html, javascript, jquery, visualisation\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/psyphi.net\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/webdev\\\/#listItem\",\"name\":\"webdev\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/webdev\\\/#listItem\",\"position\":2,\"name\":\"webdev\",\"item\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/webdev\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#listItem\",\"name\":\"Charts from Tables with D3js and jQuery\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#listItem\",\"position\":3,\"name\":\"Charts from Tables with D3js and jQuery\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/category\\\/webdev\\\/#listItem\",\"name\":\"webdev\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#organization\",\"name\":\"psyphi.net blog\",\"description\":\"Another collection of braingunk and technolint\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/\",\"name\":\"Roger Pettett\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f715f8335258578c567eb8c22335f1cee22c971c2aff8be27c4d8d934c436503?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Roger Pettett\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#webpage\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/\",\"name\":\"Charts from Tables with D3js and jQuery - psyphi.net blog\",\"description\":\"I've been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/2013\\\/04\\\/charts-from-tables-with-d3js-and-jquery\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/author\\\/rmp\\\/#author\"},\"datePublished\":\"2013-04-19T19:40:25+00:00\",\"dateModified\":\"2013-04-19T19:48:53+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/\",\"name\":\"psyphi.net blog\",\"description\":\"Another collection of braingunk and technolint\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/psyphi.net\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Charts from Tables with D3js and jQuery - psyphi.net blog","description":"I've been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than","canonical_url":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#blogposting","name":"Charts from Tables with D3js and jQuery - psyphi.net blog","headline":"Charts from Tables with D3js and jQuery","author":{"@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author"},"publisher":{"@id":"https:\/\/psyphi.net\/blog\/#organization"},"datePublished":"2013-04-19T19:40:25+00:00","dateModified":"2013-04-19T19:48:53+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#webpage"},"isPartOf":{"@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#webpage"},"articleSection":"programming, webdev, d3js, html, javascript, jquery, visualisation"},{"@type":"BreadcrumbList","@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog#listItem","position":1,"name":"Home","item":"https:\/\/psyphi.net\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/category\/webdev\/#listItem","name":"webdev"}},{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/category\/webdev\/#listItem","position":2,"name":"webdev","item":"https:\/\/psyphi.net\/blog\/category\/webdev\/","nextItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#listItem","name":"Charts from Tables with D3js and jQuery"},"previousItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#listItem","position":3,"name":"Charts from Tables with D3js and jQuery","previousItem":{"@type":"ListItem","@id":"https:\/\/psyphi.net\/blog\/category\/webdev\/#listItem","name":"webdev"}}]},{"@type":"Organization","@id":"https:\/\/psyphi.net\/blog\/#organization","name":"psyphi.net blog","description":"Another collection of braingunk and technolint","url":"https:\/\/psyphi.net\/blog\/"},{"@type":"Person","@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author","url":"https:\/\/psyphi.net\/blog\/author\/rmp\/","name":"Roger Pettett","image":{"@type":"ImageObject","@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/f715f8335258578c567eb8c22335f1cee22c971c2aff8be27c4d8d934c436503?s=96&d=mm&r=g","width":96,"height":96,"caption":"Roger Pettett"}},{"@type":"WebPage","@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#webpage","url":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/","name":"Charts from Tables with D3js and jQuery - psyphi.net blog","description":"I've been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/psyphi.net\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/#breadcrumblist"},"author":{"@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author"},"creator":{"@id":"https:\/\/psyphi.net\/blog\/author\/rmp\/#author"},"datePublished":"2013-04-19T19:40:25+00:00","dateModified":"2013-04-19T19:48:53+00:00"},{"@type":"WebSite","@id":"https:\/\/psyphi.net\/blog\/#website","url":"https:\/\/psyphi.net\/blog\/","name":"psyphi.net blog","description":"Another collection of braingunk and technolint","inLanguage":"en-US","publisher":{"@id":"https:\/\/psyphi.net\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"psyphi.net blog - Another collection of braingunk and technolint","og:type":"article","og:title":"Charts from Tables with D3js and jQuery - psyphi.net blog","og:description":"I've been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than","og:url":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/","article:published_time":"2013-04-19T19:40:25+00:00","article:modified_time":"2013-04-19T19:48:53+00:00","twitter:card":"summary_large_image","twitter:title":"Charts from Tables with D3js and jQuery - psyphi.net blog","twitter:description":"I've been tinkering with D3js on and off for a couple of months now, purely for generating simple, inline charts in web pages, made from data already dumped into HTML tables. Doing this is easier than building, caching and referencing external bitmap (PNG, GIF or whatever) images with Gnuplot or GD::Graph and also simpler than"},"aioseo_meta_data":{"post_id":"699","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2024-05-16 16:30:02","updated":"2025-08-15 17:30:53","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/psyphi.net\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/psyphi.net\/blog\/category\/webdev\/\" title=\"webdev\">webdev<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCharts from Tables with D3js and jQuery\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/psyphi.net\/blog"},{"label":"webdev","link":"https:\/\/psyphi.net\/blog\/category\/webdev\/"},{"label":"Charts from Tables with D3js and jQuery","link":"https:\/\/psyphi.net\/blog\/2013\/04\/charts-from-tables-with-d3js-and-jquery\/"}],"_links":{"self":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/comments?post=699"}],"version-history":[{"count":7,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/699\/revisions"}],"predecessor-version":[{"id":706,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/699\/revisions\/706"}],"wp:attachment":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/media?parent=699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/categories?post=699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/tags?post=699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}