Please help me find SPARKLINERENDERER class

Dear Sirs,

My name is Toan.
Now I have some issues related to Vaddin.
I am using Grid Control which is similar with “Column Renderer”, but I can find out SPARKLINERENDERER class.
Can you send me source code of that class SPARKLINERENDERER ?

Thank you and best regards!

Hi!

If you mean the renderer used in
sampler
, I’m afraid that class is not publicly available anywhere, and I don’t have access to it even myself. Have you tried to make a similar renderer of your own? You could check out the
Sparklines add-on
sources for help on the sparklines part, and the built-in renderer classes from Vaadin core for help on the renderer part if you haven’t made a custom renderer before.

I will try my best to attempt.
And if you have any information related to my issue, don’t hesitate to tell me.
Once again, thank you so much for your help!

Hi Toan!
Did you have any luck with the SparklineRenderer?

vaadin charts 2.1 and newer contains a sparkline class, whcih you can use in a generated column in a table.

http://http://demo.vaadin.com/javadoc/com.vaadin.addon/vaadin-charts/2.1.0/

I think he’s after a renderer to put in a grid, not a table. I found this thread looking for the same thing. Looks like something that would be of great benefit to the community :slight_smile:

Creating such renderer should be relatively straightforward if you limit the functionality to basics. There are two alternatives to set values of the Sparklines add-on (
https://vaadin.com/directory#!addon/sparklines
). The other passes the list of values as a String. If you forget Collection in your Renderer, it is quite simple to handle RPC of the String and store in the Grid’s container. I suggest to mimic the design pattern used in TextFieldRenderer here (
https://vaadin.com/directory#!addon/grid-renderers-collection-for-vaadin7
) That extends ClickableRenderer, which could be good choice for SparklinesRenderer too in case you want to use Sparklines as thumbnail to open real Charts in master detail UI pattern fashion.

Hi all!
Being new to Vaadin, GWT and all these technologies, and having very short deadlines, I came up with a simplistic solution to render a sparkline into grid. I use the HtmlRenderer for the column, and I build the svg code server-side. In my first attempt I followed the steps given in
https://vaadin.com/docs/-/part/charts/java-api/charts-advanced.html
I created the Sparkline object with Vaadin Charts 3.0.0 add-on and got the svg html code through the SVGGenerator. But this was really slow (about 3 secs per sparkline), for reasons I do not know. I ended up building the svg code myself… which is really easy.
I hope to revert soon with the client-side rendering of the svg!

I think building the SVG on the server is not a bad option at all. It bit breaks the abstraction, but so does using renderers as then you are working on the client side.

If you want to make it bit cleaner (and possible also make your sparklines bit cooler), you could try using the old Table or Grid with
ComponentRenderer
extension. This way you can use either Vaadin Charts (IIRC the latest version has built in sparkline support) or the Sparklines add-on. The ComponentRenderer is still marked as experimental, but if it works, I’d definitely go this way.

cheers,
matti

As I claimed, writing Sparkline Renderer should be quite straightworward, I felt that I needed to do it. So it is now part of the Grid Renderers Collection Add-On. By digging deeper how the SparklineGWT widget works, I found that actually it was easiest to make it to take Collection of Numbers as input. If your Bean in container has numbers in some other format, like JSON string or something like that, you need to create suitable converter from your format to Numbers. I also added configuration class which you can use to set parameters of the Sparkline like line width, colors and what visible elements are enabled.

https://vaadin.com/directory#!addon/grid-renderers-collection-for-vaadin7