PasiChart Filters & Functions

NB. This page documents features of the upcoming PasiChart WP plugin. All of these features are not yet implemented, and this page doubles as a to-do list for myself. It’s a good preview for you folks out there as well. Comments are welcome.

Post & Page Filters

PasiChart plugin filters the posts and pages you create and replaces properly formatted strings with appropriate chart images. A few examples of this functionality can be seen on the test page.

Main tag

All PasiChart strings begin with double opening brackets and string “pasichart”, and end with double closing brackets. In simplest form you get an empty chart by writing [[pasichart]], as shown below.

Before the first closing bracket you can give parameters for the chart. The following table illustrates the available options.

Tag Description Other tags
[[pasichart db X]] Draw chart data from database table, which has ID X. Tables can be managed through administration interface. No other tags allowed.
[[pasichart normal]] Generate chart image from value given in following tags. This is the default, not necessary to explicitly specify. The following tags specify the data.
[[pasichart blog]] Generate chart image from number of posts and comments in this blog. Some of the other tags can be used to customize, but not to add data.

Customization tags

These tags can be used to customize the chart image, and are valid with all the chart types, except the db type. The tags are enclosed within their own single brackets after the main tag, and before the final closing bracket.

Caption tag allows you to specify caption for the image. If caption is not specified, the space is freed for the chart. For example, you could write [[pasichart]], which results in the following chart image.

This is a test

… To be continued…


For inserting charts into sidebars and any other places than the actual posts and pages, you need to use PHP functions. Actually, there’s only two functions available. Below are their descriptions.

mixed pasichart_insert_graph ( [ int chart_id [, bool echo_tag ] ] )

This function draws chart data from database with the chart ID number. If no ID number is given, it defaults to lowest ID number in database. If echo_tag is TRUE (as it is by default), the generated image tag is echoed directly to output; otherwise, it’s given as return value. If return value is FALSE, something went wrong, which usually means that the chart ID was not correct/found.

bool pasichart_insert_blog_stats ( [ int data [, int type [, int days [, int width [, int height [, string caption [, bool echo_tag ] ] ] ] ] ] ])

Generates graph from this blog’s post and comment history. Parameters:

Parameter Values Default
data 0 – Posts and comments
1 – Only posts
2 – Only comments
type 0 – Daily
1 – Weekly
2 – Monthly
3 – Yearly
days 0 – Entire blog history
Other – Amount of days backwards from today
width 0 – Default width (300px)
Other – Width of graph image
height 0 – Default height (200px)
Other – Height of graph image
caption Title text of the chart empty
echo_tag TRUE – Echo proper image tag to output
FALSE – Return proper image tag

Function returns TRUE on success, and FALSE otherwise. Reasons for possible failure remain undefined.

6 thoughts on “PasiChart Filters & Functions”

  1. Hi,

    I would like to use this plugin, but I seem to be having some problems understanding how to plot arbitrary data.
    Can you give me an example of how to do a simple y(x) plot?


  2. Hi Bruno!

    If you’re asking how to plot functions, then I’ve to say that I haven’t even planned to support that. (However, that’s only because I hadn’t thought of it. Not a bad idea though.)

    Otherwise, the plugin is still in a very early phase of development. Basically this means that you can’t choose the values in the horizontal axis at all, they just run up from zero, one by one.

    Thus, with x being an array index of y, which in this example is the Fibonacci series, you can insert a set of data by writing [series y 0, 1, 1, 2, 3, 5, 8, 13, …] inside the pasichart brackets.

  3. Dear Pasi,

    Thank you for this great plugin. I want to put it on my sidebar. But I just don’t understand how to do it.
    I’ve got WP 2.2. and I can’t see any options in the dashboard. So I can’t find where to make a chart data from database.
    Could you please make a step-by-step tutorial how to do it?
    Thank you!


  4. Hi Alexey!

    If you want a sidebar widget graph, try my Simple Graph Plugin. This PasiChart thingy is very preliminary version and doesn’t even have any dashboard options implemented at all.

    Only way to use PasiChart is through using the filters and functions described on this page (and the test page). However, as there is no database management implemented, pasichart_insert_graph function is pretty useless. 🙂

    I’m not currently planning to develop this plugin further. It’s GPL licenced though, so anyone is welcome to contribute or even take over!

  5. Bruno, nice work! Indeed, why should anyone re-invent the wheel. Had I known of such library, I might have used it myself. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *