1.8 Guide – Statistics Add-on

Home / Blog / 1.8 Guide – Statistics Add-on

Statistics 2.0

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

New Shortcodes

You can create charts using the following new shortcodes:

Shortcode Description
[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.
Chart Types

Depending on which shortcode you select to use, you can choose between: Line charts, Bar Charts, Radar Charts, Pie Chart, Doughnut Charts and Radial Charts.

New Settings

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.

Optimization options is only available under your main point type (if you have more than one).
For Developers

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!

Last edited October 15, 2017

Comments are closed.