Adding RGraph to your website and creating faster charts
These pages tell you how to install RGraph, optimise it and integrate it into your website.
Benefits of RGraph
Read about the benefits of using RGraph to show charts on your website.
Benefits include things such as saving money, better website performance and it also allows you to create pretty charts!
Browser support for RGraph
Information about browser support for RGraph. For years now browser support for canvas and SVG has been good with most of both desktop and mobile browsers able to display them.
HTML5 canvas & Internet Explorer
Details of Internet Explorer support. More recent versions of Internet Explorer have had good support for canvas and SVG, since version 9.
Details of support for other devices. Typically the newer the device then the more likely it is to have support for the canvas and SVG tags. In fact, it will be hard to find a device that doesn't have support these days (2017).
Creating your charts without a browser
How you can create your charts without a browser by using PhantomJS.
This is just a note with a link to the PhantomJS website. This means that you can create charts from automatic scripts, such as cron jobs.
- HTML5 canvas & Internet Explorer
Getting started with RGraph
How to start out with RGraph - a basic chart. This bit of information is an easy way to understand how RGraph works and how you can use it on your website.
- Suggested layout for RGraph
A suggested layout for the RGraph libraries. Having a good layout makes things easy to handle and makes things easier for future developers.
- Alternative structure for RGraph
An alternative layout for the RGraph libraries that could also be used. This layout includes dates in the filenames and so can make upgrading to a newer RGraph release quicker and easier.
- The $p() and $a() functions
RGraph has a few useful debug functions that you can use while making your charts.
These functions can make finding problems with your code easier. So much in fact that you may want to add them to your own code.
- Suggested layout for RGraph
Integration with server side scripting
Learn how to add RGraph to your server-side scripts.
This page has examples of using the PHP MySQL, MySQLi and PDO extensions.
Learn how to make AJAX requests, saving your (canvas) charts as images and how to read CSV data.
Integration with PHP and MySQL using the MySQL extension
Information about integrating RGraph with the older PHP MySQL extension. This extension has been deprecated for some time now but is still in use and is a easy way to connect to your database.
Integration with PHP and MySQL using the MySQLi extension
Information about integrating RGraph with the PHP MySQLi extension. The MYSQLi extension is a newer way that PHP has available to connect to your MySQL database server.
Integration with PHP and MySQL using the PDO extension
Information about integrating RGraph with the PHP PDO extension.
Like the MySQLi extension PDO is a newer way to fetch data from your database server, but PDO is more of an abstraction interface that can connect to other database servers as well as MySQL.
Making AJAX requests
Information about making AJAX requests with RGraph.
RGraph has some AJAX functions that are available to both the SVG and canvas libraries that make it much easier to fetch data by AJAX.
If they're not good enough for you though you can always use other AJAX libraries or functions such as the jQuery $.ajax() function.
Saving the chart as an image on the server
In some cases this can actually improve performance too as the amount of data that is sent by the server is smaller.
- Integration with PHP and MySQL using the MySQL extension
Improving the performance of your charts
Hints and tips on how to improve the speed of your charts and also your entire website.
The tips here are aimed at increasing the speed of your charts but many can also be applied across your whole site (eg using Gzip compression) giving your website and your charts even more of a speed boost.
Studies have shown that having a faster website can make your users happier and can then lead on to bigger sales figures and turnover!
A reasonable performance strategy
What's a good way to improve the speed of your charts?
Well not every tip or tweak needs to be used so this is what you should consider doing first as these tips give the biggest bang for your buck.
General website performance tools
Links to a few useful more general website speed tools which can be used to gauge the effect of your speed tweaks.
These tools can be used to increase the speed of your entire website - not just your RGraph pages. You'll find that the PageSpeed tool, in particular, is very useful.
Note about performance and HTTP/2
A note about how HTTP/2 means that some of the performance tweaks that are listed here will become less necessary.
The main thing to remember with HTTP/2 is that it takes place over a single connection (per server) so keep that in mind when planning your performance tweaks.
- A reasonable performance strategy