Advance SVG is a technique for publishing interactive graphics on internet. The technique can be applied for any type of graphics and format e.g. free hand drawings, business process maps, mind charts, technical diagrams etc. - for any matter that can be described with a simple, at-a-glance picture.
Advance SVG utilises the standard modern browsers’ abilities to show high quality, scalable graphics (see the HTML5 SVG specification) and to behave interactively via Cascadin Style Sheets (CSS) and JavaScript programms.
The technique involves three elements:
ASVG Script works at the background and scans the page content for mark-ups, then it enhances the graphics on the fly. It adds: responsive behaviour, pop-up effects, in-page links and icons. These features are explained further down.
Advance SVG is not an authoring tool, hence it does not help to neither create web pages nor to draw graphics. Various tools can be used for these. In order to work, it is necessary to ensure that: first, the ASVG Script is included into the web page; second, the shapes are marked-up as per the ASVG Specification and finally, the web page includes a point(s) to insert the graphic(s).
The workflow steps are as follows:
<script src="https://d2a8hhqmsel69m.cloudfront.net/bundle.js"></script>
However, adding the library into a Content Management System (CMS) like WordPress or SharePoint requires System Administrator’s work. In SharePoint the mechanism to use the library requires using a special Webpart. The topic of using the library with SharePoint is outside of the scope of this specification.
<div data-asvg="page1.svg" data-asvg-show="page1.svg" style="width:100%;"> </div>
Optional parameter: data-asvg-filelocation
<g data-asvg-popuplink=”1” …>
popup link graphic code ...
</g>
<g data-asvg-popup=”1” …>
associated popup graphic code ...
</g>
These should be added to the SVG group <g> tag.
Parameter name | Value(s) | Description | SVG <g> tag attribute |
display | L (large), M (medium), S (small) or T (thumbnail) | Provides responsive behaviour by switching between different 'scenes', depending on the graphic container's size. | data-asvg-display |
popup | id | Popup shape to be linked to a popuplink | data-asvg-popup |
popuplink | id | When selected (click or tap), it shows the associated Popup shape. | data-asvg-popuplink |
pagelink | SVG_file_name | Replace the current graphic with another SVG file. | data-asvg-pagelink |
icon-close | position | The positions are: tl, tc, tr for Top-Left … Top-Center … Top-Right. And for middle and bottom: ml, mc, mr, bl, bc and br. | data-asvg-icon-close |
icon-popuplink | data-asvg-icon-popuplink | ||
icon-pagelink | data-asvg-icon-pagelink | ||
icon-hyperlink | data-asvg-icon-hyperlink |
Note: Hyperlinks to other pages are working with the standard <a> tag.
These are implemented via ASVG transformation filter:
Parameter name | Value(s) | Description | SVG group <g> tag attribute |
title | text | The standard SVG Title tag displays text when the mouse is over. Here is an illustration code:
| none |
annotation | text | These elements are used during the graphics development only and will not be displayed. | none |
hreftarget | e.g. _blank | This works with hyperlinks for setting the target parameter - see HTML specification about the hyperlink targets. This is a work around when the graphic design software does not allow setting the hyperlink targets. Here is an illustration code:
This code will make the hyperlink to open in a new tab or window of the browser. | data-asvg-hreftarget |
The library can be used from the source code (from GitHub or NPM). See the snippet below:
import ASVG from './asvg'
/*
An instance of the ASVG class, named 'asvg', must be exposed via the window object to make onclick handlers available
*/
if( !window.asvg ){
window.asvg = new ASVG() // Accepts a parameter object with these properties: defaultFileLocation, userErrorHandler and iconMargin
window.addEventListener('load' , asvg.updateAll )
window.addEventListener('resize', asvg.updateAll )
}
ASVG Object has the following constructor parameters:
Name | Type | Default value | Description |
defaultFileLocation | string | './' | The file location where the svg files are stored. Note that |
userErrorHandler | function | err => alert( err ) | A function to notify the user for some types of errors, for example file not find error. |
iconMargin | integer | 2 | A margin, in pixels, from the shapes' borders. The positive numbers will place the icons within the shapes i.e. popuplinks, in-page links and hyperlinks. |