{"id":15,"date":"2011-07-07T03:46:25","date_gmt":"2011-07-07T03:46:25","guid":{"rendered":"http:\/\/blog.raghwendra.com\/?p=15"},"modified":"2011-07-07T03:47:53","modified_gmt":"2011-07-07T03:47:53","slug":"create-bar-chart-using-gd-library","status":"publish","type":"post","link":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/","title":{"rendered":"Create Bar Chart Using GD library"},"content":{"rendered":"<p>GD library is useful for creating 2D charts.<!--more--><\/p>\n<p>Graph Image<br \/>\n<img fetchpriority=\"high\" decoding=\"async\" src=\"http:\/\/raghwendra.com\/gdchart.php\" height=\"280\" width=\"400\" \/><\/p>\n<p>Copy and paste this code in your php file<br \/>\n&lt;!&#8211;\/ By Raghwendra$graphValues=array(50,80,23,11,190,120,50,80,111,210,55);<br \/>\n$graphValues_city=array(&#8216;mumbai&#8217;,&#8217;delhi&#8217;,&#8217;channai&#8217;,&#8217;banglore&#8217;,&#8217;chandigarh&#8217;,<br \/>\n&#8216;surat&#8217;,&#8217;kanpur&#8217;,&#8217;patna&#8217;,&#8217;hyderabad&#8217;,&#8217;jammu&#8217;,&#8217;lacknow&#8217;);<br \/>\nheader(&#8220;Content-type: image\/png&#8221;);<br \/>\n$imgWidth=1000;<br \/>\n$imgHeight=280;<br \/>\n\/\/ Create image and define colors<br \/>\n$image=imagecreate($imgWidth, $imgHeight);<br \/>\n$colorWhite=imagecolorallocate($image, 255, 255, 255);<br \/>\n$colorGrey=imagecolorallocate($image, 192, 192, 192);<br \/>\n$colorBlue=imagecolorallocate($image, 0, 0, 255);<br \/>\n\/\/ Create border around image<br \/>\nimageline($image, 0, 0, 0, 250, $colorGrey);<br \/>\nimageline($image, 0, 249, 1000, 249, $colorGrey);<br \/>\nfor ($i=0; $i&lt;11; $i++)<br \/>\n{<br \/>\nimagefilledrectangle($image, ($i*80)+10, (250-$graphValues[$i])+1, (($i+1)*80)-20, 248, $colorBlue);<br \/>\nimagefttext( $image, 10, 0, ($i*80)+strlen($graphValues_city[$i]),270, $colorGrey, &#8216;trebuc.ttf&#8217;, $graphValues_city[$i], array(&#8216;lineheight&#8217;=&gt;2.0) );<br \/>\nimagefttext( $image, 10, 0, ($i*80)+20,244-$graphValues[$i], $colorGrey, &#8216;trebuc.ttf&#8217;, $graphValues[$i], array(&#8216;lineheight&#8217;=&gt;2.0) );<br \/>\n}<br \/>\nimagepng($image);<br \/>\nimagedestroy($image);<br \/>\n\/\/imagefilledrectangle($image, $i*25, (250-$graphValues[$i]), ($i+1)*25, 250, $colorBlue);<br \/>\n\/\/imagefilledrectangle($image, ($i*50)-10, (250-$graphValues[$i])+1, (($i+1)*50)-5, 248, $colorBlue);<br \/>\n?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GD library is useful for creating 2D charts.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-content-management-system","category-open-source-php","entry"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"rangnath\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#article\",\"name\":\"Create Bar Chart Using GD library\",\"headline\":\"Create Bar Chart Using GD library\",\"author\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/author\\\/rangnath\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/raghwendra.com\\\/gdchart.php\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#articleImage\"},\"datePublished\":\"2011-07-07T03:46:25+00:00\",\"dateModified\":\"2011-07-07T03:47:53+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#webpage\"},\"articleSection\":\"Content Management System, Open Source - PHP\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/category\\\/content-management-system\\\/#listItem\",\"name\":\"Content Management System\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/category\\\/content-management-system\\\/#listItem\",\"position\":2,\"name\":\"Content Management System\",\"item\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/category\\\/content-management-system\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#listItem\",\"name\":\"Create Bar Chart Using GD library\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#listItem\",\"position\":3,\"name\":\"Create Bar Chart Using GD library\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/category\\\/content-management-system\\\/#listItem\",\"name\":\"Content Management System\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/#organization\",\"name\":\"Raghwendra Web Services\",\"description\":\"celebrating success together\",\"url\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/\",\"telephone\":\"+919312447399\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/04\\\/logorws.jpg\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#organizationLogo\",\"width\":266,\"height\":71},\"image\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/author\\\/rangnath\\\/#author\",\"url\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/author\\\/rangnath\\\/\",\"name\":\"rangnath\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e4b75c4e27bd3aa8ec96a5b60b523ce3d2f9e46354c058bef99e7944d56198b3?s=96&d=wavatar&r=g\",\"width\":96,\"height\":96,\"caption\":\"rangnath\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#webpage\",\"url\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/\",\"name\":\"Create Bar Chart Using GD library\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/create-bar-chart-using-gd-library\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/author\\\/rangnath\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/author\\\/rangnath\\\/#author\"},\"datePublished\":\"2011-07-07T03:46:25+00:00\",\"dateModified\":\"2011-07-07T03:47:53+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/\",\"name\":\"Raghwendra Web Services Blog helps You & Your Business Grow\",\"description\":\"celebrating success together\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.raghwendra.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Create Bar Chart Using GD library","description":"","canonical_url":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#article","name":"Create Bar Chart Using GD library","headline":"Create Bar Chart Using GD library","author":{"@id":"https:\/\/www.raghwendra.com\/blog\/author\/rangnath\/#author"},"publisher":{"@id":"https:\/\/www.raghwendra.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"http:\/\/raghwendra.com\/gdchart.php","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#articleImage"},"datePublished":"2011-07-07T03:46:25+00:00","dateModified":"2011-07-07T03:47:53+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#webpage"},"isPartOf":{"@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#webpage"},"articleSection":"Content Management System, Open Source - PHP"},{"@type":"BreadcrumbList","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.raghwendra.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.raghwendra.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.raghwendra.com\/blog\/category\/content-management-system\/#listItem","name":"Content Management System"}},{"@type":"ListItem","@id":"https:\/\/www.raghwendra.com\/blog\/category\/content-management-system\/#listItem","position":2,"name":"Content Management System","item":"https:\/\/www.raghwendra.com\/blog\/category\/content-management-system\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#listItem","name":"Create Bar Chart Using GD library"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.raghwendra.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#listItem","position":3,"name":"Create Bar Chart Using GD library","previousItem":{"@type":"ListItem","@id":"https:\/\/www.raghwendra.com\/blog\/category\/content-management-system\/#listItem","name":"Content Management System"}}]},{"@type":"Organization","@id":"https:\/\/www.raghwendra.com\/blog\/#organization","name":"Raghwendra Web Services","description":"celebrating success together","url":"https:\/\/www.raghwendra.com\/blog\/","telephone":"+919312447399","logo":{"@type":"ImageObject","url":"https:\/\/www.raghwendra.com\/blog\/wp-content\/uploads\/2017\/04\/logorws.jpg","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#organizationLogo","width":266,"height":71},"image":{"@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/www.raghwendra.com\/blog\/author\/rangnath\/#author","url":"https:\/\/www.raghwendra.com\/blog\/author\/rangnath\/","name":"rangnath","image":{"@type":"ImageObject","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e4b75c4e27bd3aa8ec96a5b60b523ce3d2f9e46354c058bef99e7944d56198b3?s=96&d=wavatar&r=g","width":96,"height":96,"caption":"rangnath"}},{"@type":"WebPage","@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#webpage","url":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/","name":"Create Bar Chart Using GD library","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.raghwendra.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/#breadcrumblist"},"author":{"@id":"https:\/\/www.raghwendra.com\/blog\/author\/rangnath\/#author"},"creator":{"@id":"https:\/\/www.raghwendra.com\/blog\/author\/rangnath\/#author"},"datePublished":"2011-07-07T03:46:25+00:00","dateModified":"2011-07-07T03:47:53+00:00"},{"@type":"WebSite","@id":"https:\/\/www.raghwendra.com\/blog\/#website","url":"https:\/\/www.raghwendra.com\/blog\/","name":"Raghwendra Web Services Blog helps You & Your Business Grow","description":"celebrating success together","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.raghwendra.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"15","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":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"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":"2021-01-28 11:49:23","updated":"2022-12-07 02:48:45","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.raghwendra.com\/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:\/\/www.raghwendra.com\/blog\/category\/content-management-system\/\" title=\"Content Management System\">Content Management System<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCreate Bar Chart Using GD library\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.raghwendra.com\/blog"},{"label":"Content Management System","link":"https:\/\/www.raghwendra.com\/blog\/category\/content-management-system\/"},{"label":"Create Bar Chart Using GD library","link":"https:\/\/www.raghwendra.com\/blog\/create-bar-chart-using-gd-library\/"}],"_links":{"self":[{"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":0,"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.raghwendra.com\/blog\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}