The Statistics add-on has received a complete re-write in order to add support for showing charts and statistical data on the front end of your website. The add-on comes with pre-set types of data that you can select to show either as a table or using charts (or both).
Depending on your websites size or the number of transaction it processes, querying these data can be “expensive”. So to minimize load on your database, results are “cached”. By default, these data is updated each time a users balance changes or if a log entry is added / edited / deleted. But you can also select if you want to store data longer and only update it once an hour, every six hours, twice a day or once a day. This way, sites with large number of transactions will not need to query new stats on every transaction.
All charts are powered by Charts.js 2.7.0
You can create charts using the following new shortcodes:
|[mycred_chart_circulation]||This shortcode will render charts based on the amount of points that currently exists amongst your users for each point type.|
|[mycred_chart_gain_loss]||This shortcode will render charts based on the amount of points that has been given to users vs. the total amount taken.|
|[mycred_chart_history]||This shortcode will render the average point gain on your site for x number of days/weeks/months/years|
|[mycred_chart_top_balances]||This shortcode will render a list of balances ordered by size.|
|[mycred_chart_top_instances]||This shortcode will render a list of the most common ways your users gain points on your site based on references.|
|[mycred_chart_instance_history]||This shortcode will render the total amount of points your users has gained / lost on a daily/weekly/monthly/yearly basis.|
|[mycred_chart_balance_history]||This shortcode will render the total amount of points a specific user has gained / lost on a daily/weekly/monthly/yearly basis.|
As of version 2.0, the Statistics add-on will have it’s own tab on the settings page. This is where you can set optimization options and colors for each point type.
The new myCRED_Chart object has been added to help render charts. When using this object, we render canvas elements where the chart will be rendered, while the actual data is populated under the
$mycred_charts global. This global is then fed to Chart.js in the footer of the website. This means that charts will not render if the wp_footer function is used!