Wordpress Plugin: Download Counter Visualization

Widget Chart example

Widget Chart example

last update: 2010-04-14

This plugin adds a widget to display download statistics based on the Download Counter plugin on your site. The sidebar widget will show a highly configurable chart based on the Google Chart API. Furthermore it offers a dashboard widget that summarizes your downloads, to get information quick at a glance.

The plugin supports following chart types:

  • Bar (horizontal)
  • Pie
  • Pie 3D

You can include a chart of your downloads on a page or in a post using the downloadcounterchart-shortcut. Of course a download chart is includable in your theme. See extended documentation for detailed explanations for that.

Demo

Download Chart

Installation

Note: This plugin depends on the Download Counter plugin (version 1.01), so you may need to install it as well.

  1. Upload `wp-downloadcounter-chart.zip` to the `/wp-content/plugins/` directory and unzip it. You may also use the install manager of wordpress to get the plugin.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. Add the Download Counter Chart widget to a sidebar and edit the options of the widget to your needs. You may simple add the widget to a sidebar and click save to setup the widget with default options.
  4. You can enable the Download Counter dashboard widget by activating it in the screen options area of the dashboard page.
  5. For usage in your theme or in a page / post see the extended documentation

Usage

There are several ways to include a chart of your downloads on your site.

Page / Post (Shortcut)

downloadcounterchart chart_type="pie" chart_width="490" chart_height="190" label_color="000000" label_size="11" sqlcondition="" bar_color="0066CC90" bar_height="-1" bg_color="FFFFFF00"

Note: You have to put the definition in square brackets ([]), but this can´t done here, cause it will be processed to a chart image.

Parameters:

  • chart_type – Type of the chart. Valid values: bar_horizontal, pie or pie3d.
  • chart_width – Width of the chart image in px. May be about the 2.5 times size of the height for a pie chart.
  • chart_height – Width of the chart image in px.
  • label_color – Hex color value for labels, optional with additional opacity value (e.g. 50% black = 00000050).
  • label_size – Font size of the labels.
  • sqlcondition – Optional SQL where statement, leave blank for all downloads.
  • bar_height – Bar chart only. You can explicitly set the bar height, but it may result in a chart that does not include all data, if the chart height is not big enough. Recommend to set -1 for auto-sizing.
  • bg_color – Background color. Hex color value, optional with additional opacity value (e.g. transparent = FFFFFF00)

Theme

downloadcounterchart_img($chart_type, $chart_width, $chart_height, $label_color = '333333', $label_size = '11', $sqlcondition = '', $bar_color='', $bar_height='', $bg_color='')

Parameters:
see section above

Example:

if (function_exists('downloadcounterchart_img') && class_exists('DownloadCounterChartApi')){
downloadcounterchart_img(DLC_CHART_PIE, 490, 190, '000000', '11', '', '0066CC', '-1', 'FFFFFF00');
}

Changelog

1.3

  • Fixed Bug: When files have been downloaded the same number of times, only one appears (Reported by MasterNoun, Thanks)

1.2

  • Pie and Pie3d chart types
  • shortcut to include in page/post
  • optimized bar height configuration

1.1

  • full configurable chart
  • redesign of dashboard widget

Further Screenshots

Widget Configuration

Widget Configuration

Dashboard Widget


10 Responses to “Wordpress Plugin: Download Counter Visualization”

  • Dusan Says:

    Hello,
    I’m looking for a kind of the chart, but I need to visualise a number of tags in wordpress blog. Something like tag cloud trasnsformed to pie chart. Could be modified this plugin to do this?

    Thank you, Dusan.

  • Michael Mrotzek Says:

    Hi Dusan,
    this would trespass the focus of this plugin. But you can create an new to show a pie chart of wordpress tags. Of course you can reuse the code from this plugin.

    Practically you have to change the underlying data which will rendered by the chart api. These changes are neccessary in wp-downloadcounter-chart.php:

    • change retrieving data function to request the tags (get_downloads() line 220) – you may use get_the_tags()
    • change preparation of data (get_chart_img() line 118-122), to use the tags name and count
    • change calculating values relative to each other (line 137), for your requirement => $values .= $k.',';

    I think that´s it.

    Greetings,
    micha

  • KillerSneak Says:

    Hi there.

    • Don’t have the edit page/reset counters page
    • sqlcondition”" <- I would like to get some more information on how to use this. I want to use serveral charts but this can’t be done without the SQLCONDITIONS tag and there’s no information about it at all.
  • Michael Mrotzek Says:

    Hi,

    you can filter your downloads by the database fields that the download counter plugin offers. The following exists for each download:

    download_id - bigint(20),
    download_name - varchar(64),
    download_url - varchar(255),
    download_added - datetime,
    download_count - bigint(20),
    download_last - datetime

    So you can filter your download chart by specifying sql where clause. E.g. for downloads that trespass a specific threshold of the download count: download_count > 10

  • MasterNoun Says:

    Problem for me.

    When files have been downloaded the same number of times, only one appears (first in alphabetical order i guess..).

    How to make appear all files, even if they’ve been downloaded the same number of times ?

  • Michael Mrotzek Says:

    Hi, I think this is a bug I´ll fix it in the next week.
    Greets, micha

  • MasterNoun Says:

    It would be great.
    Thanks for your work.
    ++

  • MasterNoun Says:

    So, I’ve got some issues.
    Horizontal bar does not work since I update (1.3), and now pie(s) do not work without any changeof mine (???)…

    Problem with google api ? Or too many downloads (number increased since the update) can’t be displayed ?

    So, just a few questions :
    1) Is it possible to limit the number of downloads shown (20 most download for example) ?
    2) Is there a simple way to display the “download counter” table witch is seen on the admin dashboard, on a page ?

    Thanks.

  • Michael Mrotzek Says:

    Hi,
    for me the plugin works, but I have not so many downloads. I have to test it with more data soon to give a feedback.

    as to 1): it´s possible and I´ll implement that feature
    as to 2): currently not, but it could be implemented as a shortcode, so that you can include easy it in post or pages

  • MasterNoun Says:

    Thanks for your answer.
    1) Cool. Maybe such option could fix my issues.
    2) This shortcode would be really helpfull because, according to me, a table is clearer than image charts, especially when you have a lot of downloads.

Leave a Reply