{"id":16361,"date":"2017-10-12T19:57:08","date_gmt":"2017-10-12T14:27:08","guid":{"rendered":"http:\/\/www.fusioncharts.com\/blog\/?p=16361"},"modified":"2026-06-03T16:45:16","modified_gmt":"2026-06-03T11:15:16","slug":"how-to-create-charts-php-mongodb-nosql-fusioncharts","status":"publish","type":"post","link":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/","title":{"rendered":"How to Create Charts in PHP by Fetching Data from MongoDB 2026"},"content":{"rendered":"<p>Most enterprise apps currently use relational databases like SQL, MariaDB, or MySQL due to their popularity and stable nature. However, developers face issues when they try to scale such databases. Furthermore, considering the recent breed of web applications that handle large data sets, developers are constantly looking for more scalable databases. This has attributed to the rise of non-relational (NoSQL) databases. One such database that has become really popular is MongoDB.<\/p>\n<p>In this tutorial we will follow a step-by-step approach to create charts using data stored in a MongoDB database. We will use the PHP scripting language to connect to the database and fetch the data, which would then be used to render the chart.<\/p>\n<p>We picked PHP over others as it comes with a MongoDB driver that connects it to the database. If you need to add more firepower to your web application, you can also use Node.js.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_71 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#Requirements\" title=\"Requirements:\u00a0\">Requirements:\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#Part_1_Including_Dependencies\" title=\"Part 1: Including Dependencies\">Part 1: Including Dependencies<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#Part_2_Establishing_and_Validating_Database_Connection\" title=\"Part 2: Establishing and Validating Database Connection\">Part 2: Establishing and Validating Database Connection<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#Part_3_Rendering_the_Chart\" title=\"Part 3: Rendering the Chart\">Part 3: Rendering the Chart<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Requirements\"><\/span><strong>Requirements:\u00a0<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For creating charts using PHP and MongoDB, you need the following to be downloaded and installed on your system:<\/p>\n<ul>\n<li>XAMPP<\/li>\n<li>MongoDB<\/li>\n<li>PHP driver for MongoDB<\/li>\n<li>Composer<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Part_1_Including_Dependencies\"><\/span>Part 1: Including Dependencies<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To render FusionCharts in PHP using MongoDB, we need to include following dependencies:<\/p>\n<ul>\n<li>FusionCharts Suite XT: To begin, you need to download the <a href=\"https:\/\/www.fusioncharts.com\/download\/\">FusionCharts Suite XT package <\/a>and store all the extracted script files in a new folder inside the project folder, as shown below.<\/li>\n<\/ul>\n<pre class=\"lang:markup decode:true\" title=\"Including FusionCharts core package JS files\">&lt;html&gt;\r\n   &lt;head&gt;\r\n      &lt;script src=\"path-to\/fusioncharts.js\"&gt;&lt;\/script&gt;\r\n      &lt;script src=\"path-to\/fusioncharts.theme.fint.js\"&gt;&lt;\/script&gt;\r\n   &lt;\/head&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<ul>\n<li>FusionCharts PHP Wrapper: Extract the\u00a0<a href=\"https:\/\/www.fusioncharts.com\/php-charts\/\" target=\"_blank\" rel=\"noopener noreferrer\">FusionCharts PHP Wrapper\u00a0<\/a>\u00a0and save the\u00a0<code>fusioncharts.php<\/code>\u00a0file inside the same folder created in the previous step for keeping the script files.<\/li>\n<\/ul>\n<pre class=\"lang:php decode:true\" title=\"Including FusionCharts PHP wrapper\">&lt;?php\r\n    require 'fusioncharts\/fusioncharts.php';\r\n?&gt;\r\n<\/pre>\n<ul>\n<li>PHP Library for MongoDB (<a href=\"https:\/\/php.net\/manual\/en\/mongodb.tutorial.library.php\" target=\"_blank\" rel=\"noopener noreferrer\">Details\u00a0<\/a>): Include the\u00a0<code>autoload.php<\/code>\u00a0file that is required for using MongoDB with PHP.<\/li>\n<\/ul>\n<pre class=\"lang:php decode:true \">&lt;?php\r\n    require 'vendor\\autoload.php';\r\n?&gt;<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Part_2_Establishing_and_Validating_Database_Connection\"><\/span>Part 2: Establishing and Validating Database Connection<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Once the dependencies are included in our code, we now establish the connection with our database to fetch data for the chart.<\/p>\n<pre class=\"lang:php decode:true \" title=\"Validating DB connection\">&lt;?php\r\n$dbconn = new MongoDB\\Client;\r\n\r\nif(!$dbconn) {\r\n   exit(\"There was an error establishing database connection\");\r\n}\r\n?&gt;\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Part_3_Rendering_the_Chart\"><\/span>Part 3: Rendering the Chart<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Now that we have established the connection to our database, we will fetch data for our chart.<\/p>\n<p>Let us now look at\u00a0our\u00a0<code>chartData<\/code>\u00a0collection in the\u00a0<code>myProject<\/code>\u00a0database which we will be using to render the chart.<\/p>\n<p><a href=\"https:\/\/www.fusioncharts.com\/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-database.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16362\" src=\"https:\/\/www.fusioncharts.com\/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-database.png\" alt=\"\" width=\"525\" height=\"172\" srcset=\"\/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-database.png 525w, \/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-database-150x49.png 150w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/a><\/p>\n<p>The PHP code for fetching data from our database is as given below:<\/p>\n<pre class=\"lang:php decode:true \" title=\"Retrieving data from the database\">$db = $dbconn-&gt;myProject;\r\n$myObj = $db-&gt;chartData-&gt;find();\r\n\r\n\/\/convert MongoCursor into an array\r\n$data=iterator_to_array($myObj);\r\n\r\n\/\/ sorting the data\r\nasort($data);\r\n<\/pre>\n<p>Next, we will use\u00a0<code>$data<\/code>\u00a0to hold the data fetched from our database. We will now form an associative JSON array for the chart.<\/p>\n<p>FusionCharts accepts both XML and JSON data formats. Since we will be using JSON, we will now append the data (fetched from database in the\u00a0<code>$data<\/code>\u00a0variable) along with FusionCharts chart configuration and parse the end result as an associative JSON array.<\/p>\n<p>The PHP code required to append the chart data fetched from the database is given below:<\/p>\n<pre class=\"lang:php decode:true \">if ($data) { \r\n\t\r\n\t$categoryArray=array();\r\n\t\r\n\t$dataseries1=array(); \r\n\t\r\n\t$dataseries2=array(); \r\n\t\r\n\tforeach ($data as $dataset) {\r\n\t \r\n\t\tarray_push($categoryArray, array( \r\n\t\t\"label\" =&gt; $dataset[\"month\"] \r\n\t\t)); \r\n\r\n\t\tarray_push($dataseries1, array( \r\n\t\t\"value\" =&gt; $dataset[\"petrol\"] \r\n\t\t)); \r\n\r\n\t\tarray_push($dataseries2, array( \r\n\t\t\"value\" =&gt; $dataset[\"diesel\"] \r\n\t\t)); \r\n\t} \r\n\r\n\t$arrData = array( \r\n\t\t\"chart\" =&gt; array( \r\n\t\t\t\"caption\"=&gt; \"Comparison of Petrol and Diesel price\", \r\n\t\t\t\"xAxisname\"=&gt;\"Month\", \r\n\t\t\t\"yAxisname\"=&gt;\"Price\", \r\n\t\t\t\"numberPrefix\"=&gt;\"$\", \r\n\t\t\t\"paletteColors\"=&gt; \"#876EA1, #72D7B2\", \r\n\t\t\t\"useplotgradientcolor\"=&gt; \"0\", \r\n\t\t\t\"plotBorderAlpha\"=&gt; \"0\", \r\n\t\t\t\"bgColor\"=&gt; \"#FFFFFFF\", \r\n\t\t\t\"canvasBgColor\"=&gt; \"#FFFFFF\", \r\n\t\t\t\"showValues\"=&gt; \"0\", \r\n\t\t\t\"showCanvasBorder\"=&gt; \"0\", \r\n\t\t\t\"showBorder\"=&gt; \"0\", \r\n\t\t\t\"divLineAlpha\"=&gt; \"40\", \r\n\t\t\t\"divLineColor\"=&gt; \"#DCDCDC\", \r\n\t\t\t\"alternateHGridColor\"=&gt; \"#DCDCDC\", \r\n\t\t\t\"alternateHGridAlpha\"=&gt; \"15\", \r\n\t\t\t\"labelDisplay\"=&gt; \"auto\", \r\n\t\t\t\"baseFont\"=&gt; \"Assistant\", \r\n\t\t\t\"baseFontColor\"=&gt; \"#000000\", \r\n\t\t\t\"outCnvBaseFont\"=&gt; \"Assistant\", \r\n\t\t\t\"outCnvBaseFontColor\"=&gt; \"#000000\", \r\n\t\t\t\"baseFontSize\"=&gt; \"13\", \r\n\t\t\t\"outCnvBaseFontSize\"=&gt; \"13\", \r\n\t\t\t\"labelFontColor\"=&gt; \"#000000\", \r\n\t\t\t\"captionFontColor\"=&gt; \"#153957\", \r\n\t\t\t\"captionFontBold\"=&gt; \"1\", \r\n\t\t\t\"captionFontSize\"=&gt; \"20\", \r\n\t\t\t\"subCaptionFontColor\"=&gt; \"#153957\", \r\n\t\t\t\"subCaptionfontSize\"=&gt; \"17\", \r\n\t\t\t\"subCaptionFontBold\"=&gt; \"0\", \r\n\t\t\t\"captionPadding\"=&gt; \"20\", \r\n\t\t\t\"valueFontBold\"=&gt; \"0\", \r\n\t\t\t\"showAxisLines\"=&gt; \"1\", \r\n\t\t\t\"yAxisLineColor\"=&gt; \"#DCDCDC\", \r\n\t\t\t\"xAxisLineColor\"=&gt; \"#DCDCDC\", \r\n\t\t\t\"xAxisLineAlpha\"=&gt; \"15\", \r\n\t\t\t\"yAxisLineAlpha\"=&gt; \"15\", \r\n\t\t\t\"toolTipPadding\"=&gt; \"7\", \r\n\t\t\t\"toolTipBorderColor\"=&gt; \"#DCDCDC\", \r\n\t\t\t\"toolTipBorderThickness\"=&gt; \"0\", \r\n\t\t\t\"toolTipBorderRadius\"=&gt; \"2\", \r\n\t\t\t\"showShadow\"=&gt; \"0\", \r\n\t\t\t\"toolTipBgColor\"=&gt; \"#153957\", \r\n\t\t\t\"toolTipBgAlpha\"=&gt; \"90\", \r\n\t\t\t\"toolTipColor\"=&gt; \"#FFFFFF\", \r\n\t\t\t\"legendBorderAlpha\"=&gt; \"0\", \r\n\t\t\t\"legendShadow\"=&gt; \"0\", \r\n\t\t\t\"legendItemFontSize\"=&gt; \"14\" \r\n\t\t) \r\n\t); \r\n\r\n\t$arrData[\"categories\"]=array(array(\"category\"=&gt;$categoryArray)); \r\n\r\n\t\/\/ creating dataset object \r\n\t$arrData[\"dataset\"] = array(array(\"seriesName\"=&gt; \"Petrol_price\", \"data\"=&gt;$dataseries1), array(\"seriesName\"=&gt; \"Diesel_price\", \"data\"=&gt;$dataseries2)); \r\n\r\n\t$jsonEncodedData = json_encode($arrData); \r\n}<\/pre>\n<p>Every chart displayed on a web page is rendered within a unique HTML container. We will be using the\u00a0<code>&lt;div&gt;<\/code>\u00a0element for creating the HTML container for our chart.<\/p>\n<p>Given below is the code for creating the chart container:<\/p>\n<pre class=\"lang:markup decode:true \">&lt;body&gt;\r\n   &lt;div id=\"chart-container\"&gt;Fusion Charts will render here&lt;\/div&gt; \r\n&lt;\/body&gt;<\/pre>\n<p>Now that we have the JSON data and chart container in place, we will create the FusionCharts instance and call the <code>render()<\/code> method to render the chart.<\/p>\n<p>Chart instance includes details needed to render the chart, like the chart type, chart ID, chart dimensions, the HTML container ID, and so on, will be passed to this chart instance.<\/p>\n<pre class=\"lang:php decode:true \">$msChart = new FusionCharts(\"msline\", \"demochart\", \"600\", \"400\", \"chart-container\", \"json\", $jsonEncodedData); \r\n$msChart-&gt;render();\r\n<\/pre>\n<p>If you have been closely following the above steps, then you should see a chart like the image shown below:<\/p>\n<p><a href=\"https:\/\/www.fusioncharts.com\/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16363\" src=\"https:\/\/www.fusioncharts.com\/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-output.png\" alt=\"\" width=\"1192\" height=\"794\" srcset=\"\/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-output.png 1192w, \/blog\/wp-content\/uploads\/2017\/10\/creating-charts-php-mongodb-output-150x100.png 150w\" sizes=\"auto, (max-width: 1192px) 100vw, 1192px\" \/><\/a><\/p>\n<p>If you are still having trouble rendering the chart, you can view the source code in the Github repo. The article first appeared <a href=\"https:\/\/www.pluralsight.com\/guides\/php\/create-charts-using-php-and-mongodb?status=in-review\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most enterprise apps currently use relational databases like SQL, MariaDB, or MySQL due to their popularity and stable nature. However, developers face issues when they try to scale such databases. Furthermore, considering the recent breed of web applications that handle large data sets, developers are constantly looking for more scalable databases. This has attributed to [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":16370,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"coauthors":[653,688],"class_list":["post-16361","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Create Charts In PHP By Fetching Data From MongoDB<\/title>\n<meta name=\"description\" content=\"Learn to fetch NoSQL data from MongoDB with PHP and render multi-series FusionCharts. Covers MongoDBClient setup, autoload, JSON import &amp; chart binding.\" \/>\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.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Create Charts In PHP By Fetching Data From MongoDB\" \/>\n<meta property=\"og:description\" content=\"NoSQL databases are a boon when it comes to scalability. Learn all the steps to build strikingly beautiful charts in PHP using data coming from MongoDB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/\" \/>\n<meta property=\"og:site_name\" content=\"FusionBrew - The FusionCharts Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-10-12T14:27:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T11:15:16+00:00\" \/>\n<meta name=\"author\" content=\"Prerana Singh, Gagan Sikri\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.fusioncharts.com\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prerana Singh, Gagan Sikri\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\/\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"Article\",\n\t            \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Prerana Singh\",\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/person\/d160bebbc408a11542797e038733b9ce\"\n\t            },\n\t            \"headline\": \"How to Create Charts in PHP by Fetching Data from MongoDB 2026\",\n\t            \"datePublished\": \"2017-10-12T14:27:08+00:00\",\n\t            \"dateModified\": \"2026-06-03T11:15:16+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/\"\n\t            },\n\t            \"wordCount\": 578,\n\t            \"commentCount\": 1,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png\",\n\t            \"articleSection\": [\n\t                \"Tutorials\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/\",\n\t            \"url\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/\",\n\t            \"name\": \"How To Create Charts In PHP By Fetching Data From MongoDB\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png\",\n\t            \"datePublished\": \"2017-10-12T14:27:08+00:00\",\n\t            \"dateModified\": \"2026-06-03T11:15:16+00:00\",\n\t            \"description\": \"Learn to fetch NoSQL data from MongoDB with PHP and render multi-series FusionCharts. Covers MongoDB\\\\Client setup, autoload, JSON import & chart binding.\",\n\t            \"breadcrumb\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#breadcrumb\"\n\t            },\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage\",\n\t            \"url\": \"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png\",\n\t            \"contentUrl\": \"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png\",\n\t            \"width\": 2016,\n\t            \"height\": 750,\n\t            \"caption\": \"charting in php and mongoDB\"\n\t        },\n\t        {\n\t            \"@type\": \"BreadcrumbList\",\n\t            \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#breadcrumb\",\n\t            \"itemListElement\": [\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 1,\n\t                    \"name\": \"Home\",\n\t                    \"item\": \"https:\/\/www.fusioncharts.com\/blog\/\"\n\t                },\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 2,\n\t                    \"name\": \"How to Create Charts in PHP by Fetching Data from MongoDB 2026\"\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#website\",\n\t            \"url\": \"https:\/\/www.fusioncharts.com\/blog\/\",\n\t            \"name\": \"FusionBrew - The FusionCharts Blog\",\n\t            \"description\": \"Get tips and tricks on how to build effective Data Visualisation using FusionCharts\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\/\/www.fusioncharts.com\/blog\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#organization\",\n\t            \"name\": \"FusionCharts\",\n\t            \"url\": \"https:\/\/www.fusioncharts.com\/blog\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/logo\/image\/\",\n\t                \"url\": \"\/blog\/wp-content\/uploads\/2020\/03\/idera-fc-logo.svg\",\n\t                \"contentUrl\": \"\/blog\/wp-content\/uploads\/2020\/03\/idera-fc-logo.svg\",\n\t                \"width\": 1,\n\t                \"height\": 1,\n\t                \"caption\": \"FusionCharts\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/logo\/image\/\"\n\t            }\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/person\/d160bebbc408a11542797e038733b9ce\",\n\t            \"name\": \"Prerana Singh\",\n\t            \"image\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/person\/image\/c3a2501c113e420c92343a5caf1ccc58\",\n\t                \"url\": \"\/blog\/wp-content\/wphb-cache\/gravatar\/883\/8839d500f92b36cec1f99073ef09cf90x96.jpg\",\n\t                \"contentUrl\": \"\/blog\/wp-content\/wphb-cache\/gravatar\/883\/8839d500f92b36cec1f99073ef09cf90x96.jpg\",\n\t                \"caption\": \"Prerana Singh\"\n\t            },\n\t            \"url\": \"https:\/\/www.fusioncharts.com\/blog\/author\/prerana-singh\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Create Charts In PHP By Fetching Data From MongoDB","description":"Learn to fetch NoSQL data from MongoDB with PHP and render multi-series FusionCharts. Covers MongoDBClient setup, autoload, JSON import & chart binding.","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.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/","og_locale":"en_US","og_type":"article","og_title":"How To Create Charts In PHP By Fetching Data From MongoDB","og_description":"NoSQL databases are a boon when it comes to scalability. Learn all the steps to build strikingly beautiful charts in PHP using data coming from MongoDB.","og_url":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/","og_site_name":"FusionBrew - The FusionCharts Blog","article_published_time":"2017-10-12T14:27:08+00:00","article_modified_time":"2026-06-03T11:15:16+00:00","author":"Prerana Singh, Gagan Sikri","twitter_card":"summary_large_image","twitter_image":"https:\/\/www.fusioncharts.com\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png","twitter_misc":{"Written by":"Prerana Singh, Gagan Sikri","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#article","isPartOf":{"@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/"},"author":{"name":"Prerana Singh","@id":"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/person\/d160bebbc408a11542797e038733b9ce"},"headline":"How to Create Charts in PHP by Fetching Data from MongoDB 2026","datePublished":"2017-10-12T14:27:08+00:00","dateModified":"2026-06-03T11:15:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/"},"wordCount":578,"commentCount":1,"publisher":{"@id":"https:\/\/www.fusioncharts.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage"},"thumbnailUrl":"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/","url":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/","name":"How To Create Charts In PHP By Fetching Data From MongoDB","isPartOf":{"@id":"https:\/\/www.fusioncharts.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage"},"image":{"@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage"},"thumbnailUrl":"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png","datePublished":"2017-10-12T14:27:08+00:00","dateModified":"2026-06-03T11:15:16+00:00","description":"Learn to fetch NoSQL data from MongoDB with PHP and render multi-series FusionCharts. Covers MongoDB\\Client setup, autoload, JSON import & chart binding.","breadcrumb":{"@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#primaryimage","url":"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png","contentUrl":"\/blog\/wp-content\/uploads\/2017\/10\/blog-1.png","width":2016,"height":750,"caption":"charting in php and mongoDB"},{"@type":"BreadcrumbList","@id":"https:\/\/www.fusioncharts.com\/blog\/how-to-create-charts-php-mongodb-nosql-fusioncharts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fusioncharts.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Charts in PHP by Fetching Data from MongoDB 2026"}]},{"@type":"WebSite","@id":"https:\/\/www.fusioncharts.com\/blog\/#website","url":"https:\/\/www.fusioncharts.com\/blog\/","name":"FusionBrew - The FusionCharts Blog","description":"Get tips and tricks on how to build effective Data Visualisation using FusionCharts","publisher":{"@id":"https:\/\/www.fusioncharts.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fusioncharts.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.fusioncharts.com\/blog\/#organization","name":"FusionCharts","url":"https:\/\/www.fusioncharts.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/logo\/image\/","url":"\/blog\/wp-content\/uploads\/2020\/03\/idera-fc-logo.svg","contentUrl":"\/blog\/wp-content\/uploads\/2020\/03\/idera-fc-logo.svg","width":1,"height":1,"caption":"FusionCharts"},"image":{"@id":"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/person\/d160bebbc408a11542797e038733b9ce","name":"Prerana Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fusioncharts.com\/blog\/#\/schema\/person\/image\/c3a2501c113e420c92343a5caf1ccc58","url":"\/blog\/wp-content\/wphb-cache\/gravatar\/883\/8839d500f92b36cec1f99073ef09cf90x96.jpg","contentUrl":"\/blog\/wp-content\/wphb-cache\/gravatar\/883\/8839d500f92b36cec1f99073ef09cf90x96.jpg","caption":"Prerana Singh"},"url":"https:\/\/www.fusioncharts.com\/blog\/author\/prerana-singh\/"}]}},"_links":{"self":[{"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/posts\/16361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/comments?post=16361"}],"version-history":[{"count":0,"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/posts\/16361\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/media\/16370"}],"wp:attachment":[{"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/media?parent=16361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/categories?post=16361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/tags?post=16361"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.fusioncharts.com\/blog\/wp-json\/wp\/v2\/coauthors?post=16361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}