Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-01-09 21:42:13

stephan
Plugin Author
From: Bochum, Germany
Registered: 2004-07-26
Posts: 196
Website

[Solved] How do I implement a meter/graph

One of my New Year’s resolutions was to do a specific number of excercises during each month and the entire year. I would now love to add this to textpattern somehow. Here’s the idea:

Every day I will do either none or any (hopefully high) number or excercises. Then add this to my site and my visitors will be able to see some chart/graph/meter that says how many I have already done in this year/month/week (maybe this could be configured?). Also I can either set a goal (must reach 1000 excercises in a month) or no goal (just do as many as possible).

For the time being I would be perfectly happy to just show something quite simple on my site without any specific goals or fancy graphics. But I wonder if there is any solution for this, as I can think of many other examples where it could be used (think of fundraising, losing weigth tracker, days sick within the last year, number of times some Apple fan-boyish article appeared on your favorite news page, etc.)

Maybe there is already a plug-in for this? If not, do you know anyone to approach that might be interested in doing something like this?

Thanks for reading up until here – I promise, there’s nothing more in this post :-)

Last edited by stephan (2010-01-10 14:19:34)


Yoko for Textpattern – A free blog themeMinimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often

Offline

#2 2010-01-10 06:28:53

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: [Solved] How do I implement a meter/graph

Google has a chart api


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2010-01-10 14:19:21

stephan
Plugin Author
From: Bochum, Germany
Registered: 2004-07-26
Posts: 196
Website

Re: [Solved] How do I implement a meter/graph

Hello MattD,

thanks, but I fear the entire Google chart API was a little too complicated for me. But I discovered a PHP/GD script that draws a simple thermometer. Using that and some magic with txp variables I was able to accomplish my goal. You can see it live on feierabendyogi.de

If anyone else ever has the need to implement this, maybe this helps:

Disclaimer: I have no idea how smart or stupid this solution is, but it seems to work for me. Unfortunately I did not add any checks to make sure the custom fields and variables actually contain just plain numbers, so things may break because of unexpected content. Not scared yet? Let’s see what I’ve done!

First, I created a file called thermostat.php in my web root, which I downloaded from obleDesign (thanks to Adam Crownoble).

Next I created a section specific for my “fundraising” or better: my excercises.
I used three custom fields to input my values (set the name in the administration preferences):
custom1: excercise1
custom2: excercise2
custom3: goal

I created one sticky article for this section (actually it is the only article in the “excercise-challenge” section, but making it sticky just felt better).

Beware: I need to do a simple calculation in order to add both excercises – that is done using the plug-in adi_calc.

In my forms for the sidebar I added one form for my challenge-meter:

<div class="widget">
<h3>Surya-Challenge 2010</h3>

<txp:article_custom allowoverride="1" excerpted="0" limit="1" pgonly="0" section="excercise-challenge" status="5">
<txp:variable name="excercise1" value='<txp:custom_field name="excercise1" />' />
<txp:variable name="excercise1" value='<txp:custom_field name="excercise2" />' />
<txp:variable name="count" value='<txp:variable name="excercise1" />' />
<txp:adi_calc name="count" add='<txp:variable name="excercise2" />' />
<txp:variable name="goal" value='<txp:custom_field name="goal" />' />

<p>My goal for 2010: <txp:variable name="goal" /> excercises.<br />Latest results:</p>

<p><strong>Excercise A:</strong> <txp:variable name="excercise1" /><br />
<strong> Excercise B:</strong> <txp:variable name="excercise2" /></p>
<p><img style="display: block;
margin: 0px auto;" src="http://yauh.de/thermostat.php?goal=<txp:variable name="goal" />&progress=<txp:variable name="count" />&w=25&h=100" /></p>
</txp:article>
</div>

Last edited by stephan (2010-01-10 14:20:44)


Yoko for Textpattern – A free blog themeMinimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often

Offline

#4 2010-02-25 20:41:51

stephan
Plugin Author
From: Bochum, Germany
Registered: 2004-07-26
Posts: 196
Website

Re: [Solved] How do I implement a meter/graph

I’ve taken it a step further and created a plug-in that will enable you to easily create graphs using the JavaScript library Bluff. Find more info here


Yoko for Textpattern – A free blog themeMinimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often

Offline

Board footer

Powered by FluxBB