Sample BSV: Sparklines in Aware V7

Contains tips for configurators working with Aware IM
Post Reply
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Sample BSV: Sparklines in Aware V7

Post by hpl123 »

Hi all,
Here is a sample BSV of a implementation of Sparklines in Aware IM (v7) standard queries. There is a total of 7 Sparklines available and works with some small quirks (explained below).

Screenshot:
Sparklines.png
Sparklines.png (9.79 KiB) Viewed 22017 times
Instructions (Windows example):
1. Unzip "Sparklines.zip" (attached)
2. Create a folder called "sparklines" in the main Aware IM folder (same folder that contains the "startup.html" file) and move file "jquery.sparkline.min.js" into that folder
3. Create a folder called "Temp" on C: and move files "sparkline1.txt" to "sparkline7.txt" into that folder.
4. Add the following to "startup.html" (to just before the JS seperator):

Code: Select all

<script type="text/javascript" src="sparklines/jquery.sparkline.min.js"></script>
5. Add the following CSS class to your theme or Custom CSS file:

Code: Select all

.jqstooltip{
    box-sizing: content-box;
}
6. Import the sample BSV and log on to initialize and see an example.
7. Dissect/understand and use in your own app.

A couple of notes:
- This implementation uses the URL_CONTENTS function to populate plain text attributes with the HTML needed in the query and the advanced render script of the query then targets and draws the Sparklines based off the values in the attributes. That means you have to build a feature in you app where you populate txt files with the correct HTML you want to use in a Sparkline and this is then used in the Sparkline when drawn and all of this can be done via business rules and tags in a txt document template (see/dissect sample for more details). Not the best solution but works and the reason I had to go this way is because it isn´t possible to populate "valid" HTML with quotation marks etc. into attributes using business rules.
- Using paging bars doesn´t work (the Sparklines aren´t "re-drawn" when using the default paging bar) so you have to implement your own paging bar like the example I did (I only added a process to the query ("Next" button) to show how it would work but the process doesn´t do anything, you have to add the logic to filter entries to simulate a paging bar function).
- There is a small delay when displaying the query where the values are shown and then when the advanced render script is executed (500ms delay, see advanced scripts for the query and you can play around with the delay etc. and see if you can do something else maybe or decrease delay) the Sparklines are drawn.
- You have to use a process to refresh the query (otherwise the Sparklines aren´t drawn again).
Attachments
Sparklines.zip
(49.88 KiB) Downloaded 798 times
Henrik (V8 Developer Ed. - Windows)
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Sample BSV: Sparklines in Aware V7

Post by hpl123 »

Update:
Here is a solution for the delay problem. Add a style to the html span to make the font transparent (which means the numbers are shown but invisible which is better than the delay that is in the sample above). Example:

Code: Select all

<span class="inlinesparkline" style="color:transparent !important;">1,4,4,7,5,9,10</span>
Henrik (V8 Developer Ed. - Windows)
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Sample BSV: Sparklines in Aware V7

Post by tford »

Very nice Henrik!
I had to go this way is because it isn´t possible to populate "valid" HTML with quotation marks etc. into attributes using business rules.
Have you tried to put quotation marks into a SystemSettings attribute and incorporate that attribute in the rule to build valid HTML. I used to do that many years ago when I built a BSV that exported HTML to display Fusion Charts within AwareIM.
Tom - V8.8 build 3137 - MySql / PostGres
customaware
Posts: 2401
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Sample BSV: Sparklines in Aware V7

Post by customaware »

Awesome Henrik.

What was the trick stuffing the html into the atribute. I kept getting my " doubled up
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Sample BSV: Sparklines in Aware V7

Post by hpl123 »

tford wrote:Very nice Henrik!
I had to go this way is because it isn´t possible to populate "valid" HTML with quotation marks etc. into attributes using business rules.
Have you tried to put quotation marks into a SystemSettings attribute and incorporate that attribute in the rule to build valid HTML. I used to do that many years ago when I built a BSV that exported HTML to display Fusion Charts within AwareIM.
Good point Tom and yeah that would work and is a better solution. Do you have an old rule or example laying around? I am not entirely sure how one would go about to for example get the following html into a plain text using SystemSettings for the quotation marks:

Code: Select all

<span class="inlinesparkline" style="color:transparent !important;">1,4,4,7,5,9,10</span>
Thanks
Last edited by hpl123 on Mon Nov 07, 2016 10:25 pm, edited 1 time in total.
Henrik (V8 Developer Ed. - Windows)
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Sample BSV: Sparklines in Aware V7

Post by hpl123 »

eagles9999 wrote:Awesome Henrik.

What was the trick stuffing the html into the atribute. I kept getting my " doubled up
Yeah, this was the issue I mistakenly stumbled across :). I solved it using the URL_CONTENTS function but Tom suggested something that would be better and I asked him for an example and I will use that instead.
Henrik (V8 Developer Ed. - Windows)
customaware
Posts: 2401
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Sample BSV: Sparklines in Aware V7

Post by customaware »

Ah... yes... I hve used that a number of times in the past and it usually works well.

Will test here.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
customaware
Posts: 2401
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Sample BSV: Sparklines in Aware V7

Post by customaware »

Just another note...

You do not need to mess around loading the js in the startup.html file anymore.

Just drop it in AwareIM/Custom/JS folder and it will automatically load
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Sample BSV: Sparklines in Aware V7

Post by tford »

Do you have an old rule or example laying around? I am not entirely sure how one would go about to for example get the following html into a plain text using SystemSettings for the quotation marks:
I think you might be able to find it in here or in one of the forum posts linked:
http://www.awareim.com/forum/viewtopic.php?f=4&t=3501
Tom - V8.8 build 3137 - MySql / PostGres
customaware
Posts: 2401
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Sample BSV: Sparklines in Aware V7

Post by customaware »

Henrik,

What does the setTimeOut actually do.

I have restructured to show a Pie on a normal query. However, I see it flash on and then disappears.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Sample BSV: Sparklines in Aware V7

Post by hpl123 »

eagles9999 wrote:Henrik,

What does the setTimeOut actually do.

I have restructured to show a Pie on a normal query. However, I see it flash on and then disappears.
Take a look at your autorefresh for the query, might be what messes the Sparklines up (there are some issues with refresh but using a process to refresh should solve it or at least did for the scenarios I tested).

The setTimeOut is small delay before the script to draw the Sparklines is executed and is needed because the render script is otherwise executed before the actual spans/values has been loaded in the query.
Henrik (V8 Developer Ed. - Windows)
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Sample BSV: Sparklines in Aware V7

Post by hpl123 »

hpl123 wrote:
tford wrote:Very nice Henrik!
I had to go this way is because it isn´t possible to populate "valid" HTML with quotation marks etc. into attributes using business rules.
Have you tried to put quotation marks into a SystemSettings attribute and incorporate that attribute in the rule to build valid HTML. I used to do that many years ago when I built a BSV that exported HTML to display Fusion Charts within AwareIM.
Good point Tom and yeah that would work and is a better solution. Do you have an old rule or example laying around? I am not entirely sure how one would go about to for example get the following html into a plain text using SystemSettings for the quotation marks:

Code: Select all

<span class="inlinesparkline" style="color:transparent !important;">1,4,4,7,5,9,10</span>
Thanks
Here is an example of using SystemSettings for quotation etc..:

Code: Select all

HtmlString.String='<span'+SystemSettings.Space+'class='+SystemSettings.Quotation+'inlinesparkline'+SystemSettings.Quotation+'>1,4,4,7,5,9,10</span>' 
Henrik (V8 Developer Ed. - Windows)
Post Reply