helmuteke Report post Posted August 27, 2015 (edited) Hello , can somebody give me a php example for create a Multi-series 2D Dual Y Combination Chart like the link http://www.fusioncharts.com/dev/chart-attributes.html?chart=mscombidy2d i have one mysql query with 3 values : name (categorie) , speed , value so i wanne for the value a Block and for the speed a line in one chart pls can someone help me ?? this is the code for simple bar chart <?php error_reporting(E_ALL); ini_set('display_errors', 1); /* Include the `fusioncharts.php` file that contains functions to embed the charts. */ include("includes/fusioncharts.php"); /* The following 4 code lines contain the database connection information. Alternatively, you can move these code lines to a separate file and include the file here. You can also modify this code based on your database connection. */ $hostdb = "localhost"; // MySQl host $userdb = ""; // MySQL username $passdb = ""; // MySQL password $namedb = ""; // MySQL database name // Establish a connection to the database $dbhandle = new mysqli($hostdb, $userdb, $passdb, $namedb); /*Render an error message, to avoid abrupt failure, if the database connection parameters are incorrect */ if ($dbhandle->connect_error) { exit("There was an error with your connection: ".$dbhandle->connect_error); } ?> <html> <head> <title>FusionCharts XT - Column 2D Chart - Data from a database</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <!-- You need to include the following JS file to render the chart. When you make your own charts, make sure that the path to this JS file is correct. Else, you will get JavaScript errors. --> <script src="js/fusioncharts.js"></script> </head> <body> <?php $strQuery = "call rondesploeggrafiek"; //get the values // Execute the query, or else return the error message. $result = $dbhandle->query($strQuery) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}"); // If the query returns a valid response, prepare the JSON string if ($result) { // The `$arrData` array holds the chart attributes and data $arrData = array( "chart" => array( "caption" => "Totaal aantal rondes", "paletteColors" => "#0075c2", "bgColor" => "#ffffff", "borderAlpha"=> "20", "canvasBorderAlpha"=> "0", "usePlotGradientColor"=> "0", "plotBorderAlpha"=> "10", "showXAxisLine"=> "1", "xAxisLineColor" => "#999999", "showValues" => "0", "divlineColor" => "#999999", "divLineIsDashed" => "1", "showAlternateHGridColor" => "0" ) ); $arrData["data"] = array(); // Push the data into the array while($row = mysqli_fetch_array($result)) { array_push($arrData["data"], array( "label" => $row["alias"], "value" => $row["rondes"], "color" => $row["kleur"] ) ); } /*JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */ $jsonEncodedData = json_encode($arrData); /*Create an object for the column chart using the FusionCharts PHP class constructor. Syntax for the constructor is ` FusionCharts("type of chart", "unique chart id", width of the chart, height of the chart, "div id to render the chart", "data format", "data source")`. Because we are using JSON data to render the chart, the data format will be `json`. The variable `$jsonEncodeData` holds all the JSON data for the chart, and will be passed as the value for the data source parameter of the constructor.*/ $columnChart = new FusionCharts("column3D", "myFirstChart" , 700, 400, "chart-1", "json", $jsonEncodedData); // Render the chart $columnChart->render(); // Close the database connection $dbhandle->close(); } ?> <div id="chart-1"><!-- Fusion Charts will render here--></div> </body> </html> Edited August 27, 2015 by helmuteke Share this post Link to post Share on other sites
Vishalika Report post Posted September 2, 2015 Hi, Welcome to FusionCharts Forum!!! You can explore our PHP wrapper in this link: http://www.fusioncharts.com/php-charts/ You can refer the following sample of PHP with FusionCharts using XML: 1. Using Single series data: https://www.dropbox.com/s/4g2gur3f3vdeb67/php_samplewith_%20XML.rar?dl=0 2. Using Multiple series data: https://www.dropbox.com/s/s7hq6bjqxk5x6ar/php_multiseries_%20XML.rar?dl=0 For reference these sample will help you how you can generate the data format for the Combination chart type. Hope this helps. Share this post Link to post Share on other sites
vantel15 Report post Posted December 25, 2015 How do with JSON, not XML, because now i'm using JSON in PHP, can someone help me to make multiple series with JSON Fusioncharts and PHP MySQL...??? Share this post Link to post Share on other sites
Vishalika Report post Posted December 29, 2015 Hi, Sharing a sample of PHP and MySQL with JSON data: https://www.dropbox....hp-sql.rar?dl=0 Please check and share your feedback. Share this post Link to post Share on other sites