Documentation
| Project: | Sparkline generator and filter |
| Version: | HEAD |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | Chris Johnson |
| Status: | active |
Jump to:
Great idea ... I just wish I could figure out how to get it to work. Would it be possible to receive detailed instructions on how to implement this module?
Sparkline filter: [sparkline style=line|bar|winloss height=15 12,3,-2,39,23,2,......]
In particular, I am having difficulty configuring the filter to display any sparkline graph. The 'style' and 'height' setting seem straight forward enough, but it's unclear what the series of numbers at the end of your example are. I can only guess that they are manually entered data for the vertical units of the graph, but that seems very limited and static. I feel that I must be missing something. Can the sparkline module display dynamic data, as from a database or feed?

#1
After enabling the module, you'll need to do a couple of other things.
1. Go into your input formats and enable the sparkline filter, if you want to use the filtered format you outlined above.
2. Go into the admin settings for the sparkline module, and make sure the paths for the third-party PHP sparkline library and the sparkline cache files are correct. These can be annoying to get right.
3. You did install the 3rd-party PHP sparkline library, right?
Then to use the filter, you create a node (blog, story, etc.) using one of the input formats for which the sparkline filter has been enabled. A sample sparkline embedded into such a posting might be like this:
Fish caught this year by month: [sparkline style=bar height=15 0,0,0,4,25,33,12,18,10,0,0,19]
That's how the filter feature is used.
If you want to display dynamic data, such as from a database or feed, you'll need to write some PHP code, probably in your own module. The sparkline module exposes an application programming interface (API) to the sparkline library which you can call to generate sparklines.
Hope that helps.
#2
I believe that I've followed the directions exactly: The sparkline library is installed; the paths to the sparkline library and the cache files are correct (and validated by the system); and an Input Filter has been configured, activated, and set as the default Input Filter. I have alternately retyped and cut-and-pasted your Fish-Caught example into a story node. Each attempt ends in a blank page.
Drupal: 5.7
MySQL: 5.0.41
PHP: 5.2.5
Apache: 2.0.59 (Unix)
#3
Ditto: not working for me either. It just prints out the text of the filter inline just like this [sparkline style=line ....].
Drupal 5.6
GD library bundled (2.0.34 compatible)
MySQL database 5.0.45
PHP 5.2.4
Unicode library PHP Mbstring Extension
Web server Apache/2.2.6 (Fedora)
Time to start adding print statements into the code, I guess....
#4
Erehm, that sounds like Sparkline hasn't been activated in the Input Filters. Clearly, I am not an expert on this module, but it might be worth double checking your Input Filter settings/configuration. Then again, maybe it's not the Input Filters and problems are indeed related. Who knows.
The problem I am reporting is that once Sparkline is activated, it is generating a wholly blank page -- no header, no navigation block, no story, no nuthin'. It's all white.
It would be nice if the Sparkline issue queue got a little more love.
#5
that sounds like Sparkline hasn't been activated in the Input Filters
I agree. Here's what happens. I go to admin/settings/filters and I see all four filters, in this order:
Filtered HTML
PHP code
Full HTML
Sparkline
Of course, I added the last one (Sparkline) myself, checking only the "Sparkline filter" checkbox in the "Filters" section on the "Sparkline input format page". Is there anywhere else I should check for "activiation"?
BTW, I ran the sparkline code (http://sparkline.wikispaces.com/PHP+Library+Sample+Script) from a command line script and with one change to the last line (see below), I got the library to create sparkline PNG file. So...the PHP sparkline library itself is working fine.
$graph->output('foo.png')#6
You described creating the a new input format, naming it "Sparkline," and activating the "Sparkline" filter to be used in the "Sparkline" filter format. Did you then make the "Sparkline" filter format your default, or you selected the "Sparkline" filter format within your test post?
The only thing I can offer beyond my question above is to refer you back to Chris Johnson's instructions in Reply #1 of this thread. That's all the documentation there is so far.
#7
Of course I selected the "Sparkline" filter format in my test post. It simply just prints the post with the inline filter as test, e.g.,
Submitted by erehm on Tue, 02/12/2008 - 15:32.
This is a sparkline [sparkline style=line height=1,2,3,4,5,6,6,5,4,3,3,3] in line with text
»
* erehm's blog
Something appears to be broken I think.
#8
Don't put
height=x,x,x. That won't work. I believe height should only have one value as it defines the height of the entire graph/picture.For instance; define height as 15 and then put in a space after the height value (ie
height=15)and the static numbers (ie1,2,3,4,5,6,6,5,4,3,3,3)So you get something like;
[sparkline style=line height=15 1,2,3,4,5,6,6,5,4,3,3,3]and not;
[sparkline style=line height=151,2,3,4,5,6,6,5,4,3,3,3]Or just remove height entirely, as default height is 15px anyways:
[sparkline style=line 1,2,3,4,5,6,6,5,4,3,3,3]But keep your space between the defined values and the static numbers you put in (ie between style=line and 1,2,3, etc)
Hope this helps. :)
One question though; where can I find a documentation for what settings I may define in the sparkline code? style=bar etc? Until now I've only relyed on the examples in this thread, and I believe that is somewhat limiting :P
#9
Thanks unleached.... you were right... I feel like such an idiot, but I am happy to have sparklines working!
#10
Finally got my blank page issue solved. I downloaded a fresh Sparkline-php-0.2, implemented the edits described in http://drupal.org/node/131060, and it worked.
That said, it might be beneficial to include an updated install.txt file with the module.
#11
Sorry I haven't gotten around to writing better documentation, or even giving the issue queue much love. This is such a small and little-used module, and I'm -- well, like most people -- busy with life.
Still, if anyone or several someone's would draft even the crudest of documentation, I'd be happy to edit it for correctness, style and grammar (even!) and add it to the module.
#12