PDA

View Full Version : Sparklines



ingo.klose
01-30-2008, 08:34 AM
Hi,

I was wondering if someone ever tried or succeeded in incorporating "Sparklines" (about Sparklines) (http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR) into a report using the classic engine.

@Taqua
Do you think that would be a nice feature for the engine? I think is is a nice way to add value/information to a report by showing trends along KPIs within a report/table.

Best regards,
Ingo

Taqua
01-30-2008, 09:47 AM
oh, yes, it is a nice (and sensible) idea. But for the exiting chart support, I still wake up screaming just by thinking about the mess that's needed to get ordinary charts to work. :)

But if you are not afraid of it, then you can do it (by XML, no GUI support yet) even today. All you need are simple inline images like that:

<band x="0" y="0" width="100%" height="20" layout="inline"><label>Your text</label><drawable-field width="100" height="20" fieldname="yourChartExpression"/><label> some more text</label></band>

We have no sensible rich-text definition format yet, thats why this feature is not advertised in the 0.8.9-changelog. I'm not evil enough to force users to use crude definitions like the one above. Once we come up with a more sensible format, we will make the rich-text capabilities public. At that point, the Sparkline-capabilities are only one chart away.

ingo.klose
01-30-2008, 09:55 AM
Hi,

thanks for the quick response. When I understand this right, I could add one "Sparkline" within a text, e.g. in the report header.

But it is not be possible to add them in the item band as a column, right? I could imagine using some sort of sub report for that, but subreports are currently treated like seperate bands, right?

Taqua
01-30-2008, 10:06 AM
Well, you could as well add them as column. The reporting engine treats charts, images, and all other non-textual content in the same way. So if you have a sane way to create the images or drawables for the sparklines, you can use them in whatever way you want. The example above shows how to embedd them in text - if you want to see the spark-lines as own column then simply add a ordinary image-field or drawable-field to the report and you will have solved the problem.

Taqua
01-30-2008, 10:08 AM
Hmm .. a quick google search gave me this site: http://www.representqueens.com/spark/

I guess JFreeCharts is too heavyweight for this kind of charting, so lets see what we can do with that library.

ingo.klose
01-30-2008, 10:15 AM
sounds good... :-)

gregwmarvin
02-18-2008, 02:12 PM
Have you made any progress using the sparkline library at http://www.representqueens.com/spark/?

Greg

Taqua
02-19-2008, 03:48 AM
Sparklines will be part of the 0.8.10 release. The code is already in the jfreereport-ext project and adds "sparkline-expressions" as well as "sparkline-fields".

Mimil
03-02-2008, 03:34 PM
Hello,

look how this sparkline-graphs reporting extension (http://wiki.pentaho.org/display/%7Emimil/Reporting+Extensions) is eye candy, and it is all free for you now =) :


Regards,

ingo.klose
03-03-2008, 02:42 AM
Hi guys,

really impressive how fast you incorporated the sparklines. Great job!!!

Looking forward to check it out!

Regards,
Ingo

bugg_tb
08-24-2008, 12:40 PM
has anyone got a sample report definition that us morons can chop up and use? I'd like to say cedric's wiki post makes sense, but, *sigh*, well it doesn't :)

Cheers

Tom

Taqua
08-25-2008, 06:46 AM
There is a sparklines-demo in the demo package (package (..).demo.elements.sparklines).

Basically, you have two options to get your sparklines:

(1) Use a generic drawable element and one of the sparkline-expressions. (Same technique as with chart-expressions). The sparkline-expression expects the name of a data-source expression/field from where to read the data. The data-source-expression can return either a comma-separated string of integers, or can return a array of integers.

Mimil's example used a formula-expression named "sparkline-data" that returned an array. The formula with curly braces defines an array in the open-formula syntax, and every element itself can be a valid open-formula term (ie, a calculation, a field-reference, whatever).

(2) If you use the unified-fileformat (the *.prpt thing) then you alternatively have the option to define sparklines as sparkline-elements. In that case, your sparkline gets its data from the field or value attribute (like any other report-field) and can be computed inline via a attribute-expression, if you want to.

Mimil
09-02-2008, 10:28 AM
Hi there,

I slightly updated the wiki page with more demo source code.

Regards,

hirfuin
09-24-2009, 07:10 AM
Hi,

I can't work out how use sparkline on new Report Designer 3.5 RC2.

I've tried quite anything:


bar-sparkline, line-sparkline
picking data from field, setting data throw value formula, setting sparkline formula in fileld
report header, details
forum, google etc. searches

I'm arrived at those thin results:


bar-sparkline used with numeric field in details shows only one bar if the number is throw 1 to 50

Anyone can give me links to documentation or helps?
Tks!:)

bamaer
09-24-2009, 07:33 AM
Have a look at the example in the welcome window --> Operational Reports --> Sparkline.

In that example, that data for the sparkline is fetched (Y2003, Y2004, Y2005).
The data is then concatenated into a comma separated string using an Open Formula function (see SparkLineData).
The result of the Open Formula function is used as the data source for the sparkline.
Of course you could do the concatenation directly in your query as well.

hirfuin
09-24-2009, 07:45 AM
Tks for your fast reply.
In 3.5.0-RC2.10067 there isn't that example.

Where can I find that example field?
Tks!

hirfuin
09-24-2009, 07:47 AM
*file

Sorry ;-)

bamaer
09-24-2009, 07:54 AM
I've attached it.
Looks like it was included in RC1 but not in RC2.

hirfuin
09-24-2009, 08:48 AM
Thank you,
it worked great!

But I am a curios one:


What does function sparkline is supposed to do and how can it be used?
There's some documentation about Report Designer including also those functions? (I mean also classess javadocs, xml references and so on).

ThinkingPhoneNetworks
09-24-2009, 05:39 PM
Alessandro,
I have created a sparkline report and I did not use the sparkline function. In my sql query (mysql), I use the "group_concat" function. This will take my data in rows and return it as a string, ie (5,6,4,5,6,4,3,5,3,5). Here is an example I used in SQL:


CAST(group_concat(data.amount order by the_date) as CHAR)
Then just double click the sparkline and input the name of the column. I have one sparkline for every row in my dataset.

I know this didn't really answer your questions, but I hope its still helpful :)

- Dan

Taqua
09-24-2009, 06:24 PM
The sparklines want either a string of csv-separated-ints or a real Number[].

You can build number-arrays from existing columns with the array-syntax of libformula


={[field1] | [field2] | [field3]}

The sparkline-function produces the same result as the sparkline-element, but has the advantage that you can pass the result around in other formulas and expressions. (And it also helps those caught in the old age who have reports that used sparkline-expressions backported to the previous report versions).

wvaibhav
10-28-2009, 06:05 AM
Hi all,

Found the article at

http://b-e-o.blogspot.com/2009/10/creating-sparklines-in-pentaho-report.html

Thanks Bart Maertens.

Vaibhav Kumar